Custom Editor Array Help!

Hello!
So I created the array like so:

public string[] movementTypes = new string[] {"None", "Linear", "Path", "Roll", "HeatSeek"};

But I later decided to remove the Roll movementType. When I displayed the array in a custom editor via a Popup, it won’t update the values. I have no clue how to fix this. Please Help :slight_smile:

The Editor Popup Code:

script.movementIndexes [0] = EditorGUILayout.Popup ("Movement Type: ", script.movementIndexes [0], script.movementTypes);
  1. You should use another thread for questions about Extensions.
  2. Try to make the array private… Will it work?

Thanks for the help, but ti’s gotta stay public or the editor script can’t access it.
I’ll go make another thread now :slight_smile:

I forgot that I can’t create duplicate forums. My mistake and it got deleted. I ended up just using the unconventional way and remade my entire project with the desired changes and that worked.

Why not use an enum instead?

Are you :
A). Drawing the default editor after that, or
B). Not serilalizing your fields?

You make it private to force it to re-inialise the array with the supplied values
then make it public again

Thanks for the help guys, but like I said earlier, the problem has been fixed.
Using an enum makes the rest of my code harder to manage, so that’s a no-go.

I’m wasn’t drawing the default inspector, and I’m not really sure what serialising is. From what I have gathered with my minimal editor script knowledge, there are two sets ups that work, one is using the code like this: Editor Scripting - Unity Learn
the other uses serialising and stuff like this code:
Unity - Manual: Custom Editors

I use the first. It’s easier in my opinion. So I don’t really understand your question

I still tried to make it private, but I just got a bunch of errors and it didn’t do anything. Thanks anyway.

[SerializeField] int[] movementIndexes;

Just making sure that the fields you are accessing are serialized, that way they get updated properly if not directly using serializedObjects.

If that doesn’t work, you will need to post more code, so we can see what else might be preventing it.