Hello guys, here’s my situation.
Here’s a class to storage some data.
[Serializable]
public class MyData
{
[SerializeField]
string str;
[SerializeField]
List<string> list;
}
public class MainClass : ScriptableObject
{
[SerializeField]
MyData data;
}
And then I’d like to change assign the value via editor.
[CustomEditor(typeof(MainClass))]
[CanEditMultipleObjects]
public class MainClassEditor : Editor
{
MainClass source;
SerializedProperty data;
void OnEnable()
{
source = target as StoryScript;
data = serializedObject.FindProperty("data");
}
public override void OnInspectorGUI()
{
serializedObject.ApplyModifiedProperties();
EditorGUILayout.PropertyField(data, true);
}
}
I could assign the data class value from inspector panel, it works fine.
But I have no idea how to assign the values via script in editor class.
Is here any way could do that?