Heyo
I’m trying to figure out how I have to use EditorGUILayout.MaskField. I have a normal script, which I attach to a GameObject as Component.
In this script is a String[ ] which should hold all the selected data from MaskField.
I’ve created a CustomEditor class, this all works fine on other properties like Enum (single select) or other single select values.
My only problem ist the multi select (MaskField). What I have so far for the MaskField:
int flag = EditorGUILayout.MaskField("Test", 0, allElements);
for (int i = 0; i < allElements.Length; i++)
{
int layer = 1 << i;
if ((flag & layer) != 0)
{
string selectedItem = allElements[i];
}
}
In OnEnable I have the following:
public void OnEnable()
{
elementsToColor = serializedObject.FindProperty("_elementsToColor");
}
I also have this at the end of the script:
serializedObject.ApplyModifiedProperties();
These is the propery from the Component script class.
Can someone please help me?