public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { // Set up quest picker: if (questPicker == null) { questPicker = new QuestPicker(EditorTools.FindInitialDatabase(), prop.stringValue, true); } // Set up property drawer: EditorGUI.BeginProperty(position, GUIContent.none, prop); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); if (EditorTools.selectedDatabase == null) { EditorTools.SetInitialDatabaseIfNull(); } if (ShowReferenceDatabase()) { var dbPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); position = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width, position.height - EditorGUIUtility.singleLineHeight); EditorTools.selectedDatabase = EditorGUI.ObjectField(dbPosition, questPicker.database, typeof(DialogueDatabase), true) as DialogueDatabase; } if (EditorTools.selectedDatabase != questPicker.database) { questPicker.database = EditorTools.selectedDatabase; questPicker.UpdateTitles(); } questPicker.Draw(position); prop.stringValue = questPicker.currentQuest; EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { var trigger = target as ConditionObserver; if (trigger == null) { return; } // Reference database: EditorTools.selectedDatabase = EditorGUILayout.ObjectField("Reference Database", EditorTools.selectedDatabase, typeof(DialogueDatabase), false) as DialogueDatabase; // Frequency, once, observeGameObject: trigger.frequency = EditorGUILayout.FloatField(new GUIContent("Frequency", "Frequency in seconds between checks"), trigger.frequency); trigger.once = EditorGUILayout.Toggle(new GUIContent("Only Once", "Destroy after the condition is true"), trigger.once); trigger.observeGameObject = EditorGUILayout.ObjectField(new GUIContent("Observe GameObject", "Refer to this GameObject when evaluating the Condition"), trigger.observeGameObject, typeof(GameObject), false) as GameObject; // Condition: EditorTools.DrawSerializedProperty(serializedObject, "condition"); actionFoldout = EditorGUILayout.Foldout(actionFoldout, "Action"); if (!actionFoldout) { return; } EditorWindowTools.StartIndentedSection(); // Lua code / wizard: if (EditorTools.selectedDatabase != luaScriptWizard.database) { luaScriptWizard.database = EditorTools.selectedDatabase; luaScriptWizard.RefreshWizardResources(); } trigger.luaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true"), trigger.luaCode); // Quest: if (EditorTools.selectedDatabase != questPicker.database) { questPicker.database = EditorTools.selectedDatabase; questPicker.UpdateTitles(); } questPicker.Draw(); trigger.questName = questPicker.currentQuest; trigger.useQuestNamePicker = questPicker.usePicker; trigger.questState = (QuestState)EditorGUILayout.EnumPopup(new GUIContent("Quest State", "The new quest state"), trigger.questState); // Alert message: trigger.alertMessage = EditorGUILayout.TextField(new GUIContent("Alert Message", "Optional alert message to display when triggered"), trigger.alertMessage); trigger.localizedTextTable = EditorGUILayout.ObjectField(new GUIContent("Localized Text Table", "The localized text table to use for the alert message text"), trigger.localizedTextTable, typeof(LocalizedTextTable), true) as LocalizedTextTable; // Send Messages list: EditorTools.DrawSerializedProperty(serializedObject, "sendMessages"); EditorWindowTools.EndIndentedSection(); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { // Set up quest picker: if (questPicker == null) { questPicker = new QuestPicker(EditorTools.FindInitialDatabase(), prop.stringValue, true); } if (EditorTools.selectedDatabase != questPicker.database) { questPicker.database = EditorTools.selectedDatabase; questPicker.UpdateTitles(); } // Set up property drawer: EditorGUI.BeginProperty(position, GUIContent.none, prop); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); questPicker.Draw(position); EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { var trigger = target as ConditionObserver; if (trigger == null) { return; } serializedObject.Update(); // Reference database: EditorTools.selectedDatabase = EditorGUILayout.ObjectField(new GUIContent("Reference Database", "Database to use for pop-up menus. Assumes this database will be in memory at runtime."), EditorTools.selectedDatabase, typeof(DialogueDatabase), false) as DialogueDatabase; // Frequency, once, observeGameObject: EditorGUILayout.PropertyField(serializedObject.FindProperty("frequency"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("once"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("observeGameObject"), true); // Condition: foldouts.conditionFoldout = EditorWindowTools.EditorGUILayoutFoldout("Conditions", "Conditions that must be true for trigger to fire.", foldouts.conditionFoldout); if (foldouts.conditionFoldout) { try { EditorWindowTools.EditorGUILayoutBeginGroup(); ConditionPropertyDrawer.hideMainFoldout = true; var conditionProperty = serializedObject.FindProperty("condition"); conditionProperty.isExpanded = true; EditorGUILayout.PropertyField(conditionProperty, true); ConditionPropertyDrawer.hideMainFoldout = false; } finally { EditorWindowTools.EditorGUILayoutEndGroup(); } } // Action: foldouts.actionFoldout = EditorWindowTools.EditorGUILayoutFoldout("Actions", "Actions to run when the observed condition becomes true.", foldouts.actionFoldout); if (foldouts.actionFoldout) { try { EditorWindowTools.EditorGUILayoutBeginGroup(); serializedObject.ApplyModifiedProperties(); // Lua code / wizard: if (EditorTools.selectedDatabase != luaScriptWizard.database) { luaScriptWizard.database = EditorTools.selectedDatabase; luaScriptWizard.RefreshWizardResources(); } EditorGUI.BeginChangeCheck(); var newLuaCode = luaScriptWizard.Draw(new GUIContent("Lua Code", "The Lua code to run when the condition is true"), trigger.luaCode); // Sequence: var newSequence = SequenceEditorTools.DrawLayout(new GUIContent("Sequence"), trigger.sequence, ref sequenceRect, ref sequenceSyntaxState); // Quest: if (EditorTools.selectedDatabase != questPicker.database) { questPicker.database = EditorTools.selectedDatabase; questPicker.UpdateTitles(); } questPicker.Draw(); var newQuestName = questPicker.currentQuest; var newUseQuestNamePicker = questPicker.usePicker; var changed = EditorGUI.EndChangeCheck(); serializedObject.Update(); if (changed) { serializedObject.FindProperty("luaCode").stringValue = newLuaCode; serializedObject.FindProperty("sequence").stringValue = newSequence; serializedObject.FindProperty("questName").stringValue = newQuestName; serializedObject.FindProperty("useQuestNamePicker").boolValue = newUseQuestNamePicker; } EditorGUILayout.PropertyField(serializedObject.FindProperty("questState"), true); // Alert message: EditorGUILayout.PropertyField(serializedObject.FindProperty("alertMessage"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("textTable"), true); // Send Messages list: DrawSendMessageAction(); } finally { EditorWindowTools.EditorGUILayoutEndGroup(); } } serializedObject.ApplyModifiedProperties(); }