Пример #1
0
        private bool DrawBarkUISection()
        {
            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.BeginHorizontal();
            IBarkUI barkUI    = npcObject.GetComponentInChildren(typeof(IBarkUI)) as IBarkUI;
            bool    hasBarkUI = (barkUI != null);

            EditorGUILayout.LabelField("Bark UI", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            EditorWindowTools.StartIndentedSection();
            if (hasBarkUI)
            {
                EditorGUILayout.HelpBox("The NPC has a bark UI, so it will be able to display barks.", MessageType.None);
            }
            else
            {
                EditorGUILayout.HelpBox("The NPC needs a bark UI to be able to display barks. Click Default Bark UI to add a default Unity GUI bark UI, or assign one manually from Window > Dialogue System > Component > UI.", MessageType.Info);
                if (GUILayout.Button("Default Bark UI", GUILayout.Width(160)))
                {
                    npcObject.AddComponent <PixelCrushers.DialogueSystem.UnityGUI.UnityBarkUI>();
                    hasBarkUI = true;
                }
            }
            EditorWindowTools.EndIndentedSection();
            return(hasBarkUI);
        }
 private void DrawDialogueTreeSearchBar()
 {
     EditorWindowTools.DrawHorizontalLine();
     EditorGUILayout.BeginHorizontal();
     GUI.SetNextControlName("SearchEmptyLabel");
     EditorGUILayout.LabelField(string.Empty, GUILayout.Width(8));
     searchString = EditorGUILayout.TextField("Search", searchString, "ToolbarSeachTextField");
     if (GUILayout.Button("Clear", "ToolbarSeachCancelButton"))
     {
         searchString = string.Empty;
         GUI.FocusControl("SearchEmptyLabel");                 // Need to deselect search field to clear text field's display.
     }
     EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(searchString));
     if (GUILayout.Button("↓", EditorStyles.miniButtonLeft, GUILayout.Width(22)))
     {
         SearchDialogueTree(1);
     }
     if (GUILayout.Button("↑", EditorStyles.miniButtonMid, GUILayout.Width(22)))
     {
         SearchDialogueTree(-1);
     }
     EditorGUI.EndDisabledGroup();
     if (GUILayout.Button("X", EditorStyles.miniButtonRight, GUILayout.Width(22)))
     {
         isSearchBarOpen = false;
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.LabelField(string.Empty, GUILayout.Height(1));
 }
Пример #3
0
        public static void DrawOverrideNameSubsection(GameObject character)
        {
            EditorGUILayout.LabelField("Override Actor Name", EditorStyles.boldLabel);
            OverrideActorName overrideActorName = character.GetComponent <OverrideActorName>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox(string.Format("By default, the dialogue UI will use the name of the GameObject ({0}). You can override it below.", character.name), MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasOverrideActorName = EditorGUILayout.Toggle((overrideActorName != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("Override actor name", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasOverrideActorName)
            {
                if (overrideActorName == null)
                {
                    overrideActorName = character.AddComponent <OverrideActorName>();
                }
                overrideActorName.overrideName = EditorGUILayout.TextField("Actor Name", overrideActorName.overrideName);
            }
            else
            {
                DestroyImmediate(overrideActorName);
            }
            EditorWindowTools.EndIndentedSection();
            EditorWindowTools.DrawHorizontalLine();
        }
Пример #4
0
        private void DrawShowCursorSection()
        {
            EditorWindowTools.DrawHorizontalLine();
            ShowCursorOnConversation showCursor = pcObject.GetComponent <ShowCursorOnConversation>();
            bool showCursorFlag = (showCursor != null);

            if (!showCursorFlag)
            {
                EditorGUILayout.HelpBox("If regular gameplay hides the mouse cursor, tick Show Mouse Cursor to enable it during conversations.", MessageType.Info);
            }
            EditorGUILayout.BeginHorizontal();
            showCursorFlag = EditorGUILayout.Toggle(showCursorFlag, GUILayout.Width(ToggleWidth));
            EditorGUILayout.LabelField("Show mouse cursor during conversations", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (showCursorFlag)
            {
                if (showCursor == null)
                {
                    showCursor = pcObject.AddComponent <ShowCursorOnConversation>();
                }
            }
            else
            {
                DestroyImmediate(showCursor);
            }
        }
        private void DrawInputsStage()
        {
            if (DialogueManager.Instance.displaySettings.inputSettings == null)
            {
                DialogueManager.Instance.displaySettings.inputSettings = new DisplaySettings.InputSettings();
            }
            EditorGUILayout.LabelField("Input Settings", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("In this section, you'll specify input settings for the dialogue UI.", MessageType.Info);
            EditorWindowTools.StartIndentedSection();

            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.LabelField("Player Response Menu", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            DialogueManager.Instance.displaySettings.inputSettings.alwaysForceResponseMenu = EditorGUILayout.Toggle("Always Force Menu", DialogueManager.Instance.displaySettings.inputSettings.alwaysForceResponseMenu);
            EditorGUILayout.HelpBox("Tick to always force the response menu. If unticked, then when the player only has one valid response, the UI will automatically select it without showing the response menu.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            bool useTimeout = EditorGUILayout.Toggle("Timer", (DialogueManager.Instance.displaySettings.inputSettings.responseTimeout > 0));

            EditorGUILayout.HelpBox("Tick to make the response menu timed. If unticked, players can take as long as they want to make their selection.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            if (useTimeout)
            {
                if (Tools.ApproximatelyZero(DialogueManager.Instance.displaySettings.inputSettings.responseTimeout))
                {
                    DialogueManager.Instance.displaySettings.inputSettings.responseTimeout = DefaultResponseTimeoutDuration;
                }
                DialogueManager.Instance.displaySettings.inputSettings.responseTimeout       = EditorGUILayout.FloatField("Timeout Seconds", DialogueManager.Instance.displaySettings.inputSettings.responseTimeout);
                DialogueManager.Instance.displaySettings.inputSettings.responseTimeoutAction = (ResponseTimeoutAction)EditorGUILayout.EnumPopup("If Time Runs Out", DialogueManager.Instance.displaySettings.inputSettings.responseTimeoutAction);
            }
            else
            {
                DialogueManager.Instance.displaySettings.inputSettings.responseTimeout = 0;
            }

            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.LabelField("Quick Time Event (QTE) Trigger Buttons", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("QTE trigger buttons may be defined on the Dialogue Manager object's inspector under Display Settings > Input Settings > Qte Buttons.", MessageType.None);
            if (GUILayout.Button("Inspect Dialogue Manager object", GUILayout.Width(240)))
            {
                Selection.activeObject = DialogueManager.Instance;
            }

            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.LabelField("Cancel", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            DialogueManager.Instance.displaySettings.inputSettings.cancel.key = (KeyCode)EditorGUILayout.EnumPopup("Key", DialogueManager.Instance.displaySettings.inputSettings.cancel.key);
            EditorGUILayout.HelpBox("Pressing this key cancels the response menu or conversation.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            DialogueManager.Instance.displaySettings.inputSettings.cancel.buttonName = EditorGUILayout.TextField("Button Name", DialogueManager.Instance.displaySettings.inputSettings.cancel.buttonName);
            EditorGUILayout.HelpBox("Pressing this button cancels the response menu or conversation.", MessageType.None);
            EditorGUILayout.EndHorizontal();

            EditorWindowTools.EndIndentedSection();
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Пример #6
0
 public void Draw()
 {
     EditorGUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     Current = (Tab)GUILayout.Toolbar((int)Current, ToolbarStrings, GUILayout.Width(ToolbarWidth));
     GUILayout.FlexibleSpace();
     EditorGUILayout.EndHorizontal();
     EditorWindowTools.DrawHorizontalLine();
 }
 private void DrawProgressIndicator()
 {
     EditorGUI.BeginDisabledGroup(true);
     EditorGUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     GUILayout.Toolbar((int)stage, stageLabels, GUILayout.Width(720));
     GUILayout.FlexibleSpace();
     EditorGUILayout.EndHorizontal();
     EditorGUI.EndDisabledGroup();
     EditorWindowTools.DrawHorizontalLine();
 }
        private void DrawCutscenesStage()
        {
            if (DialogueManager.Instance.displaySettings.cameraSettings == null)
            {
                DialogueManager.Instance.displaySettings.cameraSettings = new DisplaySettings.CameraSettings();
            }
            EditorGUILayout.LabelField("Cutscene Sequences", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("The Dialogue System uses an integrated cutscene sequencer. Every line of dialogue can have a cutscene sequence -- for example to move the camera, play animations on the speaker, or play a lip-synced voiceover.", MessageType.Info);
            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.HelpBox("You can set up a camera object or prefab specifically for sequences. This can be useful to apply depth of field effects or other filters that you wouldn't normally apply to your gameplay camera. If you've set up a sequencer camera, assign it below. Otherwise the sequencer will just use the current main camera.", MessageType.None);
            DialogueManager.Instance.displaySettings.cameraSettings.sequencerCamera = EditorGUILayout.ObjectField("Sequencer Camera", DialogueManager.Instance.displaySettings.cameraSettings.sequencerCamera, typeof(Camera), true) as Camera;
            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.HelpBox("Cutscene sequence commands can reference camera angles defined on a camera angle prefab. If you've set up a camera angle prefab, assign it below. Otherwise the sequencer will use a default camera angle prefab with basic angles such as Closeup, Medium, and Wide.", MessageType.None);
            DialogueManager.Instance.displaySettings.cameraSettings.cameraAngles = EditorGUILayout.ObjectField("Camera Angles", DialogueManager.Instance.displaySettings.cameraSettings.cameraAngles, typeof(GameObject), true) as GameObject;
            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.HelpBox("If a dialogue entry doesn't define its own cutscene sequence, it will use the default sequence below.", MessageType.None);
            EditorGUILayout.BeginHorizontal();
            DefaultSequenceStyle style = string.Equals(DefaultCloseupSequence, DialogueManager.Instance.displaySettings.cameraSettings.defaultSequence)
                                ? DefaultSequenceStyle.Closeups
                                        : (string.Equals(DefaultWaitForSubtitleSequence, DialogueManager.Instance.displaySettings.cameraSettings.defaultSequence)
                                           ? DefaultSequenceStyle.WaitForSubtitle
                                           : DefaultSequenceStyle.Custom);
            DefaultSequenceStyle newStyle = (DefaultSequenceStyle)EditorGUILayout.EnumPopup("Default Sequence", style);

            if (newStyle != style)
            {
                style = newStyle;
                switch (style)
                {
                case DefaultSequenceStyle.Closeups: DialogueManager.Instance.displaySettings.cameraSettings.defaultSequence = DefaultCloseupSequence; break;

                case DefaultSequenceStyle.WaitForSubtitle: DialogueManager.Instance.displaySettings.cameraSettings.defaultSequence = DefaultWaitForSubtitleSequence; break;

                default: break;
                }
            }
            switch (style)
            {
            case DefaultSequenceStyle.Closeups: EditorGUILayout.HelpBox("Does a camera closeup of the speaker. At the end of the subtitle, changes to a closeup of the listener. Don't use this if your player is a body-less first person controller, since a closeup doesn't make sense in this case.", MessageType.None); break;

            case DefaultSequenceStyle.WaitForSubtitle: EditorGUILayout.HelpBox("Just waits for the subtitle to finish. Doesn't touch the camera.", MessageType.None); break;

            default: EditorGUILayout.HelpBox("Custom default sequence defined below.", MessageType.None); break;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.HelpBox("In the default sequence, you can use '{{end}}' to refer to the duration of the subtitle as determined by Chars/Second and Min Seconds.", MessageType.None);
            DialogueManager.Instance.displaySettings.cameraSettings.defaultSequence = EditorGUILayout.TextField("Default Sequence", DialogueManager.Instance.displaySettings.cameraSettings.defaultSequence);
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Пример #9
0
        private bool DrawTargetingOnUse()
        {
            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.LabelField("Collider", EditorStyles.boldLabel);
            Collider nontriggerCollider = null;

            foreach (var collider in npcObject.GetComponentsInChildren <Collider>())
            {
                if (!collider.isTrigger)
                {
                    nontriggerCollider = collider;
                }
            }
            Usable usable = npcObject.GetComponent <Usable>();

            if ((nontriggerCollider != null) && (usable != null))
            {
                EditorGUILayout.HelpBox("The NPC has a collider and a Usable component. The player's Selector component will be able to target it to send OnUse messages.", MessageType.None);
                EditorGUILayout.LabelField("'Usable' Customization", EditorStyles.boldLabel);
                EditorWindowTools.StartIndentedSection();
                usable.maxUseDistance     = EditorGUILayout.FloatField("Max Usable Distance", usable.maxUseDistance);
                usable.overrideName       = EditorGUILayout.TextField("Override Actor Name (leave blank to use main override)", usable.overrideName);
                usable.overrideUseMessage = EditorGUILayout.TextField("Override Use Message", usable.overrideUseMessage);
                EditorWindowTools.EndIndentedSection();
            }
            else
            {
                if (nontriggerCollider == null)
                {
                    EditorGUILayout.HelpBox("The NPC is configured to listen for OnUse messages. If these messages will be coming from the player's Selector component, the NPC needs a collider that the Selector can target. Click Add Collider to add a CharacterController. If OnUse will come from another source, you don't necessarily need a collider.", MessageType.Info);
                    if (GUILayout.Button("Add Collider", GUILayout.Width(160)))
                    {
                        npcObject.AddComponent <CharacterController>();
                    }
                }
                if (usable == null)
                {
                    EditorGUILayout.HelpBox("The NPC is configured to listen for OnUse messages. If these messages will be coming from the player's Selector component, the NPC needs a Usable component to tell the Selector that it's usable. Click Add Usable to add one.", MessageType.Info);
                    if (GUILayout.Button("Add Usable", GUILayout.Width(160)))
                    {
                        npcObject.AddComponent <Usable>();
                    }
                }
            }
            return(true);
        }
Пример #10
0
 private void DrawDialogueTreeSearchBar()
 {
     if (showNodeEditor)
     {
         GUILayout.BeginArea(new Rect(0, 49, position.width, 24));
     }
     else
     {
         EditorWindowTools.DrawHorizontalLine();
     }
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField(string.Empty, GUILayout.Width(8));
     GUI.SetNextControlName("SearchTextField");
     searchString = EditorGUILayout.TextField("Search", searchString, "ToolbarSeachTextField");
     GUI.SetNextControlName("SearchClearButton");
     if (GUILayout.Button("Clear", "ToolbarSeachCancelButton"))
     {
         searchString = string.Empty;
         GUI.FocusControl("SearchClearButton"); // Need to deselect search field to clear text field's display.
     }
     searchCaseSensitive = EditorGUILayout.ToggleLeft(new GUIContent("Aa", "Case-sensitive"), searchCaseSensitive, GUILayout.Width(30));
     EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(searchString));
     if (GUILayout.Button("↓", EditorStyles.miniButtonLeft, GUILayout.Width(22)))
     {
         SearchDialogueTree(1);
     }
     if (GUILayout.Button("↑", EditorStyles.miniButtonMid, GUILayout.Width(22)))
     {
         SearchDialogueTree(-1);
     }
     EditorGUI.EndDisabledGroup();
     if (GUILayout.Button("X", EditorStyles.miniButtonRight, GUILayout.Width(22)))
     {
         isSearchBarOpen = false;
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.LabelField(string.Empty, GUILayout.Height(1));
     if (showNodeEditor)
     {
         GUILayout.EndArea();
     }
 }
Пример #11
0
        private bool DrawTargetingOnTriggerEnter()
        {
            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.LabelField("Trigger Collider", EditorStyles.boldLabel);
            Collider triggerCollider = null;

            foreach (var collider in npcObject.GetComponentsInChildren <Collider>())
            {
                if (collider.isTrigger)
                {
                    triggerCollider = collider;
                }
            }
            if (triggerCollider != null)
            {
                if (triggerCollider is SphereCollider)
                {
                    EditorGUILayout.HelpBox("The NPC has a trigger collider, so it's ready for OnTriggerEnter events. You can adjust its radius below. Make sure its layer collision properties are configured to detect when the intended colliders enter its area.", MessageType.None);
                    SphereCollider sphereCollider = triggerCollider as SphereCollider;
                    sphereCollider.radius = EditorGUILayout.FloatField("Radius", sphereCollider.radius);
                    return(true);
                }
                else
                {
                    EditorGUILayout.HelpBox("The NPC has a trigger collider, so it's ready for OnTriggerEnter events.", MessageType.None);
                }
                return(true);
            }
            else
            {
                EditorGUILayout.HelpBox("The NPC needs a trigger collider. Add Trigger to add a sphere trigger, or add one manually.", MessageType.Info);
                if (GUILayout.Button("Add Trigger", GUILayout.Width(160)))
                {
                    SphereCollider sphereCollider = npcObject.AddComponent <SphereCollider>();
                    sphereCollider.isTrigger = true;
                    sphereCollider.radius    = 1.5f;
                    return(true);
                }
            }
            return(false);
        }
Пример #12
0
 private void DrawLuaWatchBar()
 {
     EditorWindowTools.DrawHorizontalLine();
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Run Code:", GUILayout.Width(64));
     GUI.SetNextControlName("LuaEmptyLabel");
     EditorGUILayout.LabelField(string.Empty, GUILayout.Width(8));
     luaCommand = EditorGUILayout.TextField(string.Empty, luaCommand);
     if (GUILayout.Button("Clear", "ToolbarSeachCancelButton"))
     {
         luaCommand = string.Empty;
         GUI.FocusControl("LuaEmptyLabel"); // Need to deselect field to clear text field's display.
     }
     if (GUILayout.Button("Run", EditorStyles.miniButton, GUILayout.Width(32)))
     {
         Debug.Log("Running: " + luaCommand);
         Lua.Run(luaCommand, true);
         luaCommand = string.Empty;
         GUI.FocusControl("LuaEmptyLabel"); // Need to deselect field to clear text field's display.
     }
     EditorGUILayout.EndHorizontal();
     EditorGUILayout.LabelField(string.Empty, GUILayout.Height(1));
 }
Пример #13
0
        private void DrawBarkStage()
        {
            EditorGUILayout.LabelField("Bark", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("If the NPC barks (says one-off lines during gameplay), tick either or both of the checkboxs below.", MessageType.Info);
            bool hasBarkTrigger = DrawBarkTriggerSection();

            EditorWindowTools.DrawHorizontalLine();
            bool hasBarkOnIdle    = DrawBarkOnIdleSection();
            bool hasBarkComponent = hasBarkTrigger || hasBarkOnIdle;
            bool hasBarkUI        = false;

            if (hasBarkComponent)
            {
                hasBarkUI = DrawBarkUISection();
            }
            if (hasBarkComponent && GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, (hasBarkUI || !hasBarkComponent), false);
        }
Пример #14
0
        private void DrawTargetingStage()
        {
            EditorGUILayout.LabelField("Targeting", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SelectorType selectorType = GetSelectorType();

            if (selectorType == SelectorType.None)
            {
                EditorGUILayout.HelpBox("Specify how the player will target NPCs to trigger conversations and barks.", MessageType.Info);
            }
            selectorType = (SelectorType)EditorGUILayout.EnumPopup("Target NPCs By", selectorType);
            switch (selectorType)
            {
            case SelectorType.Proximity:
                DrawProximitySelector();
                break;

            case SelectorType.CenterOfScreen:
            case SelectorType.MousePosition:
            case SelectorType.CustomPosition:
                DrawSelector(selectorType);
                break;

            default:
                DrawNoSelector();
                break;
            }
            EditorWindowTools.EndIndentedSection();
            EditorWindowTools.DrawHorizontalLine();
            DrawOverrideNameSubsection();
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            DrawNavigationButtons(true, true, false);
        }