void DrawUiGameObjects() { int oldValue = statesUiMode.intValue; statesUiMode.intValue = EditorGUILayout.IntPopup( statesUiMode.intValue, new string[] { "Automatic", "Manual" }, new int[] { 0, 1 } ); // Automatic if (statesUiMode.intValue == 0) { EditorGUILayout.LabelField("(all game objects are read only)", guistyleItalic); // re init items on switch from manual to automatic if (oldValue == 1) { serializedObject.ApplyModifiedProperties(); scriptStateItem.Init(true); } if (statesUi.arraySize == scriptStateItem.States.Length) { for (int i = 0; i < statesUi.arraySize; i++) { EditorGUILayout.ObjectField( i.ToString() + ". " + scriptStateItem.States [i], statesUi.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject), true ); } } } // Manual if (statesUiMode.intValue == 1) { EditorGUILayout.LabelField("(you can change any game object)", guistyleItalic); for (int i = 0; i < statesUi.arraySize; i++) { string stateName = (statesUi.arraySize == scriptStateItem.States.Length) ? scriptStateItem.States [i] : "?"; EditorGUILayout.PropertyField(statesUi.GetArrayElementAtIndex(i), new GUIContent(i.ToString() + ". " + stateName) ); } } }
protected override void InitInspector() { base.InitInspector(); // do initialization here scriptStateItem = (UIStateItem)target; if (!Application.isPlaying) { scriptStateItem.Init(true); } statesUi = serializedObject.FindProperty("statesUi"); isStateItemExpanded = serializedObject.FindProperty("isStateItemExpanded"); isStateItemStatesExpanded = serializedObject.FindProperty("isStateItemStatesExpanded"); isStateItemUiExpanded = serializedObject.FindProperty("isStateItemUiExpanded"); isStateItemTestingExpanded = serializedObject.FindProperty("isStateItemTestingExpanded"); OnStateChange = serializedObject.FindProperty("OnStateChange"); statesUiMode = serializedObject.FindProperty("statesUiMode"); defaultStateId = serializedObject.FindProperty("defaultStateId"); }