Are you using: “MyObject objects[ ]”, or some other kind of array?
I believe you have to use “EditorUtility.SetDirty(target)” to tell Unity to update the edited object’s … uh, stuff in the project. So it saves between edit and play mode. There’s a word for that stuff.
It is excalty an object[ ] I am using in my project.
I will try the SetDirty() method as soon as possible !
Thanks for your advice !
Edit :
It doesn’t work. (but I maybe dont insert it at the right place).
My object[ ] just contain one parameter which is a int set to 5;
When I press Play, my object[ ] contain one parameter : null
I got one class containing values and the parameters (object[ ]) :
[System.Serializable]
public class ItemCaller : MonoBehaviour
{
public GameObject gameobjectTocall;
public Component scriptToCall;
public int selectedMethod;
public MethodInfo methodToCall;
[SerializeField]
public object[] parameters;
void Start()
{
Debug.Log(gameobjectTocall);
Debug.Log(scriptToCall);
Debug.Log(selectedMethod);
Debug.Log(parameters.Length);
Debug.Log(parameters[0]);
//methodToCall.Invoke(scriptToCall, parameters);
}
}
And my EditorClass :
[CustomEditor(typeof(ItemCaller))]
public class EditorTest : Editor
{
private ItemCaller actual;
...
public void OnEnable()
{
actual = (ItemCaller)target;
...
}
public override void OnInspectorGUI()
{
serializedObject.Update();
if ( GUI.changed ) EditorUtility.SetDirty( actual );
...
}
}
I put your line there, I think it is ok…
I put paramters value on my object array and they are keep in memory in the editor.
But when I play my scene, all parameters are OK onyl my object[ ] is full of null items.