private void DrawAlertsStage()
        {
            if (DialogueManager.instance.displaySettings.alertSettings == null)
            {
                DialogueManager.instance.displaySettings.alertSettings = new DisplaySettings.AlertSettings();
            }
            EditorGUILayout.LabelField("Alert Settings", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("Alerts are gameplay messages. They can be delivered from conversations or other sources.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            DialogueManager.instance.displaySettings.alertSettings.allowAlertsDuringConversations = EditorGUILayout.Toggle("Allow In Conversations", DialogueManager.instance.displaySettings.alertSettings.allowAlertsDuringConversations);
            EditorGUILayout.HelpBox("Tick to allow alerts to be displayed while in conversations. If unticked, alerts won't be displayed until the conversation has ended.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            bool monitorAlerts = EditorGUILayout.Toggle("Monitor Alerts", (DialogueManager.instance.displaySettings.alertSettings.alertCheckFrequency > 0));

            EditorGUILayout.HelpBox("Tick to constantly monitor the Lua value \"Variable['Alert']\" and display its contents as an alert. This runs as a background process. The value is automatically checked at the end of conversations, and you can check it manually. Unless you have a need to constantly monitor the value, it's more efficient to leave this unticked.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            if (monitorAlerts)
            {
                if (Tools.ApproximatelyZero(DialogueManager.instance.displaySettings.alertSettings.alertCheckFrequency))
                {
                    DialogueManager.instance.displaySettings.alertSettings.alertCheckFrequency = DefaultAlertCheckFrequency;
                }
                DialogueManager.instance.displaySettings.alertSettings.alertCheckFrequency = EditorGUILayout.FloatField("Frequency (Seconds)", DialogueManager.instance.displaySettings.alertSettings.alertCheckFrequency);
            }
            else
            {
                DialogueManager.instance.displaySettings.alertSettings.alertCheckFrequency = 0;
            }
            EditorGUILayout.BeginHorizontal();
            DialogueManager.instance.displaySettings.alertSettings.alertCharsPerSecond = EditorGUILayout.FloatField("Chars/Second", DialogueManager.instance.displaySettings.alertSettings.alertCharsPerSecond);
            EditorGUILayout.HelpBox("Determines how long the alert is displayed. If zero, use Subtitle Settings > Chars/Second.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            DialogueManager.instance.displaySettings.alertSettings.minAlertSeconds = EditorGUILayout.FloatField("Min Seconds", DialogueManager.instance.displaySettings.alertSettings.minAlertSeconds);
            EditorGUILayout.HelpBox("The guaranteed minimum amount of time that an alert will be displayed. If zero, use Subtitle Settings > Min Subtitle Seconds.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #2
0
        private void DrawCameraStage()
        {
            EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            UnityEngine.Camera playerCamera = pcObject.GetComponentInChildren <UnityEngine.Camera>() ?? UnityEngine.Camera.main;
            var smoothCamera = (playerCamera != null) ? playerCamera.GetComponent <PixelCrushers.DialogueSystem.Demo.SmoothCameraWithBumper>() : null;

            EditorGUILayout.BeginHorizontal();
            bool useSmoothCamera = EditorGUILayout.Toggle((smoothCamera != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("Use Smooth Follow Camera", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (useSmoothCamera)
            {
                if (playerCamera == null)
                {
                    GameObject playerCameraObject = new GameObject("Player Camera");
                    playerCameraObject.transform.parent = pcObject.transform;
                    playerCamera     = playerCameraObject.AddComponent <UnityEngine.Camera>();
                    playerCamera.tag = "MainCamera";
                }
                smoothCamera = playerCamera.GetComponentInChildren <PixelCrushers.DialogueSystem.Demo.SmoothCameraWithBumper>() ?? playerCamera.gameObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.Demo.SmoothCameraWithBumper))) as Demo.SmoothCameraWithBumper;
                EditorWindowTools.StartIndentedSection();
                if (smoothCamera.target == null)
                {
                    EditorGUILayout.HelpBox("Specify the transform (usually the head) that the camera should follow.", MessageType.Info);
                }
                smoothCamera.target = EditorGUILayout.ObjectField("Target", smoothCamera.target, typeof(Transform), true) as Transform;
                EditorWindowTools.EndIndentedSection();
            }
            else
            {
                DestroyImmediate(smoothCamera);
            }
            if (GUILayout.Button("Select Camera", GUILayout.Width(100)))
            {
                Selection.activeObject = playerCamera;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #3
0
        private void DrawReviewStage()
        {
            EditorGUILayout.LabelField("Review", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("Your NPC is ready! Below is a summary of your NPC's configuration.\n\nNPC configuration can sometimes be complex. This wizard can't anticipate every possible character design. If your NPC doesn't behave the way you expect, please examine the components on the NPC and make adjustments as necessary.", MessageType.Info);
            ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>();

            if (conversationTrigger != null)
            {
                EditorGUILayout.LabelField(string.Format("Conversation: '{0}'{1} {2}", conversationTrigger.conversation, conversationTrigger.once ? " (once)" : string.Empty, conversationTrigger.trigger));
            }
            else
            {
                EditorGUILayout.LabelField("Conversation: None");
            }
            BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>();

            if (barkTrigger != null)
            {
                EditorGUILayout.LabelField(string.Format("Triggered Bark: '{0}' ({1}) {2}", barkTrigger.conversation, barkTrigger.barkOrder, barkTrigger.trigger));
            }
            else
            {
                EditorGUILayout.LabelField("Triggered Bark: None");
            }
            BarkOnIdle barkOnIdle = npcObject.GetComponentInChildren <BarkOnIdle>();

            if (barkOnIdle != null)
            {
                EditorGUILayout.LabelField(string.Format("Timed Bark: '{0}' ({1}) every {2}-{3} seconds", barkOnIdle.conversation, barkOnIdle.barkOrder, barkOnIdle.minSeconds, barkOnIdle.maxSeconds));
            }
            else
            {
                EditorGUILayout.LabelField("Timed Bark: No");
            }
            PersistentPositionData persistentPositionData = npcObject.GetComponentInChildren <PersistentPositionData>();

            EditorGUILayout.LabelField(string.Format("Save Position: {0}", (persistentPositionData != null) ? "Yes" : "No"));
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, true);
        }
Beispiel #4
0
        //private Editor positionSaverEditor = null;

        private void DrawPersistenceStage()
        {
            EditorGUILayout.LabelField("Persistence", EditorStyles.boldLabel);
            var positionSaver = npcObject.GetComponent <PositionSaver>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("The NPC can be configured to record its position in the Dialogue System's Lua environment so it will be preserved when saving and loading games.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasPositionSaver = EditorGUILayout.Toggle((positionSaver != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("NPC records position for saved games", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasPositionSaver)
            {
                if (positionSaver == null)
                {
                    positionSaver = npcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.PositionSaver))) as PositionSaver;
                }
            }
            else
            {
                DestroyImmediate(positionSaver);
                positionSaver = null;
                //positionSaverEditor = null;
                hasPositionSaver = false;
            }
            if (hasPositionSaver)
            {
                //if (positionSaverEditor == null) positionSaverEditor = Editor.CreateEditor(positionSaver);
                //positionSaverEditor.OnInspectorGUI();
                positionSaver.key = EditorGUILayout.TextField(new GUIContent("Save Under Key", "Each NPC's position saver needs a unique key."), positionSaver.key);
                positionSaver.appendSaverTypeToKey   = EditorGUILayout.Toggle(new GUIContent("Append _PositionSaver", "Append '_PositionSaver' to the key to distinguish it from other Saver components on the NPC."), positionSaver.appendSaverTypeToKey);
                positionSaver.saveAcrossSceneChanges = EditorGUILayout.Toggle(new GUIContent("Save In Scene Changes", "Tick to remember position when changing scenes. Untick only to remember when saving and loading games in NPC's scene (which saves memory)."), positionSaver.saveAcrossSceneChanges);
            }
            if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #5
0
        private void DrawReviewStage()
        {
            EditorGUILayout.LabelField("Review", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("Your NPC is ready! Below is a summary of your NPC's configuration.", MessageType.Info);
            ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>();

            if (conversationTrigger != null)
            {
                EditorGUILayout.LabelField(string.Format("Conversation: '{0}'{1} {2}", conversationTrigger.conversation, conversationTrigger.once ? " (once)" : string.Empty, conversationTrigger.trigger));
            }
            else
            {
                EditorGUILayout.LabelField("Conversation: None");
            }
            BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>();

            if (barkTrigger != null)
            {
                EditorGUILayout.LabelField(string.Format("Triggered Bark: '{0}' ({1}) {2}", barkTrigger.conversation, barkTrigger.barkOrder, barkTrigger.trigger));
            }
            else
            {
                EditorGUILayout.LabelField("Triggered Bark: None");
            }
            BarkOnIdle barkOnIdle = npcObject.GetComponentInChildren <BarkOnIdle>();

            if (barkOnIdle != null)
            {
                EditorGUILayout.LabelField(string.Format("Timed Bark: '{0}' ({1}) every {2}-{3} seconds", barkOnIdle.conversation, barkOnIdle.barkOrder, barkOnIdle.minSeconds, barkOnIdle.maxSeconds));
            }
            else
            {
                EditorGUILayout.LabelField("Timed Bark: No");
            }
            PersistentPositionData persistentPositionData = npcObject.GetComponentInChildren <PersistentPositionData>();

            EditorGUILayout.LabelField(string.Format("Save Position: {0}", (persistentPositionData != null) ? "Yes" : "No"));
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, true);
        }
Beispiel #6
0
        private void DrawDatabaseList()
        {
            EditorWindowTools.StartIndentedSection();
            DialogueDatabase databaseToDelete = null;

            for (int i = 0; i < prefs.databases.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                prefs.databases[i] = EditorGUILayout.ObjectField(prefs.databases[i], typeof(DialogueDatabase), false) as DialogueDatabase;
                if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(22)))
                {
                    databaseToDelete = prefs.databases[i];
                }
                EditorGUILayout.EndHorizontal();
            }
            if (databaseToDelete != null)
            {
                prefs.databases.Remove(databaseToDelete);
            }
            EditorWindowTools.EndIndentedSection();
        }
Beispiel #7
0
        private void DrawPersistenceStage()
        {
            EditorGUILayout.LabelField("Persistence", EditorStyles.boldLabel);
            PersistentPositionData persistentPositionData = npcObject.GetComponent <PersistentPositionData>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("The NPC can be configured to record its position in the Dialogue System's Lua environment so it will be preserved when saving and loading games.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasPersistentPosition = EditorGUILayout.Toggle((persistentPositionData != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("NPC records position for saved games", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasPersistentPosition)
            {
                if (persistentPositionData == null)
                {
                    persistentPositionData = npcObject.AddComponent <PersistentPositionData>();
                }
                if (string.IsNullOrEmpty(persistentPositionData.overrideActorName))
                {
                    EditorGUILayout.HelpBox(string.Format("Position data will be saved to the Actor['{0}'] (the name of the NPC GameObject) or the Override Actor Name if defined. You can override the name below.", npcObject.name), MessageType.None);
                }
                else
                {
                    EditorGUILayout.HelpBox(string.Format("Position data will be saved to the Actor['{0}']. To use the name of the NPC GameObject instead, clear the field below.", persistentPositionData.overrideActorName), MessageType.None);
                }
                persistentPositionData.overrideActorName = EditorGUILayout.TextField("Actor Name", persistentPositionData.overrideActorName);
            }
            else
            {
                DestroyImmediate(persistentPositionData);
            }
            if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #8
0
        private void DrawDisableControlsSection()
        {
            EditorWindowTools.StartIndentedSection();
            SetEnabledOnDialogueEvent enabler = FindConversationEnabler();

            if (setEnabledFlag)
            {
                if (enabler == null)
                {
                    enabler = pcObject.AddComponent <SetEnabledOnDialogueEvent>();
                }
                enabler.trigger = DialogueEvent.OnConversation;
                enabler.onStart = GetPlayerControls(enabler.onStart, Toggle.False);
                enabler.onEnd   = GetPlayerControls(enabler.onEnd, Toggle.True);
                ShowDisabledComponents(enabler.onStart);
            }
            else
            {
                DestroyImmediate(enabler);
            }
            EditorWindowTools.EndIndentedSection();
        }
Beispiel #9
0
        private void DrawDisableControlsSection()
        {
            EditorWindowTools.StartIndentedSection();
            SetComponentEnabledOnDialogueEvent enabler = FindConversationEnabler();

            if (setEnabledFlag)
            {
                if (enabler == null)
                {
                    enabler = pcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.SetComponentEnabledOnDialogueEvent))) as SetComponentEnabledOnDialogueEvent;
                }
                enabler.trigger = DialogueEvent.OnConversation;
                enabler.onStart = GetPlayerControls(enabler.onStart, Toggle.False);
                enabler.onEnd   = GetPlayerControls(enabler.onEnd, Toggle.True);
                ShowDisabledComponents(enabler.onStart);
            }
            else
            {
                DestroyImmediate(enabler);
            }
            EditorWindowTools.EndIndentedSection();
        }
Beispiel #10
0
 private void DrawUIStage()
 {
     EditorGUILayout.LabelField("User Interface", EditorStyles.boldLabel);
     EditorWindowTools.StartIndentedSection();
     EditorGUILayout.HelpBox("Assign a dialogue UI. You can find pre-built UIs in Prefabs/Unity UI Prefabs and Prefabs/Legacy Unity GUI Prefabs. To assign a prefab for a different GUI system, import its support package found in Third Party Support. You can also assign a UI scene object.", MessageType.Info);
     if (DialogueManager.Instance.displaySettings == null)
     {
         DialogueManager.Instance.displaySettings = new DisplaySettings();
     }
     DialogueManager.Instance.displaySettings.dialogueUI = EditorGUILayout.ObjectField("Dialogue UI", DialogueManager.Instance.displaySettings.dialogueUI, typeof(GameObject), true) as GameObject;
     if (DialogueManager.Instance.displaySettings.dialogueUI == null)
     {
         EditorGUILayout.HelpBox("If you continue without assigning a UI, the Dialogue System will use a very plain default UI.", MessageType.Warning);
     }
     else
     {
         var legacy = DialogueManager.Instance.displaySettings.dialogueUI.GetComponentsInChildren <PixelCrushers.DialogueSystem.UnityGUI.UnityDialogueUI>(true);
         if (legacy.Length > 0)
         {
             EditorGUILayout.HelpBox("This is a Legacy Unity GUI dialogue UI.", MessageType.None);
         }
         else
         {
             var newUIs = DialogueManager.Instance.displaySettings.dialogueUI.GetComponentsInChildren <UnityUIDialogueUI>(true);
             if (newUIs.Length > 0)
             {
                 EditorGUILayout.HelpBox("This is a Unity UI dialogue UI.", MessageType.None);
                 HandleUnityUIDialogueUI(newUIs[0], DialogueManager.Instance);
             }
             else
             {
                 EditorGUILayout.HelpBox("Make sure this GameObject has an active dialogue UI component.", MessageType.None);
             }
         }
     }
     EditorWindowTools.EndIndentedSection();
     DrawNavigationButtons(true, true, false);
 }
Beispiel #11
0
        private void DrawSelector(SelectorType selectorType)
        {
            DestroyImmediate(pcObject.GetComponent <ProximitySelector>());
            Selector selector = pcObject.GetComponent <Selector>() ?? pcObject.AddComponent <Selector>();

            EditorWindowTools.StartIndentedSection();
            switch (selectorType)
            {
            case SelectorType.CenterOfScreen:
                EditorGUILayout.HelpBox("Usable objects in the center of the screen will be targeted.", MessageType.None);
                selector.selectAt = Selector.SelectAt.CenterOfScreen;
                break;

            case SelectorType.MousePosition:
                EditorGUILayout.HelpBox("Usable objects under the mouse cursor will be targeted. Specify which mouse button activates the targeted object.", MessageType.None);
                selector.selectAt = Selector.SelectAt.MousePosition;
                MouseButtonChoice mouseButtonChoice = string.Equals(selector.useButton, "Fire2") ? MouseButtonChoice.RightMouseButton : MouseButtonChoice.LeftMouseButton;
                mouseButtonChoice  = (MouseButtonChoice)EditorGUILayout.EnumPopup("Select With", mouseButtonChoice);
                selector.useButton = (mouseButtonChoice == MouseButtonChoice.RightMouseButton) ? "Fire2" : "Fire1";
                break;

            default:
            case SelectorType.CustomPosition:
                EditorGUILayout.HelpBox("Usable objects will be targeted at a custom screen position. You are responsible for setting the Selector component's CustomPosition property.", MessageType.None);
                selector.selectAt = Selector.SelectAt.CustomPosition;
                break;
            }
            if (selector.reticle != null)
            {
                selector.reticle.inRange    = EditorGUILayout.ObjectField("In-Range Reticle", selector.reticle.inRange, typeof(Texture2D), false) as Texture2D;
                selector.reticle.outOfRange = EditorGUILayout.ObjectField("Out-of-Range Reticle", selector.reticle.outOfRange, typeof(Texture2D), false) as Texture2D;
            }
            DrawSelectorUIPosition();
            selector.useKey    = (KeyCode)EditorGUILayout.EnumPopup("'Use' Key", selector.useKey);
            selector.useButton = EditorGUILayout.TextField("'Use' Button", selector.useButton);
            EditorGUILayout.HelpBox("Click Select Player to customize the Selector.", MessageType.None);
            EditorWindowTools.EndIndentedSection();
        }
Beispiel #12
0
        private void DrawControlStage()
        {
            EditorGUILayout.LabelField("Control", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            PixelCrushers.DialogueSystem.SimpleController simpleController = pcObject.GetComponent <PixelCrushers.DialogueSystem.SimpleController>();
            NavigateOnMouseClick navigateOnMouseClick = pcObject.GetComponent <NavigateOnMouseClick>();
            ControlStyle         controlStyle         = (simpleController != null)
                                ? ControlStyle.ThirdPersonShooter
                                : (navigateOnMouseClick != null)
                                        ? ControlStyle.FollowMouseClicks
                                        : ControlStyle.Custom;

            EditorGUILayout.HelpBox("How will the player control movement? (Select Custom to provide your own control components instead of using the Dialogue System's.)", MessageType.Info);
            controlStyle = (ControlStyle)EditorGUILayout.EnumPopup("Control", controlStyle);
            switch (controlStyle)
            {
            case ControlStyle.ThirdPersonShooter:
                DestroyImmediate(navigateOnMouseClick);
                DrawSimpleControllerSection(simpleController ?? pcObject.AddComponent <PixelCrushers.DialogueSystem.SimpleController>());
                break;

            case ControlStyle.FollowMouseClicks:
                DestroyImmediate(simpleController);
                DrawNavigateOnMouseClickSection(navigateOnMouseClick ?? pcObject.AddComponent <NavigateOnMouseClick>());
                break;

            default:
                DestroyImmediate(simpleController);
                DestroyImmediate(navigateOnMouseClick);
                break;
            }
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #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);
        }
        private void DrawLanguages()
        {
            // Draw Languages foldout and menu:
            EditorGUILayout.BeginHorizontal();
            languagesFoldout = EditorGUILayout.Foldout(languagesFoldout, "Languages");
            DrawMenu();
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(22)))
            {
                languagesFoldout = true;
                table.languages.Add(string.Empty);
            }
            EditorGUILayout.EndHorizontal();

            // Draw languages:
            if (languagesFoldout)
            {
                int languageIndexToDelete = -1;
                EditorWindowTools.StartIndentedSection();
                for (int i = 0; i < table.languages.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    table.languages[i] = EditorGUILayout.TextField(table.languages[i]);
                    EditorGUI.BeginDisabledGroup(i == 0);
                    if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(22)))
                    {
                        languageIndexToDelete = i;
                    }
                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.EndHorizontal();
                }
                EditorWindowTools.EndIndentedSection();
                if (languageIndexToDelete != -1)
                {
                    DeleteLanguage(languageIndexToDelete);
                }
            }
        }
Beispiel #15
0
        private void DrawConversationStage()
        {
            EditorGUILayout.LabelField("Conversation", EditorStyles.boldLabel);
            ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>();

            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("If the NPC has an interactive conversation (for example, with the player), tick the checkbox below.", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            bool hasConversation = EditorGUILayout.Toggle((conversationTrigger != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("NPC has an interactive conversation", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasConversation)
            {
                EditorWindowTools.StartIndentedSection();
                if (conversationTrigger == null)
                {
                    conversationTrigger = npcObject.AddComponent <ConversationTrigger>();
                }
                EditorGUILayout.HelpBox("Select the NPC's conversation and what event will trigger it. If the NPC will only engage in this conversation once, tick Once Only. Click Select NPC to further customize the Conversation Trigger in the inspector, such as setting conditions on when the conversation can occur.",
                                        string.IsNullOrEmpty(conversationTrigger.conversation) ? MessageType.Info : MessageType.None);
                conversationTrigger.conversation = DrawConversationPopup(conversationTrigger.conversation);
                conversationTrigger.once         = EditorGUILayout.Toggle("Once Only", conversationTrigger.once);
                conversationTrigger.trigger      = DrawTriggerPopup(conversationTrigger.trigger);
                if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
                {
                    Selection.activeGameObject = npcObject;
                }
                EditorWindowTools.EndIndentedSection();
            }
            else
            {
                DestroyImmediate(conversationTrigger);
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #16
0
        private void DrawPersistenceStage()
        {
            EditorGUILayout.LabelField("Persistence", EditorStyles.boldLabel);
            var positionSaver = pcObject.GetComponent <PositionSaver>();

            EditorWindowTools.StartIndentedSection();
            if (positionSaver == null)
            {
                EditorGUILayout.HelpBox("The player can be configured to record its position in the Dialogue System's Lua environment so it will be preserved when saving and loading games.", MessageType.Info);
            }
            EditorGUILayout.BeginHorizontal();
            bool hasPersistentPosition = EditorGUILayout.Toggle((positionSaver != null), GUILayout.Width(ToggleWidth));

            EditorGUILayout.LabelField("Player records position for saved games", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            if (hasPersistentPosition)
            {
                if (positionSaver == null)
                {
                    positionSaver     = pcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.PositionSaver))) as PositionSaver;
                    positionSaver.key = "Player";
                }
                if (positionSaverEditor == null)
                {
                    positionSaverEditor = Editor.CreateEditor(positionSaver);
                }
                positionSaverEditor.OnInspectorGUI();
            }
            else
            {
                DestroyImmediate(positionSaver);
                positionSaver       = null;
                positionSaverEditor = null;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #17
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);
        }
Beispiel #18
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var manager = target as BarkGroupManager;

            foreach (var kvp in manager.groups)
            {
                EditorGUILayout.LabelField(kvp.Key, EditorStyles.boldLabel);
                EditorWindowTools.StartIndentedSection();
                foreach (var member in kvp.Value)
                {
                    if (member == null)
                    {
                        continue;
                    }
                    if (GUILayout.Button(member.name))
                    {
                        Selection.activeGameObject = member.gameObject;
                    }
                }
                EditorWindowTools.EndIndentedSection();
            }
        }
Beispiel #19
0
        private void DrawTransitionStage()
        {
            EditorGUILayout.LabelField("Gameplay/Conversation Transition", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SetComponentEnabledOnDialogueEvent setEnabled = pcObject.GetComponent <SetComponentEnabledOnDialogueEvent>();

            setEnabledFlag = setEnabledFlag || (setEnabled != null);
            if (!setEnabledFlag)
            {
                EditorGUILayout.HelpBox("Gameplay components, such as movement and camera control, will interfere with conversations. If you want to disable gameplay components during conversations, tick the checkbox below. There are many ways to disable gameplay components. You can add a Dialogue System Events component and configure it in the inspector, or add Dialogue System Triggers set to OnConversationStart and OnConversationEnd. Or you can add a Set Component Enabled On Dialogue Event component, which is what the checkbox below does.", MessageType.None);
            }
            EditorGUILayout.BeginHorizontal();
            setEnabledFlag = EditorGUILayout.Toggle(setEnabledFlag, GUILayout.Width(ToggleWidth));
            EditorGUILayout.LabelField("Add Set Component Enabled On Dialogue Event component", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            DrawDisableControlsSection();
            DrawShowCursorSection();
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #20
0
        private void DrawTransitionStage()
        {
            EditorGUILayout.LabelField("Gameplay/Conversation Transition", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SetEnabledOnDialogueEvent setEnabled = pcObject.GetComponent <SetEnabledOnDialogueEvent>();

            setEnabledFlag = setEnabledFlag || (setEnabled != null);
            if (!setEnabledFlag)
            {
                EditorGUILayout.HelpBox("Gameplay components, such as movement and camera control, will interfere with conversations. If you want to disable gameplay components during conversations, tick the checkbox below.", MessageType.None);
            }
            EditorGUILayout.BeginHorizontal();
            setEnabledFlag = EditorGUILayout.Toggle(setEnabledFlag, GUILayout.Width(ToggleWidth));
            EditorGUILayout.LabelField("Disable gameplay components during conversations", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            DrawDisableControlsSection();
            DrawShowCursorSection();
            if (GUILayout.Button("Select Player", GUILayout.Width(100)))
            {
                Selection.activeGameObject = pcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
        public override void OnInspectorGUI()
        {
            var trigger = target as SequenceTrigger;

            if (trigger == null)
            {
                return;
            }

            trigger.trigger = (DialogueTriggerEvent)EditorGUILayout.EnumPopup(new GUIContent("Trigger", "The event that triggers the sequence"), trigger.trigger);
            if (trigger.trigger == DialogueTriggerEvent.OnEnable || trigger.trigger == DialogueTriggerEvent.OnStart)
            {
                trigger.waitOneFrameOnStartOrEnable = EditorGUILayout.Toggle(new GUIContent("Wait 1 Frame", "Tick to wait one frame to allow other components to finish their OnStart/OnEnable"), trigger.waitOneFrameOnStartOrEnable);
            }
            EditorGUILayout.LabelField(new GUIContent("Sequence", "The sequence to play"));
            EditorWindowTools.StartIndentedSection();
            trigger.sequence = EditorGUILayout.TextArea(trigger.sequence);
            EditorWindowTools.EndIndentedSection();
            trigger.speaker  = EditorGUILayout.ObjectField(new GUIContent("Speaker", "The GameObject referenced by 'speaker'. If unassigned, this GameObject"), trigger.speaker, typeof(Transform), true) as Transform;
            trigger.listener = EditorGUILayout.ObjectField(new GUIContent("Listener", "The GameObject referenced by 'listener'. If unassigned, the GameObject that triggered this sequence"), trigger.listener, typeof(Transform), true) as Transform;
            trigger.once     = EditorGUILayout.Toggle(new GUIContent("Only Once", "Only trigger once, then destroy this component"), trigger.once);
            EditorTools.DrawReferenceDatabase();
            EditorTools.DrawSerializedProperty(serializedObject, "condition");
        }
        private void DrawActionsStage()
        {
            EditorGUILayout.LabelField("Actions", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.LabelField("Dialogue System Trigger", EditorStyles.boldLabel);
            var dialogueSystemTrigger = npcObject.GetComponent <DialogueSystemTrigger>();

            EditorGUILayout.HelpBox("A Dialogue System Trigger runs actions when an event occurs, such as when the player uses the NPC.", MessageType.None);
            var hasDialogueSystemTrigger = (dialogueSystemTrigger != null);

            hasDialogueSystemTrigger = EditorGUILayout.Toggle("Dialogue System Trigger", hasDialogueSystemTrigger);
            if (hasDialogueSystemTrigger && dialogueSystemTrigger == null)
            {
                dialogueSystemTrigger = npcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.DialogueSystemTrigger))) as DialogueSystemTrigger;
            }
            else if (!hasDialogueSystemTrigger && dialogueSystemTrigger != null)
            {
                DestroyImmediate(dialogueSystemTrigger);
                dialogueSystemTrigger       = null;
                hasDialogueSystemTrigger    = false;
                dialogueSystemTriggerEditor = null;
            }
            if (hasDialogueSystemTrigger)
            {
                if (dialogueSystemTriggerEditor == null)
                {
                    dialogueSystemTriggerEditor = Editor.CreateEditor(dialogueSystemTrigger);
                }
                dialogueSystemTriggerEditor.OnInspectorGUI();
            }

            EditorWindowTools.DrawHorizontalLine();
            EditorGUILayout.LabelField("Dialogue System Events", EditorStyles.boldLabel);
            var dialogueSystemEvents = npcObject.GetComponent <DialogueSystemEvents>();

            if (dialogueSystemEvents != null)
            {
                EditorGUILayout.HelpBox("A Dialogue System Events component is a handy way to configure activity such as disabling components and setting animator states when Dialogue System events occur. To configure Dialogue System Events in the Inspector view, click Select NPC.", MessageType.None);
            }
            else
            {
                EditorGUILayout.HelpBox("A Dialogue System Events component is a handy way to configure activity such as disabling components and setting animator states when Dialogue System events occur.", MessageType.None);
            }
            var hasDialogueSystemEvents = (dialogueSystemEvents != null);

            hasDialogueSystemEvents = EditorGUILayout.Toggle("Dialogue System Events", dialogueSystemEvents);
            if (hasDialogueSystemEvents && dialogueSystemEvents == null)
            {
                dialogueSystemEvents = npcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.DialogueSystemEvents))) as DialogueSystemEvents;
            }
            else if (!hasDialogueSystemEvents && dialogueSystemEvents != null)
            {
                DestroyImmediate(dialogueSystemEvents);
                dialogueSystemEvents    = null;
                hasDialogueSystemEvents = false;
            }

            EditorWindowTools.DrawHorizontalLine();
            DrawBarkOnIdleSection();

            if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #23
0
        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 Line", 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 interrupts the currently-playing subtitle.", 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 interrupts the currently-playing subtitle.", MessageType.None);
            EditorGUILayout.EndHorizontal();

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

            EditorWindowTools.EndIndentedSection();
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
Beispiel #24
0
        private void DrawFields()
        {
            // Draw Fields foldout and "+" button:
            EditorGUILayout.BeginHorizontal();
            fieldsFoldout = EditorGUILayout.Foldout(fieldsFoldout, "Fields");
            if (GUILayout.Button("Sort", EditorStyles.miniButton, GUILayout.Width(44)))
            {
                SortFields();
                return;
            }
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(22)))
            {
                fieldsFoldout = true;
                var index = table.fields.Count;
                if (!fieldFoldouts.ContainsKey(index))
                {
                    fieldFoldouts.Add(index, false);
                }
                if (addFieldsAtTop)
                {
                    table.fields.Insert(0, new LocalizedTextTable.LocalizedTextField());
                    for (int i = index; i > 0; i--)
                    {
                        if (!fieldFoldouts.ContainsKey(i))
                        {
                            fieldFoldouts.Add(i, false);
                        }
                        if (!fieldFoldouts.ContainsKey(i - 1))
                        {
                            fieldFoldouts.Add(i - 1, false);
                        }
                        fieldFoldouts[i] = fieldFoldouts[i - 1];
                    }
                    fieldFoldouts[0] = true;
                }
                else
                {
                    table.fields.Add(new LocalizedTextTable.LocalizedTextField());
                    fieldFoldouts[index] = true;
                }
            }
            EditorGUILayout.EndHorizontal();

            // Draw fields:
            if (fieldsFoldout)
            {
                int fieldIndexToDelete = -1;
                EditorWindowTools.StartIndentedSection();
                for (int i = 0; i < table.fields.Count; i++)
                {
                    LocalizedTextTable.LocalizedTextField field = table.fields[i];
                    if (!fieldFoldouts.ContainsKey(i))
                    {
                        fieldFoldouts.Add(i, false);
                    }
                    EditorGUILayout.BeginHorizontal();
                    fieldFoldouts[i] = EditorGUILayout.Foldout(fieldFoldouts[i], string.IsNullOrEmpty(field.name) ? string.Format("Field {0}", i) : field.name);
                    if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(22)))
                    {
                        fieldIndexToDelete = i;
                    }
                    EditorGUILayout.EndHorizontal();
                    if (fieldFoldouts[i])
                    {
                        EditorGUILayout.BeginHorizontal();

                        if (currentSearchResultIndex == i && currentSearchResultValueIndex == -1)
                        {
                            GUI.SetNextControlName("Match");
                        }

                        EditorGUILayout.LabelField("Field", GUILayout.Width(60));
                        field.name = EditorGUILayout.TextField(field.name);
                        EditorGUILayout.LabelField(string.Empty, GUILayout.Width(22));
                        EditorGUILayout.EndHorizontal();
                        EditorWindowTools.StartIndentedSection();
                        for (int j = 0; j < table.languages.Count; j++)
                        {
                            if (j >= field.values.Count)
                            {
                                field.values.Add(string.Empty);
                            }
                            EditorGUILayout.BeginHorizontal();

                            if (currentSearchResultIndex == i && currentSearchResultValueIndex == j)
                            {
                                GUI.SetNextControlName("Match");
                            }

                            EditorGUILayout.LabelField(table.languages[j], GUILayout.Width(60));
                            //---Was: field.values[j] = EditorGUILayout.TextField(field.values[j]);
                            field.values[j] = EditorGUILayout.TextArea(field.values[j]);
                            EditorGUILayout.LabelField(string.Empty, GUILayout.Width(22));
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorWindowTools.EndIndentedSection();
                    }

                    if (currentSearchResultIndex == i && needToFocusOnSearchResult)
                    {
                        GUI.FocusControl("Match");
                        needToFocusOnSearchResult = false;
                    }
                }
                EditorWindowTools.EndIndentedSection();
                if (fieldIndexToDelete != -1)
                {
                    DeleteField(fieldIndexToDelete);
                }
            }
        }
        private void DrawSavingStage()
        {
            EditorGUILayout.LabelField("Save System Settings", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();

            var hasSaveSystem = DialogueManager.instance.GetComponent <PixelCrushers.SaveSystem>() != null;
            var useSaveSystem = EditorGUILayout.Toggle("Use Save System", hasSaveSystem);

            if (useSaveSystem && !hasSaveSystem)
            {
                DialogueManager.instance.gameObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.SaveSystem)));
                hasSaveSystem = true;
            }
            else if (!useSaveSystem && hasSaveSystem)
            {
                DestroyImmediate(DialogueManager.instance.GetComponent <PixelCrushers.SaveSystem>());
                hasSaveSystem = false;
            }
            if (hasSaveSystem)
            {
                EditorGUILayout.HelpBox("The Dialogue System will automatically add a Player Prefs Saved Game Data Storer and JSON Data Serializer at runtime unless you add a different type of Saved Game Data Storer or Data Serializer component to it. For example, you can manually add a Disk Saved Game Data Storer if you want to save games to local disk files.", MessageType.None);
            }

            if (hasSaveSystem)
            {
                var dsSaver = DialogueManager.instance.GetComponent <DialogueSystemSaver>();
                if (dsSaver == null)
                {
                    dsSaver = DialogueManager.instance.gameObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.DialogueSystemSaver))) as PixelCrushers.DialogueSystem.DialogueSystemSaver;
                    dsSaver.saveAcrossSceneChanges = true;
                }

                var transitionManager    = DialogueManager.instance.GetComponent <PixelCrushers.SceneTransitionManager>();
                var hasTransitionManager = (transitionManager != null);
                var useTransitionManager = EditorGUILayout.Toggle("Use Scene Transitions", hasTransitionManager);
                if (useTransitionManager && !hasTransitionManager)
                {
                    hasTransitionManager = true;
                    transitionManager    = DialogueManager.instance.gameObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.StandardSceneTransitionManager))) as PixelCrushers.StandardSceneTransitionManager;
                    var stdTransitionMgr = transitionManager as StandardSceneTransitionManager;
                    stdTransitionMgr.pauseDuringTransition = true;
                    if (DialogueManager.instance.transform.Find("SceneFaderCanvas") == null)
                    {
                        var faderCanvasPrefab = AssetDatabase.LoadMainAssetAtPath("Assets/Plugins/Pixel Crushers/Dialogue System/Prefabs/Art/SceneFaderCanvas.prefab");
                        if (faderCanvasPrefab == null)
                        {
                            EditorUtility.DisplayDialog("Prefab Not Found", "This wizard can't find the SceneFaderCanvas prefab. You may have moved the Dialogue System to a different folder in your project. Scene transitions will not fade to black.", "OK");
                        }
                        else
                        {
                            var prefabGO = PrefabUtility.InstantiatePrefab(faderCanvasPrefab) as GameObject;
                            prefabGO.transform.SetParent(DialogueManager.instance.transform, false);
                            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                            stdTransitionMgr.leaveSceneTransition.animator              = prefabGO.GetComponent <Animator>();
                            stdTransitionMgr.leaveSceneTransition.trigger               = "Show";
                            stdTransitionMgr.leaveSceneTransition.animationDuration     = 1;
                            stdTransitionMgr.leaveSceneTransition.minTransitionDuration = 1;
                            stdTransitionMgr.enterSceneTransition.animator              = prefabGO.GetComponent <Animator>();
                            stdTransitionMgr.enterSceneTransition.trigger               = "Hide";
                        }
                    }
                }
                else if (!useTransitionManager && hasTransitionManager)
                {
                    DestroyImmediate(transitionManager);
                    hasTransitionManager = false;
                }
                if (hasTransitionManager)
                {
                    EditorGUILayout.HelpBox("The Dialogue Manager's Scene Transition Manager will fade to black by default. If you want to use a separate loading scene, inspect the Dialogue Manager and set the Loading Scene Name field.", MessageType.None);
                }
            }

            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
        private void DrawActorStage()
        {
            EditorGUILayout.LabelField("Dialogue Actor Component (Optional)", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("A Dialogue Actor component lets you specify which actor in the database this GameObject is associated with if the GameObject doesn't have the same name as the actor. You can also set actor-specific UI settings.", MessageType.Info);
            var dialogueActor    = npcObject.GetComponent <DialogueActor>();
            var hasDialogueActor = dialogueActor != null;

            if (dialogueActor == null)
            {
                dialogueActorEditor = null;
            }
            var useDialogueActor = EditorGUILayout.Toggle("Use Dialogue Actor", hasDialogueActor);

            if (useDialogueActor && !hasDialogueActor)
            {
                dialogueActor    = npcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.DialogueActor))) as DialogueActor;
                hasDialogueActor = true;
            }
            else if (!useDialogueActor && hasDialogueActor)
            {
                DestroyImmediate(dialogueActor);
                dialogueActor       = null;
                hasDialogueActor    = false;
                dialogueActorEditor = null;
            }
            if (hasDialogueActor)
            {
                if (dialogueActorEditor == null)
                {
                    dialogueActorEditor = Editor.CreateEditor(dialogueActor);
                }
                dialogueActorEditor.OnInspectorGUI();
            }

            EditorWindowTools.DrawHorizontalLine();
            var defaultCameraAngle    = npcObject.GetComponent <DefaultCameraAngle>();
            var hasDefaultCameraAngle = defaultCameraAngle != null;

            EditorGUILayout.BeginHorizontal();
            var useDefaultCameraAngle = EditorGUILayout.Toggle("Override Default Camera Angle", hasDefaultCameraAngle);

            EditorGUILayout.HelpBox("The default camera angle is 'Closeup'. You can override it here.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            if (useDefaultCameraAngle && !hasDefaultCameraAngle)
            {
                defaultCameraAngle    = npcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.DefaultCameraAngle))) as DefaultCameraAngle;
                hasDefaultCameraAngle = true;
            }
            else if (!useDefaultCameraAngle && hasDefaultCameraAngle)
            {
                DestroyImmediate(defaultCameraAngle);
                defaultCameraAngle    = null;
                hasDefaultCameraAngle = false;
            }
            if (hasDefaultCameraAngle)
            {
                EditorGUILayout.BeginHorizontal();
                defaultCameraAngle.cameraAngle = EditorGUILayout.TextField("Angle", defaultCameraAngle.cameraAngle);
                EditorGUILayout.HelpBox("Specify the default camera angle for this NPC.", MessageType.None);
                EditorGUILayout.EndHorizontal();
            }

            DrawBarkGroupSection();
            if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, (database != null), false);
        }
        private void DrawTargetingStage()
        {
            EditorGUILayout.LabelField("Interaction", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("If your player will be configured to use interaction components such as Selector or Proximity Selector, you can configure this NPC to be usable by the player.", MessageType.Info);
            if (!lookedUpDimension)
            {
                lookedUpDimension = true;
                dimension         = (npcObject.GetComponent <Collider2D>() != null) ? Dimension.In2D : Dimension.In3D;
            }
            dimension = (Dimension)EditorGUILayout.EnumPopup(new GUIContent("Scene Is...", "Is this NPC in a 2D or 3D scene?"), dimension);

            var usable    = npcObject.GetComponent <Usable>();
            var hasUsable = (usable != null);

            hasUsable = EditorGUILayout.Toggle("Usable By Player", hasUsable);
            if (usable == null && hasUsable)
            {
                usable = npcObject.AddComponent(TypeUtility.GetWrapperType(typeof(PixelCrushers.DialogueSystem.Usable))) as Usable;
            }
            else if (usable != null && !hasUsable)
            {
                DestroyImmediate(usable);
                usable       = null;
                usableEditor = null;
            }
            if (usable != null)
            {
                if (usableEditor == null)
                {
                    usableEditor = Editor.CreateEditor(usable);
                }
                usableEditor.OnInspectorGUI();
            }

            var hasTriggerCollider    = false;
            var hasNontriggerCollider = false;

            if (dimension == Dimension.In2D)
            {
                var colliders = npcObject.GetComponents <Collider2D>();
                foreach (var collider in colliders)
                {
                    if (collider.isTrigger)
                    {
                        hasTriggerCollider = true;
                    }
                    else
                    {
                        hasNontriggerCollider = true;
                    }
                }
            }
            else
            {
                var colliders = npcObject.GetComponents <Collider>();
                foreach (var collider in colliders)
                {
                    if (collider.isTrigger)
                    {
                        hasTriggerCollider = true;
                    }
                    else
                    {
                        hasNontriggerCollider = true;
                    }
                }
            }

            if (hasNontriggerCollider)
            {
                EditorGUILayout.HelpBox("This NPC has a collider. If you want to edit its properties, click Select NPC.", MessageType.None);
            }
            else
            {
                if (hasUsable)
                {
                    EditorGUILayout.HelpBox("This NPC has a Usable component. It also needs a collider so the player's Selector or Proximity Selector can detect it.", MessageType.None);
                }
                else
                {
                    EditorGUILayout.HelpBox("If this NPC will take action on collision enter/exit, it needs a collider.", MessageType.None);
                }
                hasTriggerCollider = EditorGUILayout.Toggle("Add Collider", hasTriggerCollider);
                if (hasTriggerCollider)
                {
                    if (dimension == Dimension.In2D)
                    {
                        npcObject.AddComponent <CircleCollider2D>();
                        var rb = npcObject.GetComponent <Rigidbody2D>();
                        if (rb == null)
                        {
                            rb             = npcObject.AddComponent <Rigidbody2D>();
                            rb.isKinematic = true;
                        }
                    }
                    else
                    {
                        npcObject.AddComponent <CapsuleCollider>();
                        var rb = npcObject.GetComponent <Rigidbody>();
                        if (rb == null)
                        {
                            rb             = npcObject.AddComponent <Rigidbody>();
                            rb.isKinematic = true;
                        }
                    }
                }
            }

            if (hasTriggerCollider)
            {
                EditorGUILayout.HelpBox("This NPC has a trigger collider. If you want to edit its properties, click Select NPC.", MessageType.None);
            }
            else
            {
                EditorGUILayout.HelpBox("If this NPC will take action on trigger enter/exit, it needs a trigger collider.", MessageType.None);
                hasTriggerCollider = EditorGUILayout.Toggle("Add Trigger Collider", hasTriggerCollider);
                if (hasTriggerCollider)
                {
                    if (dimension == Dimension.In2D)
                    {
                        var circleCollider = npcObject.AddComponent <CircleCollider2D>();
                        circleCollider.isTrigger = true;
                        circleCollider.radius    = 1.5f;
                        var rb = npcObject.GetComponent <Rigidbody2D>();
                        if (rb == null)
                        {
                            rb             = npcObject.AddComponent <Rigidbody2D>();
                            rb.isKinematic = true;
                        }
                    }
                    else
                    {
                        SphereCollider sphereCollider = npcObject.AddComponent <SphereCollider>();
                        sphereCollider.isTrigger = true;
                        sphereCollider.radius    = 1.5f;
                        var rb = npcObject.GetComponent <Rigidbody>();
                        if (rb == null)
                        {
                            rb             = npcObject.AddComponent <Rigidbody>();
                            rb.isKinematic = true;
                        }
                    }
                }
            }
            if (GUILayout.Button("Select NPC", GUILayout.Width(100)))
            {
                Selection.activeGameObject = npcObject;
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, true, false);
        }
        private void DrawFields()
        {
            // Draw Fields foldout and "+" button:
            EditorGUILayout.BeginHorizontal();
            fieldsFoldout = EditorGUILayout.Foldout(fieldsFoldout, "Fields");
            if (GUILayout.Button("Sort", EditorStyles.miniButton, GUILayout.Width(44)))
            {
                SortFields();
                return;
            }
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(22)))
            {
                fieldsFoldout = true;
                table.fields.Add(new LocalizedTextTable.LocalizedTextField());
                if (!fieldFoldouts.ContainsKey(table.fields.Count - 1))
                {
                    fieldFoldouts.Add(table.fields.Count - 1, true);
                }
            }
            EditorGUILayout.EndHorizontal();

            // Draw fields:
            if (fieldsFoldout)
            {
                int fieldIndexToDelete = -1;
                EditorWindowTools.StartIndentedSection();
                for (int i = 0; i < table.fields.Count; i++)
                {
                    LocalizedTextTable.LocalizedTextField field = table.fields[i];
                    if (!fieldFoldouts.ContainsKey(i))
                    {
                        fieldFoldouts.Add(i, false);
                    }
                    EditorGUILayout.BeginHorizontal();
                    fieldFoldouts[i] = EditorGUILayout.Foldout(fieldFoldouts[i], string.IsNullOrEmpty(field.name) ? string.Format("Field {0}", i) : field.name);
                    if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(22)))
                    {
                        fieldIndexToDelete = i;
                    }
                    EditorGUILayout.EndHorizontal();
                    if (fieldFoldouts[i])
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Field", GUILayout.Width(60));
                        field.name = EditorGUILayout.TextField(field.name);
                        EditorGUILayout.LabelField(string.Empty, GUILayout.Width(22));
                        EditorGUILayout.EndHorizontal();
                        EditorWindowTools.StartIndentedSection();
                        for (int j = 0; j < table.languages.Count; j++)
                        {
                            if (j >= field.values.Count)
                            {
                                field.values.Add(string.Empty);
                            }
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField(table.languages[j], GUILayout.Width(60));
                            field.values[j] = EditorGUILayout.TextField(field.values[j]);
                            EditorGUILayout.LabelField(string.Empty, GUILayout.Width(22));
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorWindowTools.EndIndentedSection();
                    }
                }
                EditorWindowTools.EndIndentedSection();
                if (fieldIndexToDelete != -1)
                {
                    DeleteField(fieldIndexToDelete);
                }
            }
        }
Beispiel #29
0
        public static string DrawLayout(GUIContent guiContent, string sequence, ref Rect rect)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(guiContent);
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(26)))
            {
                DrawContextMenu(sequence);
            }
            EditorGUILayout.EndHorizontal();
            if (menuResult != MenuResult.Unselected)
            {
                sequence   = ApplyMenuResult(menuResult, sequence);
                menuResult = MenuResult.Unselected;
            }

            EditorWindowTools.StartIndentedSection();
            var newSequence = EditorGUILayout.TextArea(sequence);

            if (!string.Equals(newSequence, sequence))
            {
                sequence    = newSequence;
                GUI.changed = true;
            }

            switch (Event.current.type)
            {
            case EventType.Repaint:
                rect = GUILayoutUtility.GetLastRect();
                break;

            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (rect.Contains(Event.current.mousePosition))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (Event.current.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();
                        foreach (var obj in DragAndDrop.objectReferences)
                        {
                            if (obj is AudioClip)
                            {
                                // Drop audio clip according to selected audio command:
                                var clip = obj as AudioClip;
                                var path = AssetDatabase.GetAssetPath(clip);
                                if (path.Contains("Resources"))
                                {
                                    sequence    = AddCommandToSequence(sequence, GetCurrentAudioCommand() + "(" + GetResourceName(path) + ")");
                                    GUI.changed = true;
                                }
                                else
                                {
                                    EditorUtility.DisplayDialog("Not in Resources Folder", "Audio clips must be located in the hierarchy of a Resources folder or an AssetBundle.", "OK");
                                }
                            }
                            else if (obj is GameObject)
                            {
                                // Drop GameObject.
                                var go = obj as GameObject;
                                if (sequence.EndsWith("("))
                                {
                                    // If sequence ends in open paren, add GameObject and close:
                                    sequence += go.name + ")";
                                }
                                else
                                {
                                    // Drop GameObject according to selected GameObject command:
                                    var command = Event.current.alt ? alternateGameObjectDragDropCommand : gameObjectDragDropCommand;
                                    sequence = AddCommandToSequence(sequence, GetCurrentGameObjectCommand(command, go.name));
                                }
                                GUI.changed = true;
                            }
                        }
                    }
                }
                break;
            }

            EditorWindowTools.EndIndentedSection();

            return(sequence);
        }
Beispiel #30
0
        private bool Draw3DTargetingOnUse()
        {
            EditorGUILayout.LabelField("Collider", EditorStyles.boldLabel);
            Collider nontriggerCollider = null;
            Collider triggerCollider    = null;

            foreach (var collider in npcObject.GetComponentsInChildren <Collider>())
            {
                if (collider.isTrigger)
                {
                    triggerCollider = collider;
                }
                else
                {
                    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 (triggerCollider == null)
                {
                    EditorGUILayout.HelpBox("The NPC is configured to listen for OnUse messages. If these messages will be coming from the player's ProximitySelector component, the NPC needs a trigger collider that the ProximitySelector can detect. Click Add Trigger Collider to add a Sphere Collider. If OnUse will come from another source, you don't necessarily need a trigger collider.", MessageType.Info);
                    if (GUILayout.Button("Add Trigger Collider", GUILayout.Width(160)))
                    {
                        triggerCollider           = npcObject.AddComponent <SphereCollider>();
                        triggerCollider.isTrigger = true;
                        var rb = npcObject.GetComponent <Rigidbody>();
                        if (rb == null)
                        {
                            rb             = npcObject.AddComponent <Rigidbody>();
                            rb.isKinematic = true;
                        }
                    }
                }
                else if (triggerCollider is SphereCollider)
                {
                    EditorGUILayout.HelpBox("The NPC has a trigger collider, so it's ready for OnUse events from the player's ProximitySelector if it has one. 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);
                }
                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);
        }