Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why getting errors SerializedObjectNotCreatableException: Object at index 0 is null and InvalidCastException: Specified cast is not valid.?

There are no any specific lines of any script in the errors. I tried to add animation to my character then deleted the animation and removed it from the animator controller and the errors happens.

I deleted everything from the hierarchy also in the assets deleted any packages assets i installed. and still the errors show.

I have this errors also in another project, started yesterday.

I'm using unity 2021.3.2f1 Personal

Each error show twice the same :

SerializedObjectNotCreatableException: Object at index 0 is null UnityEditor.Editor.CreateSerializedObject () (at :0) UnityEditor.Editor.GetSerializedObjectInternal () (at :0) UnityEditor.Editor.get_serializedObject () (at :0) UnityEditor.BaseAssetImporterTabUI.get_serializedObject () (at :0) UnityEditor.ModelImporterClipEditor.UnregisterListeners () (at :0) UnityEditor.ModelImporterClipEditor.OnDisable () (at :0) UnityEditor.ModelImporterEditor.OnDisable () (at :0)

And

InvalidCastException: Specified cast is not valid. UnityEditor.AssetImporters.AssetImporterEditor.InitializePostprocessors () (at :0) UnityEditor.AssetImporters.AssetImporterEditor.OnEnable () (at :0) UnityEditor.AssetImporterTabbedEditor.OnEnable () (at :0) UnityEditor.ModelImporterEditor.OnEnable () (at :0)

like image 452
Daniel Lip Avatar asked Nov 15 '25 03:11

Daniel Lip


2 Answers

Sometimes this happens if you have a second Inspector window open in Unity!

Try closing every Inspector window you can find. (It may be hiding somewhere weird.) Make sure the little lock icon in the top right is "unlocked."

You can also reset your layout to factory settings through the Window menu, if you're comfortable doing so.

After that, close all instances of Unity and re-open one of them. (For me it's Window -> Layouts -> Revert Factory Settings...)

If the error is fixed, then you can get the Inspector back by going to Window -> Windows -> Inspector.

EDIT: Looking more closely, I see that the errors are referencing the Unity Asset Importer and the Model Importer. That makes me think even more that the window that looks like this (or something related to it) is bugging out:

Image of the Unity Inspector window, showing model import settings with tabs named "Model," "Rig," "Animation," and "Materials."

like image 150
sleepysheepy Avatar answered Nov 17 '25 20:11

sleepysheepy


How I fixed?

  1. Reset layout close all instpector window and reopen Window->General->Inspector (this bug is cuz by 2nd inspector window).
  2. Restart unity after closing.
like image 37
Abdullah Arif Avatar answered Nov 17 '25 20:11

Abdullah Arif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!