public override void OnInspectorGUI() { serializedObject.Update(); // if there are no elements reset _currentlySelectedConversationIndex if (conversationsList.serializedProperty.arraySize - 1 < _currentlySelectedConversationIndex) { _currentlySelectedConversationIndex = -1; } conversationsList.DoLayoutList(); if (GUILayout.Button("Save Conversations")) { _conversationTrigger.SaveConversations(); } if (GUILayout.Button("Load Conversations")) { Undo.RecordObject(_conversationTrigger, "Loaded conversations from JSON"); _conversationTrigger.LoadConversations(); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { // Load the current values from the real component into the serialized copy serializedObject.Update(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); GUILayout.Space(10); conversationList.DoLayoutList(); EditorGUILayout.EndScrollView(); GUILayout.Space(100); if (GUILayout.Button("Save Conversations")) { conversationTrigger.SaveConversations(); } GUILayout.Space(10); if (GUILayout.Button("Load Conversations")) { Undo.RecordObject(conversationtrigger, "Loaded conversations from JSON"); conversationTrigger.LoadConversations(); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); DrawDefaultInspector(); EditorGUILayout.EndScrollView(); // Load the current values from the real component into the serialized copy serializedObject.Update(); if (GUILayout.Button("Add new conversation")) { conversations.arraySize++; } GUILayout.Space(10); if (conversations.arraySize != 0) { if (GUILayout.Button("Remove conversation")) { if (conversations.arraySize > 0) { conversations.arraySize--; } } } GUILayout.Space(100); if (GUILayout.Button("Save Conversations")) { conversationTrigger.SaveConversations(); } GUILayout.Space(10); if (GUILayout.Button("Load Conversations")) { // Depending on what this does you should consider to also // change it to using the SerializedProperties! Undo.RecordObject(conversationtrigger, "Loaded conversations from JSON"); conversationTrigger.LoadConversations(); } serializedObject.ApplyModifiedProperties(); }