public override void OnInspectorGUI() { ActionListAsset _target = (ActionListAsset)target; ActionListAssetEditor.ShowPropertiesGUI(_target); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject(_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject(_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow.Init(_target); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button("Run now", EditorStyles.miniButtonRight)) { if (KickStarter.actionListAssetManager != null) { if (!_target.canRunMultipleInstances) { int numRemoved = KickStarter.actionListAssetManager.EndAssetList(_target); if (numRemoved > 0) { ACDebug.Log("Removed 1 instance of ActionList asset '" + _target.name + "' because it is set to only run one at a time.", _target); } } AdvGame.RunActionListAsset(_target); } else { ACDebug.LogWarning("An AC PersistentEngine object must be present in the scene for ActionList assets to run.", _target); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (actionsManager == null) { EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable(); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i = 0; i < _target.actions.Count; i++) { int typeIndex = KickStarter.actionsManager.GetActionTypeIndex(_target.actions[i]); if (_target.actions[i] == null) { RebuildAction(_target.actions[i], typeIndex, _target, i); } _target.actions[i].isAssetFile = true; EditorGUILayout.BeginVertical("Button"); string actionLabel = " (" + i + ") " + actionsManager.GetActionTypeLabel(_target.actions[i], true); actionLabel = actionLabel.Replace("\r\n", ""); actionLabel = actionLabel.Replace("\n", ""); actionLabel = actionLabel.Replace("\r", ""); if (actionLabel.Length > 40) { actionLabel = actionLabel.Substring(0, 40) + "..)"; } EditorGUILayout.BeginHorizontal(); _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.Width(100f)); } if (GUILayout.Button("", CustomStyles.IconCog)) { ActionSideMenu(_target.actions[i]); } EditorGUILayout.EndHorizontal(); if (_target.actions[i].isDisplayed) { if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString())) { EditorGUILayout.HelpBox("This Action type is not listed in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd(); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject(_target, "Change Action type"); RebuildAction(_target.actions[i], newTypeIndex, _target, i, _end); } EditorGUILayout.Space(); GUI.enabled = _target.actions[i].isEnabled; if (_target.useParameters) { if (Application.isPlaying) { _target.actions[i].AssignValues(_target.parameters); } _target.actions[i].ShowGUI(_target.parameters); } else { if (Application.isPlaying) { _target.actions[i].AssignValues(null); } _target.actions[i].ShowGUI(null); } } GUI.enabled = true; } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i] is ActionCheck || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("Add new Action")) { Undo.RecordObject(_target, "Create action"); AddAction(ActionsManager.GetDefaultAction(), _target.actions.Count, _target); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
private void ButtonGUI(Button button, string suffix, InteractionSource source, bool isForInventory = false) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { EditorGUILayout.BeginHorizontal(); button.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", button.assetFile, false, "", "The ActionList asset to run"); if (button.assetFile == null) { if (GUILayout.Button("Create", autoWidth)) { string defaultName = GenerateInteractionName(suffix, true); #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\._]", ""); #else defaultName = ""; #endif button.assetFile = ActionListAssetMenu.CreateAsset(defaultName); } } else if (GUILayout.Button("", CustomStyles.IconNodes)) { ActionListEditorWindow.Init(button.assetFile); } EditorGUILayout.EndHorizontal(); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.assetFile.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", button.customScriptObject, true, "", "The GameObject with the custom script to run"); button.customScriptFunction = CustomGUILayout.TextField("Message to send:", button.customScriptFunction, "", "The name of the function to run"); if (isForInventory) { EditorGUILayout.HelpBox("If the receiving function has an integer parameter, the Inventory item's ID will be passed to it.", MessageType.Info); } } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction:", button.interaction, true, "", "The Interaction ActionList to run"); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = GenerateInteractionName(suffix, false); button.interaction = newInteraction; } } else { if (GUILayout.Button("", CustomStyles.IconNodes)) { ActionListEditorWindow.Init(button.interaction); } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.interaction.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } } button.playerAction = (PlayerAction)CustomGUILayout.EnumPopup("Player action:", button.playerAction, "", "What the Player prefab does after clicking the Hotspot, but before the Interaction itself is run"); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = CustomGUILayout.Toggle("Cutscene while moving?", button.isBlocking, "", "If True, then gameplay will be blocked while the Player moves"); button.faceAfter = CustomGUILayout.Toggle("Face after moving?", button.faceAfter, "", "If True, then the Player will face the Hotspot after reaching the Marker"); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = CustomGUILayout.Toggle("Set minimum distance?", button.setProximity, "", "If True, then the Interaction will be run once the Player is within a certain distance of the Hotspot"); if (button.setProximity) { button.proximity = CustomGUILayout.FloatField("Proximity:", button.proximity, "", "The proximity the Player must be within"); } } } }
private void ButtonGUI(Button button, string suffix, InteractionSource source, bool isForInventory = false) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { EditorGUILayout.BeginHorizontal(); button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false); if (button.assetFile == null) { if (GUILayout.Button("Create", autoWidth)) { string defaultName = GenerateInteractionName(suffix); #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\_]", ""); #else defaultName = ""; #endif button.assetFile = ActionListAssetMenu.CreateAsset(defaultName); } } else if (GUILayout.Button("", Resource.NodeSkin.customStyles[13], GUILayout.Width(20f))) { ActionListEditorWindow.Init(button.assetFile); } EditorGUILayout.EndHorizontal(); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); if (button.parameterID >= 0 && _target.GetComponent <ConstantID>() == null) { EditorGUILayout.HelpBox("A Constant ID component must be added to the Hotspot in order for it to be passed as a parameter.", MessageType.Warning); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true); button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction); if (isForInventory) { EditorGUILayout.HelpBox("If the receiving function has an integer parameter, the Inventory item's ID will be passed to it.", MessageType.Info); } } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = GenerateInteractionName(suffix); button.interaction = newInteraction; } } else { if (GUILayout.Button("", Resource.NodeSkin.customStyles[13], GUILayout.Width(20f))) { ActionListEditorWindow.Init(button.interaction); } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); } } button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking); button.faceAfter = EditorGUILayout.Toggle("Face after moving?", button.faceAfter); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity); if (button.setProximity) { button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity); } } } }
protected void DrawSharedElements(ActionList _target) { if (IsActionListPrefab(_target)) { EditorGUILayout.HelpBox("Scene-based Actions can not live in prefabs - use ActionList assets instead.", MessageType.Info); return; } int numActions = 0; if (_target.source != ActionListSource.AssetFile) { numActions = _target.actions.Count; if (numActions < 1) { numActions = 1; AddAction(ActionsManager.GetDefaultAction(), -1, _target); } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (_target.source == ActionListSource.AssetFile) { GUI.enabled = false; } if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject(_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject(_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } GUI.enabled = true; if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid)) { if (_target.source == ActionListSource.AssetFile) { if (_target.assetFile != null) { ActionListEditorWindow.Init(_target.assetFile); } } else { ActionListEditorWindow.Init(_target); } } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button("Run now", EditorStyles.miniButtonRight)) { _target.Interact(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (_target.source == ActionListSource.AssetFile) { return; } ActionListEditor.ResetList(_target); actionsManager = AdvGame.GetReferences().actionsManager; if (actionsManager == null) { EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable(); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i = 0; i < _target.actions.Count; i++) { if (_target.actions[i] == null) { ACDebug.LogWarning("An empty Action was found, and was deleted", _target); _target.actions.RemoveAt(i); numActions--; continue; } _target.actions[i].AssignParentList(_target); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); int typeIndex = actionsManager.GetActionTypeIndex(_target.actions[i]); string actionLabel = " (" + i.ToString() + ") " + actionsManager.GetActionTypeLabel(_target.actions[i], true); actionLabel = actionLabel.Replace("\r\n", ""); actionLabel = actionLabel.Replace("\n", ""); actionLabel = actionLabel.Replace("\r", ""); if (actionLabel.Length > 40) { actionLabel = actionLabel.Substring(0, 40) + "..)"; } _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.MaxWidth(100f)); } if (GUILayout.Button("", CustomStyles.IconCog)) { ActionSideMenu(i); } _target.actions[i].isAssetFile = false; EditorGUILayout.EndHorizontal(); if (_target.actions[i].isBreakPoint) { EditorGUILayout.HelpBox("Break point", MessageType.None); } if (_target.actions[i].isDisplayed) { GUI.enabled = _target.actions[i].isEnabled; if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString())) { EditorGUILayout.HelpBox("This Action type is not listed in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd(); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject(_target, "Change Action type"); _target.actions[i] = RebuildAction(_target.actions[i], newTypeIndex, _target, -1, _end); } if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0) { _target.actions[i].ShowGUI(_target.parameters); } else { _target.actions[i].ShowGUI(null); } } } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i].numSockets == 2 || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed); } GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("Add new action")) { Undo.RecordObject(_target, "Create action"); numActions += 1; } _target = ActionListEditor.ResizeList(_target, numActions); }
protected void DrawSharedElements(ActionList _target) { if (PrefabUtility.GetPrefabType(_target) == PrefabType.Prefab) { EditorGUILayout.HelpBox("Scene-based Actions can not live in prefabs - use ActionList assets instead.", MessageType.Info); return; } if (_target.source == ActionListSource.AssetFile) { return; } int numActions = _target.actions.Count; if (numActions < 1) { numActions = 1; AC.Action newAction = ActionList.GetDefaultAction(); _target.actions.Add(newAction); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject(_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject(_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow.Init(_target); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button("Run now", EditorStyles.miniButtonRight)) { _target.Interact(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); ActionListEditor.ResetList(_target); if (actionsManager == null) { EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable(); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i = 0; i < _target.actions.Count; i++) { if (_target.actions[i] == null) { ACDebug.LogWarning("An empty Action was found, and was deleted"); _target.actions.RemoveAt(i); continue; } EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); int typeIndex = KickStarter.actionsManager.GetActionTypeIndex(_target.actions[i]); string actionLabel = " (" + (i).ToString() + ") " + actionsManager.EnabledActions[typeIndex].GetFullTitle() + _target.actions[i].SetLabel(); _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.MaxWidth(100f)); } Texture2D icon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D)); if (GUILayout.Button(icon, GUILayout.Width(20f), GUILayout.Height(15f))) { ActionSideMenu(i); } _target.actions[i].isAssetFile = false; EditorGUILayout.EndHorizontal(); if (_target.actions[i].isBreakPoint) { EditorGUILayout.HelpBox("Break point", MessageType.None); } if (_target.actions[i].isDisplayed) { GUI.enabled = _target.actions[i].isEnabled; if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString())) { EditorGUILayout.HelpBox("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd(); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject(_target, "Change Action type"); _target.actions[i] = ActionListEditor.RebuildAction(_target.actions[i], newTypeIndex, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); } if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0) { _target.actions[i].ShowGUI(_target.parameters); } else { _target.actions[i].ShowGUI(null); } } } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i].numSockets == 2 || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed); } GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("Add new action")) { Undo.RecordObject(_target, "Create action"); numActions += 1; } _target.actions = ActionListEditor.ResizeList(_target.actions, numActions); }
private void NodeWindow(int ID) { if (ID == -2) { GUILayout.Label(lastConversation.gameObject.name); } else if (ID == -1) { GUILayout.Label(conversation.gameObject.name); } else if (ID < conversation.options.Count) { GUILayout.BeginHorizontal(); conversation.options[ID].label = GUILayout.TextField(conversation.options[ID].label); if (GUILayout.Button("-", GUILayout.Width(20f))) { Undo.RecordObject(this, "Delete dialogue option"); foreach (ButtonDialog option in conversation.options) { option.isEditing = false; } conversation.selectedOption = null; conversation.options.RemoveAt(ID); } GUILayout.EndHorizontal(); } else if (ID < conversation.options.Count * 2) { int i = ID - conversation.options.Count; if (conversation.interactionSource == InteractionSource.AssetFile) { conversation.options[i].assetFile = (ActionListAsset)EditorGUILayout.ObjectField(conversation.options[i].assetFile, typeof(ActionListAsset), false); } else if (conversation.interactionSource == InteractionSource.CustomScript) { GUILayout.Label("(Set in Inspector)"); } else if (conversation.interactionSource == InteractionSource.InScene) { if (conversation.options[i].dialogueOption != null) { GUILayout.BeginHorizontal(); string label = conversation.options[i].dialogueOption.gameObject.name; if (label.Length > 22) { label = label.Substring(0, 22); } if (GUILayout.Button(label)) { if (conversation.interactionSource == InteractionSource.InScene) { Selection.activeGameObject = conversation.options[i].dialogueOption.gameObject; } } if (GUILayout.Button("", Resource.NodeSkin.customStyles[13])) { if (conversation.interactionSource == InteractionSource.InScene) { ActionListEditorWindow.Init(conversation.options[i].dialogueOption); } else { ActionListEditorWindow.Init(conversation.options[i].dialogueOption.assetFile); } } GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("(Not set)"); if (GUILayout.Button("Create")) { Undo.RecordObject(conversation, "Auto-create dialogue option"); DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>(); newDialogueOption.gameObject.name = AdvGame.UniqueName(conversation.gameObject.name + "_Option"); newDialogueOption.Initialise(); EditorUtility.SetDirty(newDialogueOption); conversation.options[i].dialogueOption = newDialogueOption; } GUILayout.EndHorizontal(); } } } else if (ID < conversation.options.Count * 3) { int i = ID - (conversation.options.Count * 2); conversation.options[i].conversationAction = (ConversationAction)EditorGUILayout.EnumPopup(conversation.options[i].conversationAction); } else { int i = ID - (conversation.options.Count * 3); if (conversation.options[i].newConversation != null) { conversation.options[i].newConversation = (Conversation)EditorGUILayout.ObjectField(conversation.options[i].newConversation, typeof(Conversation), true); } else { GUILayout.BeginHorizontal(); conversation.options[i].newConversation = (Conversation)EditorGUILayout.ObjectField(conversation.options[i].newConversation, typeof(Conversation), true); if (GUILayout.Button("Create")) { Undo.RecordObject(conversation, "Auto-create conversation"); Conversation newConversation = SceneManager.AddPrefab("Logic", "Conversation", true, false, true).GetComponent <Conversation>(); conversation.options[i].newConversation = newConversation; } GUILayout.EndHorizontal(); } } }
/// <summary> /// Draws actual editor window UI /// </summary> void OnGUI() { GUILayout.Label("Gather text from Adventure Creator Speech Manager before using this editor"); // Button for manual refresh if (GUILayout.Button(new GUIContent("Refresh", null, "Manually refresh the list of speech below"))) { FindSpeech(); } // Some informational output about found speech GUILayout.Label(string.Format("Showing {0} of {1} speech items", displayedLines.Count, discoveredLines.Count)); GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); currentTextFilter = EditorGUILayout.TextField("Filter", currentTextFilter); if (EditorGUI.EndChangeCheck()) { UpdateDisplayedLines(); } if (GUILayout.Button(new GUIContent("X", null, "Clear filter"), GUILayout.Width(20F))) { currentTextFilter = string.Empty; UpdateDisplayedLines(); } GUILayout.EndHorizontal(); // Scroll area for all the individual speech scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandHeight(true)); Color origBack = GUI.backgroundColor; if (displayedLines.Count == 0) { GUILayout.Label("No speech actions found"); } for (int n = 0; n < displayedLines.Count; n++) { if (displayedLines[n].SerializedActionSpeech.targetObject == null) { FindSpeech(); break; } // Synchronize SO displayedLines[n].SerializedActionSpeech.Update(); EditorGUI.BeginChangeCheck(); // Color each row differently for easier visual guidance (but only the background box!) GUI.backgroundColor = n % 2 == 0 ? Color.blue : Color.green; EditorGUILayout.BeginVertical("Box"); GUILayout.Space(3F); GUI.backgroundColor = origBack; var propIsPlayer = displayedLines[n].SerializedActionSpeech.FindProperty("isPlayer"); var propSpeaker = displayedLines[n].SerializedActionSpeech.FindProperty("speaker"); var prop = displayedLines[n].SerializedActionSpeech.FindProperty("messageText"); var propSpeechOrder = displayedLines[n].SpeechOrder; // Get the speech order var speaker = (propSpeaker.objectReferenceValue as Char); EditorGUILayout.BeginHorizontal(); GUILayout.Label(propIsPlayer.boolValue ? "Player" : (speaker == null ? "Narration" : speaker.speechLabel), GUILayout.Width(150F)); GUILayout.Label(propSpeechOrder, GUILayout.Width(300F)); // Display the speech order prop.stringValue = EditorGUILayout.TextArea(prop.stringValue); if (GUILayout.Button("Goto", GUILayout.Width(100F))) { ActionListEditorWindow.Init(displayedLines[n].ContainedList); } EditorGUILayout.EndHorizontal(); GUILayout.Space(3F); EditorGUILayout.EndVertical(); // When something changed, apply SO props and generate a undo action if (EditorGUI.EndChangeCheck()) { Undo.SetCurrentGroupName("Text modification"); displayedLines[n].SerializedActionSpeech.ApplyModifiedProperties(); // Manually set it all dirty EditorUtility.SetDirty(displayedLines[n].ContainedList); EditorUtility.SetDirty(displayedLines[n].SerializedActionSpeech.targetObject); } } EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { ActionListAsset _target = (ActionListAsset)target; EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Asset properties", EditorStyles.boldLabel); _target.actionListType = (ActionListType)EditorGUILayout.EnumPopup("When running:", _target.actionListType); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = EditorGUILayout.Toggle("Is skippable?", _target.isSkippable); _target.unfreezePauseMenus = EditorGUILayout.Toggle("Unfreeze 'pause' Menus?", _target.unfreezePauseMenus); } _target.useParameters = EditorGUILayout.Toggle("Use parameters?", _target.useParameters); EditorGUILayout.EndVertical(); if (_target.useParameters) { ShowParametersGUI(_target); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject(_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject(_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow.Init(_target); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button("Run now", EditorStyles.miniButtonRight)) { AdvGame.RunActionListAsset(_target); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (actionsManager == null) { EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable(); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i = 0; i < _target.actions.Count; i++) { int typeIndex = KickStarter.actionsManager.GetActionTypeIndex(_target.actions[i]); if (_target.actions[i] == null) { _target.actions.Insert(i, ActionListAssetEditor.RebuildAction(_target.actions[i], typeIndex, _target)); } _target.actions[i].isAssetFile = true; EditorGUILayout.BeginVertical("Button"); string actionLabel = " " + (i).ToString() + ": " + actionsManager.EnabledActions[typeIndex].GetFullTitle() + _target.actions[i].SetLabel(); EditorGUILayout.BeginHorizontal(); _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.Width(100f)); } Texture2D icon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D)); if (GUILayout.Button(icon, GUILayout.Width(20f), GUILayout.Height(15f))) { ActionSideMenu(_target.actions[i]); } EditorGUILayout.EndHorizontal(); if (_target.actions[i].isDisplayed) { if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString())) { EditorGUILayout.HelpBox("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd(); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject(_target, "Change Action type"); _target.actions.Insert(i, ActionListAssetEditor.RebuildAction(_target.actions[i], newTypeIndex, _target, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene)); } EditorGUILayout.Space(); GUI.enabled = _target.actions[i].isEnabled; if (_target.useParameters) { _target.actions[i].ShowGUI(_target.parameters); } else { _target.actions[i].ShowGUI(null); } } GUI.enabled = true; } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i] is ActionCheck || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("Add new Action")) { Undo.RecordObject(_target, "Create action"); AddAction(actionsManager.GetActionName(actionsManager.defaultClass), _target.actions.Count, _target); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }