Ejemplo n.º 1
0
        private void DrawCameraStage()
        {
            EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            Camera playerCamera = pcObject.GetComponentInChildren <Camera>() ?? Camera.main;
            SmoothCameraWithBumper smoothCamera = (playerCamera != null) ? playerCamera.GetComponent <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 <Camera>();
                    playerCamera.tag = "MainCamera";
                }
                smoothCamera = playerCamera.GetComponentInChildren <SmoothCameraWithBumper>() ?? playerCamera.gameObject.AddComponent <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);
        }
            public void Draw(bool drawFoldout, bool draggable)
            {
                if (database == null)
                {
                    return;
                }

                if (drawFoldout)
                {
                    var foldout    = variableGroupFoldouts.Contains(group);
                    var newFoldout = EditorGUILayout.Foldout(foldout, group);
                    if (newFoldout != foldout)
                    {
                        foldout = newFoldout;
                        if (foldout)
                        {
                            variableGroupFoldouts.Add(group);
                        }
                        else
                        {
                            variableGroupFoldouts.Remove(group);
                        }
                    }
                    if (!foldout)
                    {
                        return;
                    }
                }
                if (reorderableList == null)
                {
                    reorderableList = new ReorderableList(variableList, typeof(Variable), draggable, false, true, true);
                    reorderableList.drawHeaderCallback    = OnDrawVariableHeader;
                    reorderableList.drawElementCallback   = OnDrawVariableElement;
                    reorderableList.onAddDropdownCallback = OnAddVariableDropdown;
                    reorderableList.onRemoveCallback      = OnRemoveVariable;
                }
                EditorWindowTools.StartIndentedSection();
                reorderableList.DoLayoutList();
                EditorWindowTools.EndIndentedSection();
            }
Ejemplo n.º 3
0
        private void DrawLocalizationSection()
        {
            EditorWindowTools.StartIndentedSection();
            if (exportLanguageList == null)
            {
                exportLanguageList = new ReorderableList(localizationLanguages.languages, typeof(string), true, true, true, true);
                exportLanguageList.drawHeaderCallback += OnDrawExportLanguageListHeader;
                exportLanguageList.drawElementCallback = OnDrawExportLanguageListElement;
                exportLanguageList.onAddCallback      += OnAddExportLanguageListElement;
            }
            exportLanguageList.DoLayoutList();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Checkbox also imports updated main text from file.");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Find Languages", GUILayout.Width(120)))
            {
                FindLanguagesForLocalizationExportImport();
            }
            if (GUILayout.Button("Export...", GUILayout.Width(100)))
            {
                var newOutputFolder = EditorUtility.OpenFolderPanel("Export Localization Files", localizationLanguages.outputFolder, string.Empty);
                if (!string.IsNullOrEmpty(newOutputFolder))
                {
                    localizationLanguages.outputFolder = newOutputFolder;
                    ExportLocalizationFiles();
                }
            }
            if (GUILayout.Button("Import...", GUILayout.Width(100)))
            {
                var newOutputFolder = EditorUtility.OpenFolderPanel("Import Localization Files", localizationLanguages.outputFolder, string.Empty);
                if (!string.IsNullOrEmpty(newOutputFolder))
                {
                    localizationLanguages.outputFolder = newOutputFolder;
                    ImportLocalizationFiles();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        private void DrawControlStage()
        {
            EditorGUILayout.LabelField("Control", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            SimpleController     simpleController     = pcObject.GetComponent <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 <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);
        }
Ejemplo n.º 7
0
        private void DrawVariable(Variable asset, int index, AssetFoldouts foldouts)
        {
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.BeginVertical("button");
            List <Field> fields = asset.fields;

            for (int i = 0; i < fields.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (IsTextAreaField(fields[i]))
                {
                    DrawTextAreaFirstPart(fields[i], false);
                    DrawTextAreaSecondPart(fields[i]);
                }
                else
                {
                    DrawField(fields[i], false);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 8
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));
 }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 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;
            }
            selector.useKey    = (KeyCode)EditorGUILayout.EnumPopup("'Use' Key", selector.useKey);
            selector.useButton = EditorGUILayout.TextField("'Use' Button", selector.useButton);
            EditorGUILayout.HelpBox("Click Select Player Inspect to customize the Selector.", MessageType.None);
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        private void DrawVariables()
        {
            List <Variable> assets   = database.variables;
            AssetFoldouts   foldouts = variableFoldouts;

            EditorWindowTools.StartIndentedSection();
            Variable assetToRemove = null;

            for (int index = 0; index < assets.Count; index++)
            {
                Variable asset = assets[index];
                EditorGUILayout.BeginHorizontal();
                if (!foldouts.properties.ContainsKey(index))
                {
                    foldouts.properties.Add(index, false);
                }
                foldouts.properties[index] = EditorGUILayout.Foldout(foldouts.properties[index], GetAssetName(asset));
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", GetAssetName(asset))), "OL Minus", GUILayout.Width(16)))
                {
                    assetToRemove = asset;
                }
                EditorGUILayout.EndHorizontal();
                if (foldouts.properties[index])
                {
                    DrawVariable(asset, index, foldouts);
                }
            }
            if (assetToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", GetAssetName(assetToRemove)), "Are you sure you want to delete this?", "Delete", "Cancel"))
                {
                    assets.Remove(assetToRemove);
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 15
0
 static void OpenWindow()
 {
     EditorWindowTools.OpenWindowNextToInspector <BuildWindow>("Build");
 }
Ejemplo n.º 16
0
        private void DrawAssets <T>(string label, List <T> assets, AssetFoldouts foldouts, string filter) where T : Asset
        {
            EditorWindowTools.StartIndentedSection();
            showStateFieldAsQuest = false;
            DrawAssetSpecificFoldoutProperties <T>(assets);
            T   assetToRemove   = null;
            int indexToMoveUp   = -1;
            int indexToMoveDown = -1;

            for (int index = 0; index < assets.Count; index++)
            {
                T asset = assets[index];
                if (!IsAssetInFilter(asset, filter))
                {
                    continue;
                }
                EditorGUILayout.BeginHorizontal();
                if (!foldouts.properties.ContainsKey(index))
                {
                    foldouts.properties.Add(index, false);
                }
                foldouts.properties[index] = EditorGUILayout.Foldout(foldouts.properties[index], GetAssetName(asset));
                EditorGUI.BeginDisabledGroup(index >= (assets.Count - 1));
                if (GUILayout.Button(new GUIContent("↓", "Move down"), GUILayout.Width(16)))
                {
                    indexToMoveDown = index;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(index == 0);
                if (GUILayout.Button(new GUIContent("↑", "Move up"), GUILayout.Width(16)))
                {
                    indexToMoveUp = index;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", GetAssetName(asset))), "OL Minus", GUILayout.Width(16)))
                {
                    assetToRemove = asset;
                }
                EditorGUILayout.EndHorizontal();
                if (foldouts.properties[index])
                {
                    DrawAsset <T>(asset, index, foldouts);
                }
            }
            if (indexToMoveDown >= 0)
            {
                T asset = assets[indexToMoveDown];
                assets.RemoveAt(indexToMoveDown);
                assets.Insert(indexToMoveDown + 1, asset);
                SetDatabaseDirty("Move Down");
            }
            else if (indexToMoveUp >= 0)
            {
                T asset = assets[indexToMoveUp];
                assets.RemoveAt(indexToMoveUp);
                assets.Insert(indexToMoveUp - 1, asset);
                SetDatabaseDirty("Move Up");
            }
            else if (assetToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", GetAssetName(assetToRemove)), "Are you sure you want to delete this?", "Delete", "Cancel"))
                {
                    assets.Remove(assetToRemove);
                    SetDatabaseDirty("Delete");
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
        private void TryExportToChatMapperXML()
        {
            string newChatMapperExportPath = EditorUtility.SaveFilePanel("Save Chat Mapper XML", EditorWindowTools.GetDirectoryName(chatMapperExportPath), chatMapperExportPath, "xml");

            if (!string.IsNullOrEmpty(newChatMapperExportPath))
            {
                chatMapperExportPath = newChatMapperExportPath;
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    chatMapperExportPath = chatMapperExportPath.Replace("/", "\\");
                }
                if (exportCanvasRect)
                {
                    AddCanvasRectTemplateField();
                }
                ValidateDatabase(database, false);
                ConfirmSyncAssetsAndTemplate();
                ChatMapperExporter.Export(database, chatMapperExportPath, exportActors, exportItems, exportLocations, exportVariables, exportConversations, exportCanvasRect);
                string templatePath = chatMapperExportPath.Replace(".xml", "_Template.txt");
                ExportTemplate(chatMapperExportPath, templatePath);
                EditorUtility.DisplayDialog("Export Complete", "The dialogue database was exported to Chat Mapper XML format.\n\n" +
                                            "Remember to apply a template after importing it into Chat Mapper. " +
                                            "The required fields in the template are listed in " + templatePath + ".\n\n" +
                                            "If you have any issues importing, please contact us at [email protected].", "OK");
            }
        }
        private void TryExportToLanguageText()
        {
            string newLanguageTextPath = EditorUtility.SaveFilePanel("Save Language Text", EditorWindowTools.GetDirectoryName(languageTextExportPath), languageTextExportPath, "txt");

            if (!string.IsNullOrEmpty(newLanguageTextPath))
            {
                languageTextExportPath = newLanguageTextPath;
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    languageTextExportPath = languageTextExportPath.Replace("/", "\\");
                }
                LanguageTextExporter.Export(database, languageTextExportPath, encodingType);
                EditorUtility.DisplayDialog("Export Complete", "The language texts have been exported to " + languageTextExportPath + " with the language code appended to the end of each filename. ", "OK");
            }
        }
        private void TryExportToVoiceoverScript()
        {
            string newVoiceoverPath = EditorUtility.SaveFilePanel("Save Voiceover Scripts", EditorWindowTools.GetDirectoryName(voiceoverExportPath), voiceoverExportPath, "csv");

            if (!string.IsNullOrEmpty(newVoiceoverPath))
            {
                voiceoverExportPath = newVoiceoverPath;
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    voiceoverExportPath = voiceoverExportPath.Replace("/", "\\");
                }
                VoiceoverScriptExporter.Export(database, voiceoverExportPath, exportActors, entrytagFormat, encodingType);
                EditorUtility.DisplayDialog("Export Complete", "The voiceover scripts were exported to CSV (comma-separated values) files in " + voiceoverExportPath + ".", "OK");
            }
        }
Ejemplo n.º 20
0
        private void DrawVariablesTraditional()
        {
            List <Variable> assets   = database.variables;
            AssetFoldouts   foldouts = variableFoldouts;

            EditorWindowTools.StartIndentedSection();
            Variable assetToRemove   = null;
            int      indexToMoveUp   = -1;
            int      indexToMoveDown = -1;

            for (int index = 0; index < assets.Count; index++)
            {
                Variable asset = assets[index];
                EditorGUILayout.BeginHorizontal();
                if (!foldouts.properties.ContainsKey(index))
                {
                    foldouts.properties.Add(index, false);
                }
                foldouts.properties[index] = EditorGUILayout.Foldout(foldouts.properties[index], GetAssetName(asset));
                EditorGUI.BeginDisabledGroup(index >= (assets.Count - 1));
                if (GUILayout.Button(new GUIContent("↓", "Move down"), GUILayout.Width(16)))
                {
                    indexToMoveDown = index;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(index == 0);
                if (GUILayout.Button(new GUIContent("↑", "Move up"), GUILayout.Width(16)))
                {
                    indexToMoveUp = index;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", GetAssetName(asset))), "OL Minus", GUILayout.Width(16)))
                {
                    assetToRemove = asset;
                }
                EditorGUILayout.EndHorizontal();
                if (foldouts.properties[index])
                {
                    DrawVariable(asset, index, foldouts);
                }
            }
            if (indexToMoveDown >= 0)
            {
                Variable asset = assets[indexToMoveDown];
                assets.RemoveAt(indexToMoveDown);
                assets.Insert(indexToMoveDown + 1, asset);
                SetDatabaseDirty("Move Variable Down");
            }
            else if (indexToMoveUp >= 0)
            {
                Variable asset = assets[indexToMoveUp];
                assets.RemoveAt(indexToMoveUp);
                assets.Insert(indexToMoveUp - 1, asset);
                SetDatabaseDirty("Move Variable Up");
            }
            else if (assetToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", GetAssetName(assetToRemove)), "Are you sure you want to delete this?", "Delete", "Cancel"))
                {
                    assets.Remove(assetToRemove);
                    SetDatabaseDirty("Delete Variable");
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
Ejemplo n.º 21
0
        void OnSceneGUI(SceneView sv)
        {
            if (!drawing)
            {
                if (preview != null)
                {
                    MonoBehaviour.DestroyImmediate(preview.gameObject);
                }

                previewLocked = false;
                return;
            }

            if (!InternalEditorUtility.isApplicationActive)
            {
                return;
            }

            GameObject prefab = GetPrefab();

            if (prefab == null)
            {
                return;
            }

            Event e = Event.current;

            Handles.BeginGUI();
            GUI.Label(new Rect(e.mousePosition.x + mosuePosOffset, (e.mousePosition.y + mosuePosOffset) - 75, sceneViewBoxSize, sceneViewBoxSize), GetHint());
            Handles.EndGUI();


            EditorWindowTools.FocusSceneViewOnMouseOver();


            Event current = Event.current;

            if (EventType.KeyUp == current.type)
            {
                bool earlyOut = false;
                if (exitDrawKey == current.keyCode)
                {
                    drawing  = false;
                    earlyOut = true;
                    MonoBehaviour.DestroyImmediate(preview.gameObject);
                }
                if (lockPreviewKey == current.keyCode)
                {
                    earlyOut      = true;
                    previewLocked = !previewLocked;
                }
                if (switchDrawModeKey == current.keyCode)
                {
                    earlyOut = true;
                    SwitchDrawMode();
                }
                if (alignNormalKey == current.keyCode)
                {
                    earlyOut    = true;
                    alignNormal = !alignNormal;
                }
                if (randomizePreviewKey == current.keyCode)
                {
                    earlyOut = true;
                    UpdatePreviewRandom();
                }
                if (earlyOut)
                {
                    current.Use();
                    Repaint();
                    return;
                }
            }

            bool focus = false;

            if ((EventType.KeyUp == current.type || EventType.KeyDown == current.type) && focusKey == current.keyCode)
            {
                focus = EventType.KeyUp == current.type;
                current.Use();
            }

            if (EventType.ScrollWheel == current.type && current.command)
            {
                radius += current.delta.y;
                current.Use();
            }

            int      controlId = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
            Collider hitCollider;
            bool     isValid = CalculateMousePosition(out hitCollider);

            if (isValid)
            {
                if (drawMode == DrawMode.Field || drawMode == DrawMode.RandomArea)
                {
                    Handles.color = current.shift ? GUITools.red : GUITools.white;
                    if (drawMode == DrawMode.Field)
                    {
                        Matrix4x4 mat = Handles.matrix;
                        Handles.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.FromToRotation(Vector3.up, hitNormal), Vector3.one);
                        Handles.DrawWireCube(hitPos, new Vector3(radius * 2, 1, radius * 2));
                        Handles.matrix = mat;
                    }
                    else if (drawMode == DrawMode.RandomArea)
                    {
                        Handles.DrawWireDisc(hitPos, hitNormal, radius);
                    }
                }

                if (focus)
                {
                    SceneView.lastActiveSceneView.Frame(new Bounds(hitPos, Vector3.one * radius), false);
                }

                if ((current.type == EventType.MouseDown) && !current.alt)
                {
                    if (current.button == 0)
                    {
                        if (!current.shift)
                        {
                            PrefabInstantiate(prefab);
                        }
                        else
                        {
                            PrefabRemove(hitCollider);
                        }
                    }
                }
            }

            HandlePreview(isValid, current.shift);

            if (Event.current.type == EventType.Layout)
            {
                HandleUtility.AddDefaultControl(controlId);
            }

            SceneView.RepaintAll();
        }
Ejemplo n.º 22
0
 public static void ShowWindow()
 {
     EditorWindowTools.SetSize(EditorWindow.GetWindow <IconsMenu>("Icons Menu"), 512, 512).CenterWindow();
 }
Ejemplo n.º 23
0
 static void OpenWindow()
 {
     EditorWindowTools.OpenWindowNextToInspector <GameSettingsWindow>("Game Settings");
 }
 static void OpenWindow()
 {
     EditorWindowTools.OpenWindowNextToInspector <InputManagerWindow>("Input Manager");
 }
Ejemplo n.º 25
0
        private void DrawConversations()
        {
            EditorWindowTools.StartIndentedSection();
            showStateFieldAsQuest = false;
            Conversation conversationToRemove = null;
            int          indexToMoveUp        = -1;
            int          indexToMoveDown      = -1;

            for (int index = 0; index < database.conversations.Count; index++)
            {
                Conversation conversation = database.conversations[index];
                EditorGUILayout.BeginHorizontal();
                bool isCurrentConversation = (conversation == currentConversation);
                bool foldout = isCurrentConversation;
                foldout = EditorGUILayout.Foldout(foldout, conversation.Title);
                EditorGUI.BeginDisabledGroup(index >= (database.conversations.Count - 1));
                if (GUILayout.Button(new GUIContent("↓", "Move down"), GUILayout.Width(16)))
                {
                    indexToMoveDown = index;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(index == 0);
                if (GUILayout.Button(new GUIContent("↑", "Move up"), GUILayout.Width(16)))
                {
                    indexToMoveUp = index;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(new GUIContent(" ", string.Format("Delete {0}.", conversation.Title)), "OL Minus", GUILayout.Width(16)))
                {
                    conversationToRemove = conversation;
                }
                EditorGUILayout.EndHorizontal();
                if (foldout)
                {
                    if (!isCurrentConversation)
                    {
                        OpenConversation(conversation);
                    }
                    DrawConversation();
                }
                else if (isCurrentConversation)
                {
                    ResetConversationSection();
                }
            }
            if (indexToMoveDown >= 0)
            {
                var conversation = database.conversations[indexToMoveDown];
                database.conversations.RemoveAt(indexToMoveDown);
                database.conversations.Insert(indexToMoveDown + 1, conversation);
                SetDatabaseDirty("Move Conversation Up");
            }
            else if (indexToMoveUp >= 0)
            {
                var conversation = database.conversations[indexToMoveUp];
                database.conversations.RemoveAt(indexToMoveUp);
                database.conversations.Insert(indexToMoveUp - 1, conversation);
                SetDatabaseDirty("Move Conversation Down");
            }
            else if (conversationToRemove != null)
            {
                if (EditorUtility.DisplayDialog(string.Format("Delete '{0}'?", conversationToRemove.Title),
                                                "Are you sure you want to delete this conversation?\nYou cannot undo this operation!", "Delete", "Cancel"))
                {
                    if (conversationToRemove == currentConversation)
                    {
                        ResetConversationSection();
                    }
                    database.conversations.Remove(conversationToRemove);
                    SetDatabaseDirty("Delete Conversation");
                }
            }
            EditorWindowTools.EndIndentedSection();
        }
 /// <summary>
 /// Draws the articy:draft Project filename field.
 /// </summary>
 private void DrawProjectFilenameField()
 {
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.TextField(new GUIContent("articy:draft Project", "The XML file that you exported from articy:draft."), prefs.ProjectFilename);
     if (GUILayout.Button("...", EditorStyles.miniButtonRight, GUILayout.Width(22)))
     {
         prefs.ProjectFilename      = EditorUtility.OpenFilePanel("Select articy:draft Project", EditorWindowTools.GetDirectoryName(prefs.ProjectFilename), "xml");
         GUIUtility.keyboardControl = 0;
     }
     EditorGUILayout.EndHorizontal();
     if (EditorGUI.EndChangeCheck())
     {
         ConverterPrefsTools.Save(prefs);
         articyData = null;
     }
 }
        private void ImportTemplate()
        {
            string importPath = EditorUtility.OpenFilePanel("Import Template from XML", EditorWindowTools.GetDirectoryName(templateExportPath), "xml");

            if (!string.IsNullOrEmpty(importPath))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(Template));
                Template      newTemplate   = xmlSerializer.Deserialize(new StreamReader(importPath)) as Template;
                if (newTemplate != null)
                {
                    template = newTemplate;
                }
                else
                {
                    EditorUtility.DisplayDialog("Import Error", "Unable to import template data from the XML file.", "OK");
                }
            }
        }
        private void ExportTemplate()
        {
            string newExportPath = EditorUtility.SaveFilePanel("Export Template to XML", EditorWindowTools.GetDirectoryName(templateExportPath), templateExportPath, "xml");

            if (!string.IsNullOrEmpty(newExportPath))
            {
                templateExportPath = newExportPath;
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(Template));
                StreamWriter  streamWriter  = new StreamWriter(templateExportPath, false, System.Text.Encoding.Unicode);
                xmlSerializer.Serialize(streamWriter, template);
                streamWriter.Close();
            }
        }
Ejemplo n.º 29
0
 static void OpenWindow()
 {
     EditorWindowTools.OpenWindowNextToInspector <PrefabPainter>("Prefab Painter");
 }
Ejemplo n.º 30
0
        private void DrawQuestEntries(Item item)
        {
            EditorGUILayout.LabelField("Quest Entries", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            int entryCount      = Field.LookupInt(item.fields, "Entry Count");
            int entryToDelete   = -1;
            int entryToMoveUp   = -1;
            int entryToMoveDown = -1;

            for (int i = 1; i <= entryCount; i++)
            {
                DrawQuestEntry(item, i, entryCount, ref entryToDelete, ref entryToMoveUp, ref entryToMoveDown);
            }
            if (entryToDelete != -1)
            {
                DeleteQuestEntry(item, entryToDelete, entryCount);
                SetDatabaseDirty("Delete Quest Entry");
            }
            if (entryToMoveUp != -1)
            {
                MoveQuestEntryUp(item, entryToMoveUp, entryCount);
            }
            if (entryToMoveDown != -1)
            {
                MoveQuestEntryDown(item, entryToMoveDown, entryCount);
            }
            if (GUILayout.Button(new GUIContent("Add New Quest Entry", "Adds a new quest entry to this quest.")))
            {
                entryCount++;
                Field.SetValue(item.fields, "Entry Count", entryCount);
                Field.SetValue(item.fields, string.Format("Entry {0} State", entryCount), "unassigned");
                Field.SetValue(item.fields, string.Format("Entry {0}", entryCount), string.Empty);
                List <string> questLanguages = new List <string>();
                item.fields.ForEach(field =>
                {
                    if (field.title.StartsWith("Description "))
                    {
                        string language = field.title.Substring("Description ".Length);
                        questLanguages.Add(language);
                        languages.Add(language);
                    }
                });
                questLanguages.ForEach(language => item.fields.Add(new Field(string.Format("Entry {0} {1}", entryCount, language), string.Empty, FieldType.Localization)));

                if (entryCount > 1)
                {
                    // Copy any custom "Entry 1 ..." fields to "Entry # ..." fields:
                    var fieldCount = item.fields.Count;
                    for (int i = 0; i < fieldCount; i++)
                    {
                        var field = item.fields[i];
                        if (field.title.StartsWith("Entry 1 "))
                        {
                            // Skip Entry 1, Entry 1 State, or Entry 1 Language:
                            if (string.Equals(field.title, "Entry 1") || string.Equals(field.title, "Entry 1 State"))
                            {
                                continue;
                            }
                            var afterEntryNumber = field.title.Substring("Entry 1 ".Length);
                            if (questLanguages.Contains(afterEntryNumber))
                            {
                                continue;
                            }

                            // Otherwise add:
                            var newFieldTitle = "Entry " + entryCount + " " + afterEntryNumber;
                            if (item.FieldExists(newFieldTitle))
                            {
                                continue;
                            }
                            var copiedField = new Field(field);
                            copiedField.title = newFieldTitle;
                            if (copiedField.type == FieldType.Text)
                            {
                                copiedField.value = string.Empty;
                            }
                            item.fields.Add(copiedField);
                        }
                    }
                }

                SetDatabaseDirty("Add New Quest Entry");
            }
            EditorWindowTools.EndIndentedSection();
        }