I want if SerializeField has default value then remove in yaml field.
or can I use
SerializedProperty
to cast value dynamically (like thing)?
for example :
# (scene asset or prefab, asset, etc...)
...yaml data...
items:
- value: 157899130
...yaml data...
SerializedProperty v = serializedObject.FindProperty("value");
Debug.Log(v.stringValue); //returns 157899130 as string value.
Debug.Log(v.objectReferenceValue); //returns 157899130 as referencing UnityEngine.Object from fileID.
The reason I need this…
I want to create an RPGmaker-style event editor that is flexible and easy to edit.
However, SerializeField always has a fixed size and specification. I know this can be safe for type definitions. But I want to use it flexibly.
I wanted to use the int, string and ObjectField to refer to a scene or prefab. so that it could be edited and applied freely in the editor script, but unfortunately, SerializeField was hard to make it light because it strictly adheres to the specified standard as mentioned above.
At first I tried to create multiple classes that inherit one class to solve this, but it can
parent class only to be serialized.
So the second time I tried to make it using only string values. I was able to easily cast values such as int, float Vector3, etc. to a string.
But it was too difficult to implement the fields that reference UnityEngine.Object.
So as a last resort, I created and assigned a class with multiple values (int, string, Vector3, UnityEngine.Object, never custom class).
I succeeded in implementing what I wanted but, the problem is that fields that are not used are also serialized, which can make them heavy.
I am looking for a way to figure out how to solve this.
have any solution?