I am making a custom editor for a component that holds a SceneReference as a serialized field. Teh SceneReference is a type from this package.
I had problems with serializedObject
, so I decided to draw the custom editor without using the SerializedObject API. Example:
// on OnInspectorGUI()
var newField = EditorGUILayout.Toggle("Is some field true", targetComp.someField);
if (newField != targetComp.someField)
{
wereModifications = true;
Undo.RecordObject(targetComp, "something was modified");
targetComp.someField = newField;
}
// At the end...
if (wereModifications)
{
EditorUtility.SetDirty(targetComp);
}
This seems to actually work well. It even serializes the SceneReference correctly.
The only thing is that the SetDirty
call logs an error in the Unity console:
Unsupported type SceneReference
There’s no stack trace.
Even though it all seems to work well, I want to get rid of this error to avoid confusion. How could I do that?
Edit: It doesn’t log this error on newly created components. It seems like the error is logged due to outdated serialization. So, forcing reserialization on old components should prevent the error log.