Example #1
0
        void ShowEventFolder(TreeItem item, Predicate <TreeItem> filter)
        {
            eventStyle.padding.left += 17;

            {
                // Highlight first found item
                if (item.EventRef != null || item.BankRef != null)
                {
                    if (!String.IsNullOrEmpty(searchString) &&
                        itemCount == 0 &&
                        selectedItem == null
                        )
                    {
                        SetSelectedItem(item);
                    }

                    itemCount++;
                }

                item.Next = null;
                item.Prev = lastDrawnItem;
                if (lastDrawnItem != null)
                {
                    lastDrawnItem.Next = item;
                }
                lastDrawnItem = item;
            }

            if (item.EventRef != null)
            {
                // Rendering and GUI event handling to show an event
                GUIContent content = new GUIContent(item.Name, item.EventRef.Path.StartsWith("snapshot") ? snapshotIcon : eventIcon);

                eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null;

                GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true));

                Event e = Event.current;

                Rect rect = GUILayoutUtility.GetLastRect();
                if (e.type == EventType.MouseDown &&
                    e.button == 0 &&
                    rect.Contains(e.mousePosition))
                {
                    e.Use();

                    if (fromInspector && e.clickCount >= 2)
                    {
                        outputProperty.stringValue = "";
                        outputProperty.stringValue = item.EventRef.Path;
                        EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, item.EventRef.Path);
                        outputProperty.serializedObject.ApplyModifiedProperties();

                        Close();
                    }

                    SetSelectedItem(item);
                }
                if (e.type == EventType.mouseDrag && rect.Contains(e.mousePosition) && !fromInspector)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.objectReferences = new UnityEngine.Object[] { ScriptableObject.Instantiate(item.EventRef) };
                    DragAndDrop.StartDrag("New FMOD Studio Emitter");
                    e.Use();
                }
                if (Event.current.type == EventType.Repaint)
                {
                    item.Rect = rect;
                }
            }
            else if (item.BankRef != null)
            {
                // Rendering and event handling for a bank
                GUIContent content = new GUIContent(item.Name, bankIcon);

                eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null;

                GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true));

                Event e = Event.current;

                Rect rect = GUILayoutUtility.GetLastRect();
                if (e.type == EventType.MouseDown &&
                    e.button == 0 &&
                    rect.Contains(e.mousePosition))
                {
                    e.Use();

                    if (fromInspector && e.clickCount >= 2)
                    {
                        outputProperty.stringValue = item.BankRef.Name;
                        outputProperty.serializedObject.ApplyModifiedProperties();
                        Close();
                    }

                    SetSelectedItem(item);
                }
                if (e.type == EventType.mouseDrag && rect.Contains(e.mousePosition) && !fromInspector)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.objectReferences = new UnityEngine.Object[] { ScriptableObject.Instantiate(item.BankRef) };
                    DragAndDrop.StartDrag("New FMOD Studio Bank Loader");
                    e.Use();
                }
                if (Event.current.type == EventType.Repaint)
                {
                    item.Rect = rect;
                }
            }
            else
            {
                eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null;

                bool       expanded = item.Expanded || !string.IsNullOrEmpty(searchString);
                GUIContent content  = new GUIContent(item.Name, expanded ? folderOpenIcon : folderClosedIcon);
                GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true));

                Rect rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.MouseDown &&
                    Event.current.button == 0 &&
                    rect.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    item.Expanded = !item.Expanded;
                    SetSelectedItem(item);
                }

                if (item.Expanded || !string.IsNullOrEmpty(searchString))
                {
                    item.Children.Sort((a, b) => a.Name.CompareTo(b.Name));
                    if (item.Name.ToLower().Contains(searchString.ToLower()))
                    {
                        foreach (var childFolder in item.Children)
                        {
                            ShowEventFolder(childFolder, (x) => true);
                        }
                    }
                    else
                    {
                        foreach (var childFolder in item.Children.FindAll(filter))
                        {
                            ShowEventFolder(childFolder, filter);
                        }
                    }
                }

                if (Event.current.type == EventType.Repaint)
                {
                    item.Rect = rect;
                }
            }
            eventStyle.padding.left -= 17;
        }
Example #2
0
        private void DrawSideWindow()
        {
            GUILayout.Label(new GUIContent("Node Editor (" + canvasCache.nodeCanvas.name + ")", "Opened Canvas path: " + canvasCache.openedCanvasPath), NodeEditorGUI.nodeLabelBold);

//			EditorGUILayout.ObjectField ("Loaded Canvas", canvasCache.nodeCanvas, typeof(NodeCanvas), false);
//			EditorGUILayout.ObjectField ("Loaded State", canvasCache.editorState, typeof(NodeEditorState), false);

            if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, canvasCache.NewNodeCanvas);
                menu.Show(createCanvasUIPos.position, createCanvasUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder")))
            {
                string path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/");
                if (!string.IsNullOrEmpty(path))
                {
                    canvasCache.SaveNodeCanvas(path);
                }
            }

            if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder")))
            {
                string path = EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset");
                if (!path.Contains(Application.dataPath))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        ShowNotification(new GUIContent("You should select an asset inside your project folder!"));
                    }
                }
                else
                {
                    canvasCache.LoadNodeCanvas(path);
                }
            }

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false)))
            {
                canvasCache.SaveSceneNodeCanvas(sceneCanvasName);
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave);
                }
                menu.Show(loadSceneUIPos.position, loadSceneUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                loadSceneUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually.")))
            {
                NodeEditor.RecalculateAll(canvasCache.nodeCanvas);
            }

            if (GUILayout.Button("Force Re-Init"))
            {
                NodeEditor.ReInit(true);
            }

            NodeEditorGUI.knobSize       = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20);
            canvasCache.editorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), canvasCache.editorState.zoom, 0.6f, 2);

            if (canvasCache.editorState.selectedNode != null && Event.current.type != EventType.Ignore)
            {
                canvasCache.editorState.selectedNode.DrawNodePropertyEditor();
            }
        }
Example #3
0
    public void OnGUI()
    {
        if (!this.IsVisible)
        {
            return;
        }

        GUI.skin.label.wordWrap = true;
        //GUI.skin.button.richText = true;      // this allows toolbar buttons to have bold/colored text. nice to indicate new msgs
        //GUILayout.Button("<b>lala</b>");      // as richText, html tags could be in text


        if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
        {
            if ("ChatInput".Equals(GUI.GetNameOfFocusedControl()))
            {
                // focus on input -> submit it
                GuiSendsMsg();
                return; // showing the now modified list would result in an error. to avoid this, we just skip this single frame
            }
            else
            {
                // assign focus to input
                GUI.FocusControl("ChatInput");
            }
        }

        GUI.SetNextControlName("");
        GUILayout.BeginArea(this.GuiRect);

        GUILayout.FlexibleSpace();

        if (this.chatClient == null || this.chatClient.State != ChatState.ConnectedToFrontEnd)
        {
            GUILayout.Label("Not in chat yet.");
        }
        else
        {
            List <string> channels = new List <string>(this.chatClient.PublicChannels.Keys);    // this could be cached
            int           countOfPublicChannels = channels.Count;
            channels.AddRange(this.chatClient.PrivateChannels.Keys);

            if (channels.Count > 0)
            {
                int previouslySelectedChannelIndex = this.selectedChannelIndex;
                int channelIndex = channels.IndexOf(this.selectedChannelName);
                this.selectedChannelIndex = (channelIndex >= 0) ? channelIndex : 0;

                this.selectedChannelIndex = GUILayout.Toolbar(this.selectedChannelIndex, channels.ToArray(), GUILayout.ExpandWidth(false));
                this.scrollPos            = GUILayout.BeginScrollView(this.scrollPos);

                this.doingPrivateChat    = (this.selectedChannelIndex >= countOfPublicChannels);
                this.selectedChannelName = channels[this.selectedChannelIndex];

                if (this.selectedChannelIndex != previouslySelectedChannelIndex)
                {
                    // changed channel -> scroll down, if private: pre-fill "to" field with target user's name
                    this.scrollPos.y = float.MaxValue;
                    if (this.doingPrivateChat)
                    {
                        string[] pieces = this.selectedChannelName.Split(new char[] { ':' }, 3);
                        this.userIdInput = pieces[1];
                    }
                }

                GUILayout.Label(ChatGui.WelcomeText);

                if (this.chatClient.TryGetChannel(selectedChannelName, this.doingPrivateChat, out this.selectedChannel))
                {
                    for (int i = 0; i < this.selectedChannel.Messages.Count; i++)
                    {
                        string sender  = this.selectedChannel.Senders[i];
                        object message = this.selectedChannel.Messages[i];
                        GUILayout.Label(string.Format("{0}: {1}", sender, message));
                    }
                }

                GUILayout.EndScrollView();
            }
        }


        GUILayout.BeginHorizontal();
        if (doingPrivateChat)
        {
            GUILayout.Label("to:", GUILayout.ExpandWidth(false));
            GUI.SetNextControlName("WhisperTo");
            this.userIdInput = GUILayout.TextField(this.userIdInput, GUILayout.MinWidth(100), GUILayout.ExpandWidth(false));
            string focussed = GUI.GetNameOfFocusedControl();
            if (focussed.Equals("WhisperTo"))
            {
                if (this.userIdInput.Equals("username"))
                {
                    this.userIdInput = "";
                }
            }
            else if (string.IsNullOrEmpty(this.userIdInput))
            {
                this.userIdInput = "username";
            }
        }
        GUI.SetNextControlName("ChatInput");
        inputLine = GUILayout.TextField(inputLine);
        if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
        {
            GuiSendsMsg();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Example #4
0
    void DrawAddFrame(tk2dSpriteAnimationClip clip, bool vertical)
    {
        GUILayout.Space(32);
        if (vertical)
        {
            GUILayout.BeginHorizontal();
        }
        else
        {
            GUILayout.BeginVertical();
        }

        GUILayout.FlexibleSpace();
        if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single && GUILayout.Button("Add frame", GUILayout.ExpandWidth(false)))
        {
            AddFrame(clip);
            scrollPosition.y += 200.0f;             // allways bring the new frame into view
        }
        GUILayout.FlexibleSpace();

        if (vertical)
        {
            GUILayout.EndHorizontal();
        }
        else
        {
            GUILayout.EndVertical();
        }
        GUILayout.Space(32);
    }
Example #5
0
    public override void OnInspectorGUI()
    {
        MMD4MecanimAnimMorphHelper animMorphHelper = this.target as MMD4MecanimAnimMorphHelper;

        EditorGUILayout.Separator();

        animMorphHelper.animName        = EditorGUILayout.TextField("Anim Name", animMorphHelper.animName);
        animMorphHelper.playingAnimName = EditorGUILayout.TextField("Playing Anim Name", animMorphHelper.playingAnimName);

        EditorGUILayout.Separator();

        animMorphHelper.animEnabled     = EditorGUILayout.Toggle("Enabled", animMorphHelper.animEnabled);
        animMorphHelper.animPauseOnEnd  = EditorGUILayout.Toggle("Pause On End", animMorphHelper.animPauseOnEnd);
        animMorphHelper.animSyncToAudio = EditorGUILayout.Toggle("Sync To Audio", animMorphHelper.animSyncToAudio);

        EditorGUILayout.Separator();

        animMorphHelper.initializeOnAwake = EditorGUILayout.Toggle("Initialize On Awake", animMorphHelper.initializeOnAwake);
        animMorphHelper.morphSpeed        = EditorGUILayout.FloatField("Morph Speed (Start/End)", animMorphHelper.morphSpeed);
        animMorphHelper.overrideWeight    = EditorGUILayout.Toggle("Override Weight", animMorphHelper.overrideWeight);

        EditorGUILayout.Separator();

        if (animMorphHelper.animList != null)
        {
            GUILayout.Label("Animations", EditorStyles.boldLabel);

            for (int animIndex = 0; animIndex < animMorphHelper.animList.Length;)
            {
                MMD4MecanimAnimMorphHelper.Anim anim = animMorphHelper.animList[animIndex];

                EditorGUILayout.BeginHorizontal();
                bool isRemove = GUILayout.Button("-", EditorStyles.miniButton, GUILayout.ExpandWidth(false));
                anim.animName = EditorGUILayout.TextField("Anim Name", anim.animName);
                EditorGUILayout.EndHorizontal();

                TextAsset animFile = anim.animFile;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(26.0f);
                animFile = (TextAsset)EditorGUILayout.ObjectField("Anim File", (Object)animFile, typeof(TextAsset), false);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(26.0f);
                anim.audioClip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", (AudioClip)anim.audioClip, typeof(AudioClip), false);
                EditorGUILayout.EndHorizontal();

                if (animFile != null)
                {
                    if (!AssetDatabase.GetAssetPath(animFile).ToLower().EndsWith(".anim.bytes"))
                    {
                        animFile = null;
                    }
                    else
                    {
                        if (anim.animFile != animFile)
                        {
                            anim.animFile = animFile;
                            anim.animName = System.IO.Path.GetFileNameWithoutExtension(animFile.name);
                        }
                    }
                }
                else
                {
                    isRemove      = true;
                    anim.animFile = null;
                }
                if (isRemove)
                {
                    for (int i = animIndex; i + 1 < animMorphHelper.animList.Length; ++i)
                    {
                        animMorphHelper.animList[i] = animMorphHelper.animList[i + 1];
                    }
                    System.Array.Resize(ref animMorphHelper.animList, animMorphHelper.animList.Length - 1);
                }
                else
                {
                    ++animIndex;
                }
            }
        }

        EditorGUILayout.Separator();

        {
            GUILayout.Label("Add Animation", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(26.0f);
            TextAsset animFile = (TextAsset)EditorGUILayout.ObjectField("Anim File", (Object)null, typeof(TextAsset), false);
            EditorGUILayout.EndHorizontal();
            if (animFile != null)
            {
                if (!AssetDatabase.GetAssetPath(animFile).ToLower().EndsWith(".anim.bytes"))
                {
                    Debug.LogWarning(System.IO.Path.GetExtension(AssetDatabase.GetAssetPath(animFile)).ToLower());
                    animFile = null;
                }
                else
                {
                    MMD4MecanimAnimMorphHelper.Anim anim = new MMD4MecanimAnimMorphHelper.Anim();
                    anim.animFile = animFile;
                    anim.animName = System.IO.Path.GetFileNameWithoutExtension(animFile.name);
                    if (animMorphHelper.animList == null)
                    {
                        animMorphHelper.animList    = new MMD4MecanimAnimMorphHelper.Anim[1];
                        animMorphHelper.animList[0] = anim;
                    }
                    else
                    {
                        int animIndex = animMorphHelper.animList.Length;
                        System.Array.Resize(ref animMorphHelper.animList, animIndex + 1);
                        animMorphHelper.animList[animIndex] = anim;
                    }
                }
            }
        }
    }
        private void DrawPathPicker()
        {
            using (new GUILayout.HorizontalScope())
            {
                //EditorGUILayout.PrefixLabel("Import Path");

                string displayPath = importSettings.TargetDirectory;

                EditorGUI.BeginChangeCheck();
                string userPath = EditorGUILayout.DelayedTextField(labelPath, displayPath, GUILayout.ExpandWidth(true));
                if (EditorGUI.EndChangeCheck())
                {
                    if (string.IsNullOrEmpty(userPath) == false)
                    {
                        userPath = string.Format("Assets/{0}", userPath);
                    }
                    else
                    {
                        userPath = importPath.Substring(0, importPath.LastIndexOf("/"));
                    }
                    if (AssetDatabase.IsValidFolder(userPath))
                    {
                        importSettings.TargetDirectory = userPath;
                    }
                }

                if (GUILayout.Button(labelPickPath, EditorStyles.miniButtonRight, noExpandW))
                {
                    GUI.FocusControl(null);
                    string openPath = importSettings.TargetDirectory;
                    if (string.IsNullOrEmpty(openPath))
                    {
                        openPath = importPath.Substring(0, importPath.LastIndexOf("/"));
                    }

                    openPath = EditorUtility.SaveFolderPanel("Export Path", openPath, "");

                    int inPath = openPath.IndexOf(Application.dataPath);
                    if (inPath < 0 || Application.dataPath.Length == openPath.Length)
                    {
                        openPath = string.Empty;
                    }
                    else
                    {
                        openPath = openPath.Substring(Application.dataPath.LastIndexOf("/") + 1);
                    }

                    importSettings.TargetDirectory = openPath;
                }
            }
        }
        private void DrawLayerTable()
        {
            using (new EditorGUILayout.HorizontalScope(styleToolbar))
            {
                searchFilter = EditorGUILayout.TextField(searchFilter, styleToolSearch, GUILayout.ExpandWidth(true));
                if (GUILayout.Button(GUIContent.none, styleToolCancel))
                {
                    searchFilter = string.Empty;
                    GUI.FocusControl(null);
                }

                if (showHeader)
                {
                    EditorGUILayout.LabelField(labelHeader, styleHeader, noExpandW);
                }

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    isAdvancedMode = GUILayout.Toggle(isAdvancedMode, labelAdvanced, EditorStyles.miniButton, noExpandW);
                    if (check.changed)
                    {
                        EditorPrefs.SetBool(PrefKeyAdvancedMode, isAdvancedMode);
                    }
                }

                if (Event.current.type == EventType.Repaint)
                {
                    showHeader = string.IsNullOrEmpty(searchFilter);
                    if (showHeader == false)
                    {
                        showHeader = EditorGUIUtility.currentViewWidth > 400;
                    }
                }
            }

            var width = CalculateColumns();

            var rHeader = GUILayoutUtility.GetRect(width, rTableSize.x, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight);

            GUI.Box(rHeader, GUIContent.none, styleToolbar);
            GUI.Label(new Rect(rLayerDisplay)
            {
                y = rHeader.y, x = rLayerDisplay.x - scrollPos.x
            }, "Layer");
            if (isAdvancedMode)
            {
                GUI.Label(new Rect(rPivot)
                {
                    y = rHeader.y, x = rPivot.x - scrollPos.x
                }, "Pivot");
                GUI.Label(new Rect(rScaling)
                {
                    y = rHeader.y, x = rScaling.x - scrollPos.x
                }, "Scale");
            }

            using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos))
            {
                scrollPos = scrollView.scrollPosition;
                DrawLayerContents();
            }

            if (Event.current.type == EventType.Repaint)
            {
                var scrollArea    = GUILayoutUtility.GetLastRect();
                var newWillScroll = layerEntryYMax > scrollArea.yMax;
                if (newWillScroll != tableWillScroll)
                {
                    tableWillScroll = newWillScroll;
                    Repaint();
                }
            }

            using (new EditorGUI.DisabledGroupScope(importFile == null))
            {
                var btnW = GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth / 2f);
                using (new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Save Selection", btnW))
                    {
                        AddQuickSelect();
                        Repaint();
                        WriteImportSettings();
                    }

                    if (GUILayout.Button("Clear Selection", btnW))
                    {
                        quickSelect.Clear();
                        selectionCount    = 0;
                        lastSelectedLayer = null;
                    }
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    string textImport      = string.Format("Import Saved ({0})", importLayersList.Count);
                    string textQuickImport = string.Format("Import Selected ({0})", selectionCount);

                    if (GUILayout.Button(textImport, bigButton, btnW))
                    {
                        PsdImporter.ImportLayersUI(importFile, importSettings, importLayersList);
                    }

                    if (GUILayout.Button(textQuickImport, bigButton, btnW))
                    {
                        PsdImporter.ImportLayersUI(importFile, importSettings, quickSelect);
                    }
                }
            }

            GUILayout.Box(GUIContent.none, GUILayout.Height(4f), GUILayout.ExpandWidth(true));
        }
Example #8
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label("Comment Editor", EditorStyles.boldLabel);
        if (comments != null)
        {
            if (GUILayout.Button("Show Comment Asset", GUILayout.ExpandWidth(false)))
            {
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = comments;
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Open Comment List", GUILayout.ExpandWidth(false)))
        {
            OpenCommentList();
        }
        if (GUILayout.Button("New Comment List", GUILayout.ExpandWidth(false)))
        {
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = comments;
        }
        GUILayout.EndHorizontal();

        if (comments == null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            if (GUILayout.Button("Create New Comment List", GUILayout.ExpandWidth(false)))
            {
                CreateNewCommentList();
            }
            if (GUILayout.Button("Open Existing Comment List", GUILayout.ExpandWidth(false)))
            {
                OpenCommentList();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(20);

        if (comments != null)
        {
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
            {
                if (viewIndex > 1)
                {
                    viewIndex--;
                }
                else
                {
                    viewIndex = 3;
                }
            }
            GUILayout.Space(5);
            if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
            {
                if (viewIndex < 3)
                {
                    viewIndex++;
                }
                else
                {
                    viewIndex = 1;
                }
            }/*
              * GUILayout.Space(60);
              *
              * if (GUILayout.Button("Add Item", GUILayout.ExpandWidth(false)))
              * {
              * AddItem();
              * }
              * if (GUILayout.Button("Delete Item", GUILayout.ExpandWidth(false)))
              * {
              * DeleteItem(viewIndex - 1);
              * }
              *
              */
            GUILayout.EndHorizontal();
            //if (comments.commentList == null)
            //   Debug.Log("wtf");

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            if (viewIndex == 1)
            {
                //////////
                // WORK //
                //////////
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Work", EditorStyles.boldLabel);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Zero list", GUILayout.ExpandWidth(false)))
                {
                    ZeroList(0);
                }
                GUILayout.Space(86);
                if (GUILayout.Button("Add line", GUILayout.ExpandWidth(false)))
                {
                    AddCommentLine(0);
                }
                GUILayout.EndHorizontal();
                if (comments.WorkPositive != null)
                {
                    ScriptableObject   target          = comments;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("WorkPositive");

                    EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
                    so.ApplyModifiedProperties();                         // Remember to apply modified properties
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.Space(154);
                if (GUILayout.Button("Add line", GUILayout.ExpandWidth(false)))
                {
                    AddCommentLine(1);
                }
                GUILayout.EndHorizontal();
                if (comments.WorkNegative != null)
                {
                    ScriptableObject   target          = comments;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("WorkNegative");

                    EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
                    so.ApplyModifiedProperties();                         // Remember to apply modified properties
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            if (viewIndex == 2)
            {
                //////////////
                // PERSONAL //
                //////////////
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Personal", EditorStyles.boldLabel);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.Space(154);
                if (GUILayout.Button("Add line", GUILayout.ExpandWidth(false)))
                {
                    AddCommentLine(2);
                }
                GUILayout.EndHorizontal();
                if (comments.WorkPositive != null)
                {
                    ScriptableObject   target          = comments;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("PersonalPositive");

                    EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
                    so.ApplyModifiedProperties();                         // Remember to apply modified properties
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.Space(154);
                if (GUILayout.Button("Add line", GUILayout.ExpandWidth(false)))
                {
                    AddCommentLine(3);
                }
                GUILayout.EndHorizontal();
                if (comments.WorkNegative != null)
                {
                    ScriptableObject   target          = comments;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("PersonalNegative");

                    EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
                    so.ApplyModifiedProperties();                         // Remember to apply modified properties
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            if (viewIndex == 3)
            {
                /////////////
                // OUTSIDE //
                /////////////
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Outside World", EditorStyles.boldLabel);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.Space(154);
                if (GUILayout.Button("Add line", GUILayout.ExpandWidth(false)))
                {
                    AddCommentLine(4);
                }
                GUILayout.EndHorizontal();
                if (comments.WorkPositive != null)
                {
                    ScriptableObject   target          = comments;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("OutsideWorldPositive");

                    EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
                    so.ApplyModifiedProperties();                         // Remember to apply modified properties
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                GUILayout.Space(154);
                if (GUILayout.Button("Add line", GUILayout.ExpandWidth(false)))
                {
                    AddCommentLine(5);
                }
                GUILayout.EndHorizontal();
                if (comments.WorkNegative != null)
                {
                    ScriptableObject   target          = comments;
                    SerializedObject   so              = new SerializedObject(target);
                    SerializedProperty stringsProperty = so.FindProperty("OutsideWorldNegative");

                    EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
                    so.ApplyModifiedProperties();                         // Remember to apply modified properties
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(comments);
        }
    }
Example #9
0
        static void OnPostHeaderGUI(Editor editor)
        {
            var aaSettings = AddressableAssetSettingsDefaultObject.Settings;
            var guid       = string.Empty;
            AddressableAssetEntry entry = null;

            if (editor.targets.Length > 0)
            {
                int  addressableCount = 0;
                bool foundValidAsset  = false;
                foreach (var t in editor.targets)
                {
                    string path;
                    if ((AddressableAssetUtility.GetPathAndGUIDFromTarget(t, out path, ref guid)) &&
                        (path.ToLower().Contains("assets")))
                    {
                        foundValidAsset = true;

                        if (aaSettings != null)
                        {
                            entry = aaSettings.FindAssetEntry(guid);
                            if (entry != null && !entry.IsSubAsset)
                            {
                                addressableCount++;
                            }
                        }
                    }
                }


                if (!foundValidAsset)
                {
                    return;
                }

                if (addressableCount == 0)
                {
                    if (GUILayout.Toggle(false, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), editor.targets, true);
                    }
                }
                else if (addressableCount == editor.targets.Length)
                {
                    GUILayout.BeginHorizontal();
                    if (!GUILayout.Toggle(true, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(aaSettings, editor.targets, false);
                    }

                    if (editor.targets.Length == 1 && entry != null)
                    {
                        entry.address = EditorGUILayout.DelayedTextField(entry.address, GUILayout.ExpandWidth(true));
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    if (s_ToggleMixed == null)
                    {
                        s_ToggleMixed = new GUIStyle("ToggleMixed");
                    }
                    if (GUILayout.Toggle(false, s_AddressableAssetToggleText, s_ToggleMixed, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), editor.targets, true);
                    }
                    EditorGUILayout.LabelField(addressableCount + " out of " + editor.targets.Length + " assets are addressable.");
                    GUILayout.EndHorizontal();
                }
            }
        }
        /// <summary>
        /// Draws the given <see cref="NugetPackage"/>.
        /// </summary>
        /// <param name="package">The <see cref="NugetPackage"/> to draw.</param>
        private void DrawPackage(NugetPackage package, GUIStyle packageStyle, GUIStyle contrastStyle)
        {
            IEnumerable <NugetPackage> installedPackages = NugetHelper.InstalledPackages;
            var installed = installedPackages.FirstOrDefault(p => p.Id == package.Id);

            EditorGUILayout.BeginHorizontal();
            {
                // The Unity GUI system (in the Editor) is terrible.  This probably requires some explanation.
                // Every time you use a Horizontal block, Unity appears to divide the space evenly.
                // (i.e. 2 components have half of the window width, 3 components have a third of the window width, etc)
                // GUILayoutUtility.GetRect is SUPPOSED to return a rect with the given height and width, but in the GUI layout.  It doesn't.
                // We have to use GUILayoutUtility to get SOME rect properties, but then manually calculate others.
                EditorGUILayout.BeginHorizontal();
                {
                    const int iconSize = 32;
                    int       padding  = EditorStyles.label.padding.vertical;
                    Rect      rect     = GUILayoutUtility.GetRect(iconSize, iconSize);
                    // only use GetRect's Y position.  It doesn't correctly set the width, height or X position.

                    rect.x      = padding;
                    rect.y     += padding;
                    rect.width  = iconSize;
                    rect.height = iconSize;

                    if (package.Icon != null)
                    {
                        GUI.DrawTexture(rect, package.Icon, ScaleMode.StretchToFill);
                    }
                    else
                    {
                        GUI.DrawTexture(rect, defaultIcon, ScaleMode.StretchToFill);
                    }

                    rect.x     = iconSize + 2 * padding;
                    rect.width = position.width / 2 - (iconSize + padding);
                    rect.y    -= padding; // This will leave the text aligned with the top of the image


                    EditorStyles.label.fontStyle = FontStyle.Bold;
                    EditorStyles.label.fontSize  = 16;

                    Vector2 idSize = EditorStyles.label.CalcSize(new GUIContent(package.Id));
                    rect.y += (iconSize / 2 - idSize.y / 2) + padding;
                    GUI.Label(rect, package.Id, EditorStyles.label);
                    rect.x += idSize.x;

                    EditorStyles.label.fontSize  = 10;
                    EditorStyles.label.fontStyle = FontStyle.Normal;

                    Vector2 versionSize = EditorStyles.label.CalcSize(new GUIContent(package.Version));
                    rect.y += (idSize.y - versionSize.y - padding / 2);

                    if (!string.IsNullOrEmpty(package.Authors))
                    {
                        string  authorLabel = string.Format("by {0}", package.Authors);
                        Vector2 size        = EditorStyles.label.CalcSize(new GUIContent(authorLabel));
                        GUI.Label(rect, authorLabel, EditorStyles.label);
                        rect.x += size.x;
                    }

                    if (package.DownloadCount > 0)
                    {
                        string  downloadLabel = string.Format("{0} downloads", package.DownloadCount.ToString("#,#"));
                        Vector2 size          = EditorStyles.label.CalcSize(new GUIContent(downloadLabel));
                        GUI.Label(rect, downloadLabel, EditorStyles.label);
                        rect.x += size.x;
                    }
                }

                GUILayout.FlexibleSpace();
                if (installed != null && installed.Version != package.Version)
                {
                    GUILayout.Label(string.Format("Current Version {0}", installed.Version));
                }
                GUILayout.Label(string.Format("Version {0}", package.Version));


                if (installedPackages.Contains(package))
                {
                    // This specific version is installed
                    if (GUILayout.Button("Uninstall"))
                    {
                        // TODO: Perhaps use a "mark as dirty" system instead of updating all of the data all the time?
                        NugetHelper.Uninstall(package);
                        NugetHelper.UpdateInstalledPackages();
                        UpdateUpdatePackages();
                    }
                }
                else
                {
                    if (installed != null)
                    {
                        if (installed < package)
                        {
                            // An older version is installed
                            if (GUILayout.Button("Update"))
                            {
                                NugetHelper.Update(installed, package);
                                NugetHelper.UpdateInstalledPackages();
                                UpdateUpdatePackages();
                            }
                        }
                        else if (installed > package)
                        {
                            // A newer version is installed
                            if (GUILayout.Button("Downgrade"))
                            {
                                NugetHelper.Update(installed, package);
                                NugetHelper.UpdateInstalledPackages();
                                UpdateUpdatePackages();
                            }
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Install"))
                        {
                            NugetHelper.InstallIdentifier(package);
                            AssetDatabase.Refresh();
                            NugetHelper.UpdateInstalledPackages();
                            UpdateUpdatePackages();
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical();
                {
                    // Show the package details
                    EditorStyles.label.wordWrap  = true;
                    EditorStyles.label.fontStyle = FontStyle.Normal;

                    string summary = package.Summary;
                    if (string.IsNullOrEmpty(summary))
                    {
                        summary = package.Description;
                    }

                    if (!package.Title.Equals(package.Id, StringComparison.InvariantCultureIgnoreCase))
                    {
                        summary = string.Format("{0} - {1}", package.Title, summary);
                    }

                    if (summary.Length >= 240)
                    {
                        summary = string.Format("{0}...", summary.Substring(0, 237));
                    }

                    EditorGUILayout.LabelField(summary);

                    bool   detailsFoldout;
                    string detailsFoldoutId = string.Format("{0}.{1}", package.Id, "Details");
                    if (!foldouts.TryGetValue(detailsFoldoutId, out detailsFoldout))
                    {
                        foldouts[detailsFoldoutId] = detailsFoldout;
                    }
                    detailsFoldout             = EditorGUILayout.Foldout(detailsFoldout, "Details");
                    foldouts[detailsFoldoutId] = detailsFoldout;

                    if (detailsFoldout)
                    {
                        EditorGUI.indentLevel++;
                        if (!string.IsNullOrEmpty(package.Description))
                        {
                            EditorGUILayout.LabelField("Description", EditorStyles.boldLabel);
                            EditorGUILayout.LabelField(package.Description);
                        }

                        if (!string.IsNullOrEmpty(package.ReleaseNotes))
                        {
                            EditorGUILayout.LabelField("Release Notes", EditorStyles.boldLabel);
                            EditorGUILayout.LabelField(package.ReleaseNotes);
                        }

                        // Show project URL link
                        if (!string.IsNullOrEmpty(package.ProjectUrl))
                        {
                            EditorGUILayout.LabelField("Project Url", EditorStyles.boldLabel);
                            GUILayoutLink(package.ProjectUrl);
                            GUILayout.Space(4f);
                        }


                        // Show the dependencies
                        if (package.Dependencies.Count > 0)
                        {
                            EditorStyles.label.wordWrap  = true;
                            EditorStyles.label.fontStyle = FontStyle.Italic;
                            StringBuilder builder = new StringBuilder();

                            NugetFrameworkGroup frameworkGroup = NugetHelper.GetBestDependencyFrameworkGroupForCurrentSettings(package);
                            foreach (var dependency in frameworkGroup.Dependencies)
                            {
                                builder.Append(string.Format(" {0} {1};", dependency.Id, dependency.Version));
                            }
                            EditorGUILayout.Space();
                            EditorGUILayout.LabelField(string.Format("Depends on:{0}", builder.ToString()));
                            EditorStyles.label.fontStyle = FontStyle.Normal;
                        }

                        // Create the style for putting a box around the 'Clone' button
                        var cloneButtonBoxStyle = new GUIStyle("box");
                        cloneButtonBoxStyle.stretchWidth   = false;
                        cloneButtonBoxStyle.margin.top     = 0;
                        cloneButtonBoxStyle.margin.bottom  = 0;
                        cloneButtonBoxStyle.padding.bottom = 4;

                        var normalButtonBoxStyle = new GUIStyle(cloneButtonBoxStyle);
                        normalButtonBoxStyle.normal.background = packageStyle.normal.background;

                        bool showCloneWindow = openCloneWindows.Contains(package);
                        cloneButtonBoxStyle.normal.background = showCloneWindow ? contrastStyle.normal.background : packageStyle.normal.background;

                        // Create a simillar style for the 'Clone' window
                        var cloneWindowStyle = new GUIStyle(cloneButtonBoxStyle);
                        cloneWindowStyle.padding = new RectOffset(6, 6, 2, 6);

                        // Show button bar
                        EditorGUILayout.BeginHorizontal();
                        {
                            if (package.RepositoryType == RepositoryType.Git || package.RepositoryType == RepositoryType.TfsGit)
                            {
                                if (!string.IsNullOrEmpty(package.RepositoryUrl))
                                {
                                    EditorGUILayout.BeginHorizontal(cloneButtonBoxStyle);
                                    {
                                        var cloneButtonStyle = new GUIStyle(GUI.skin.button);
                                        cloneButtonStyle.normal = showCloneWindow ? cloneButtonStyle.active : cloneButtonStyle.normal;
                                        if (GUILayout.Button("Clone", cloneButtonStyle, GUILayout.ExpandWidth(false)))
                                        {
                                            showCloneWindow = !showCloneWindow;
                                        }

                                        if (showCloneWindow)
                                        {
                                            openCloneWindows.Add(package);
                                        }
                                        else
                                        {
                                            openCloneWindows.Remove(package);
                                        }
                                    }
                                    EditorGUILayout.EndHorizontal();
                                }
                            }

                            if (!string.IsNullOrEmpty(package.LicenseUrl) && package.LicenseUrl != "http://your_license_url_here")
                            {
                                // Creaete a box around the license button to keep it alligned with Clone button
                                EditorGUILayout.BeginHorizontal(normalButtonBoxStyle);
                                // Show the license button
                                if (GUILayout.Button("View License", GUILayout.ExpandWidth(false)))
                                {
                                    Application.OpenURL(package.LicenseUrl);
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        if (showCloneWindow)
                        {
                            EditorGUILayout.BeginVertical(cloneWindowStyle);
                            {
                                // Clone latest label
                                EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(20f);
                                EditorGUILayout.LabelField("clone latest");
                                EditorGUILayout.EndHorizontal();

                                // Clone latest row
                                EditorGUILayout.BeginHorizontal();
                                {
                                    if (GUILayout.Button("Copy", GUILayout.ExpandWidth(false)))
                                    {
                                        GUI.FocusControl(package.Id + package.Version + "repoUrl");
                                        GUIUtility.systemCopyBuffer = package.RepositoryUrl;
                                    }

                                    GUI.SetNextControlName(package.Id + package.Version + "repoUrl");
                                    EditorGUILayout.TextField(package.RepositoryUrl);
                                }
                                EditorGUILayout.EndHorizontal();

                                // Clone @ commit label
                                GUILayout.Space(4f);
                                EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(20f);
                                EditorGUILayout.LabelField("clone @ commit");
                                EditorGUILayout.EndHorizontal();

                                // Clone @ commit row
                                EditorGUILayout.BeginHorizontal();
                                {
                                    // Create the three commands a user will need to run to get the repo @ the commit. Intentionally leave off the last newline for better UI appearance
                                    string commands = string.Format("git clone {0} {1} --no-checkout{2}cd {1}{2}git checkout {3}", package.RepositoryUrl, package.Id, Environment.NewLine, package.RepositoryCommit);

                                    if (GUILayout.Button("Copy", GUILayout.ExpandWidth(false)))
                                    {
                                        GUI.FocusControl(package.Id + package.Version + "commands");

                                        // Add a newline so the last command will execute when pasted to the CL
                                        GUIUtility.systemCopyBuffer = (commands + Environment.NewLine);
                                    }

                                    EditorGUILayout.BeginVertical();
                                    GUI.SetNextControlName(package.Id + package.Version + "commands");
                                    EditorGUILayout.TextArea(commands);
                                    EditorGUILayout.EndVertical();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                            EditorGUILayout.EndVertical();
                        }
                        EditorGUI.indentLevel--;
                    }

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }
Example #11
0
    void OnGUI()
    {
        if (Event.current.type == EventType.MouseDown)
        {
            if (characters != null)
            {
                LoadVIDEDialogues();
            }
        }

        //EditorUtility.ClearProgressBar();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Character Editor", EditorStyles.boldLabel);
        if (characters && (characters.allCharacters != null) && characters.allCharacters.Count > 0)
        {
            if (GUILayout.Button("Rename assets", GUILayout.ExpandWidth(false)))
            {
                RenameAllCharacterAssets();
            }
            if (GUILayout.Button("Sort character list", GUILayout.ExpandWidth(false)))
            {
                OrderCharacterList();
            }
            if (GUILayout.Button("Save all", GUILayout.ExpandWidth(false)))
            {
                Save();
            }
        }
        else
        {
            if (GUILayout.Button("New list of characters", GUILayout.ExpandWidth(false)))
            {
                CreateNewCharacterList();
            }
        }
        GUILayout.EndHorizontal();

        if (characters)
        {
            GUILayout.Space(10);
            if (GUILayout.Button("DEBUG: Populate list", GUILayout.ExpandWidth(false)))
            {
                CreateMultipleNewCharacters(20);
            }
            GUILayout.Space(20);
            GUILayout.Label("List of all characters:", EditorStyles.boldLabel);
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add a new character", GUILayout.ExpandWidth(false)))
            {
                CreateNewCharacter();
            }
            GUILayout.Space(16);
            if (GUILayout.Button("Find & add a character", GUILayout.ExpandWidth(false)))
            {
                FindCharacters();
            }
            GUILayout.Space(16);
            if (GUILayout.Button("Remove last character", GUILayout.ExpandWidth(false)))
            {
                RemoveCharacter();
            }
            GUIStyle btnR = new GUIStyle(GUI.skin.button);
            btnR.normal.textColor = Color.red;
            GUILayout.Space(16);
            if (GUILayout.Button("Remove all characters", btnR))
            {
                RemoveAllCharacters();
            }
            GUILayout.EndHorizontal();
            ScriptableObject   target          = characters;
            SerializedObject   so              = new SerializedObject(target);
            SerializedProperty stringsProperty = so.FindProperty("allCharacters");
            EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
            so.ApplyModifiedProperties();                         // Remember to apply modified properties

            if (characters.allCharacters.Count > 0)
            {
                GUILayout.Space(20);

                GUILayout.Label("Single Character Editor:", EditorStyles.boldLabel);

                GUILayout.BeginHorizontal();
                viewIndex = Mathf.Clamp(EditorGUILayout.IntField("Currently editing", viewIndex, GUILayout.ExpandWidth(false)), 1, characters.allCharacters.Count);
                GUILayout.Space(200);
                if (characters.allCharacters[viewIndex - 1])
                {
                    findCharacter = EditorGUILayout.TextField(findCharacter);
                    if (GUILayout.Button("Find (hit enter after typing)", GUILayout.ExpandWidth(false)))
                    {
                        FindCharacter(findCharacter);
                    }
                }
                GUILayout.EndHorizontal();


                //else
                //EditorGUILayout.LabelField("(Unknown - character/name not found/set)");


                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
                {
                    if (viewIndex > 1)
                    {
                        viewIndex--;
                    }
                }
                GUILayout.Space(5);
                if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
                {
                    if (viewIndex < characters.allCharacters.Count)
                    {
                        viewIndex++;
                    }
                }
                GUILayout.Space(61);
                if (GUILayout.Button("Delete this character", GUILayout.ExpandWidth(false)))
                {
                    RemoveCharacter(viewIndex - 1);
                    if (viewIndex > 1)
                    {
                        viewIndex--;
                    }
                    else
                    {
                        return;
                    }
                }
                GUILayout.EndHorizontal();

                if (characters.allCharacters[viewIndex - 1])
                {
                    GUILayout.Space(10);
                    characters.allCharacters[viewIndex - 1].characterName = EditorGUILayout.TextField("Character Name", characters.allCharacters[viewIndex - 1].characterName as string);
                    characters.allCharacters[viewIndex - 1].spawnFloor    = EditorGUILayout.IntSlider("Spawn Floor", characters.allCharacters[viewIndex - 1].spawnFloor, 0, 100);
                    //characters.allCharacters[viewIndex - 1].currentFloor = EditorGUILayout.IntSlider("Current Floor", characters.allCharacters[viewIndex - 1].currentFloor, 0, 100);
                    characters.allCharacters[viewIndex - 1].authorization          = EditorGUILayout.TextField("Authorization", characters.allCharacters[viewIndex - 1].authorization as string);
                    characters.allCharacters[viewIndex - 1].priority               = EditorGUILayout.IntField("Priority", characters.allCharacters[viewIndex - 1].priority);
                    characters.allCharacters[viewIndex - 1].infectionStageDuration = EditorGUILayout.IntField("Infection Stage Duration", characters.allCharacters[viewIndex - 1].infectionStageDuration);
                    characters.allCharacters[viewIndex - 1].animator               = EditorGUILayout.ObjectField("Animator", characters.allCharacters[viewIndex - 1].animator, typeof(RuntimeAnimatorController), true) as RuntimeAnimatorController;
                    characters.allCharacters[viewIndex - 1].isOriginallyNPC        = EditorGUILayout.Toggle("Is NPC At Start", characters.allCharacters[viewIndex - 1].isOriginallyNPC);
                    //characters.allCharacters[viewIndex - 1].isOriginallyInfected = EditorGUILayout.Toggle("Is Infected At Start", characters.allCharacters[viewIndex - 1].isOriginallyInfected);
                    characters.allCharacters[viewIndex - 1].isInteractable    = EditorGUILayout.Toggle("Is Interactable", characters.allCharacters[viewIndex - 1].isInteractable);
                    characters.allCharacters[viewIndex - 1].isInfectable      = EditorGUILayout.Toggle("Is Infectable", characters.allCharacters[viewIndex - 1].isInfectable);
                    characters.allCharacters[viewIndex - 1].isInanimateObject = EditorGUILayout.Toggle("Is Inanimate Object", characters.allCharacters[viewIndex - 1].isInanimateObject);
                    characters.allCharacters[viewIndex - 1].gender            = (CharacterEnums.Gender)EditorGUILayout.EnumPopup("Gender", characters.allCharacters[viewIndex - 1].gender);
                    //characters.allCharacters[viewIndex - 1].currentStateOfInfection = (Character.InfectionState)EditorGUILayout.EnumPopup("State Of Infection", characters.allCharacters[viewIndex - 1].currentStateOfInfection);
                    //characters.allCharacters[viewIndex - 1].currentStateOfSuspicion = (Character.SuspicionState)EditorGUILayout.EnumPopup("State Of Suspicion", characters.allCharacters[viewIndex - 1].currentStateOfSuspicion);

                    GUILayout.BeginHorizontal();
                    if (dialogues.Count > 0)
                    {
                        EditorGUI.BeginChangeCheck();
                        characters.allCharacters[viewIndex - 1].VideConversationIndex = EditorGUILayout.Popup("Assigned Dialogue", characters.allCharacters[viewIndex - 1].VideConversationIndex, dialogues.ToArray());
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (characters.allCharacters[viewIndex - 1].VideConversation != dialogues[characters.allCharacters[viewIndex - 1].VideConversationIndex])
                            {
                                characters.allCharacters[viewIndex - 1].VideConversation = dialogues[characters.allCharacters[viewIndex - 1].VideConversationIndex];
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("No saved Dialogues!");
                    }
                    GUILayout.EndHorizontal();

                    characters.allCharacters[viewIndex - 1].characterPoseSprite   = EditorGUILayout.ObjectField("Standing pose sprite", characters.allCharacters[viewIndex - 1].characterPoseSprite, typeof(Sprite), false, GUILayout.ExpandWidth(false)) as Sprite;
                    characters.allCharacters[viewIndex - 1].characterDialogSprite = EditorGUILayout.ObjectField("Dialog sprite", characters.allCharacters[viewIndex - 1].characterDialogSprite, typeof(Sprite), false, GUILayout.ExpandWidth(false)) as Sprite;

                    GUILayout.Space(25);
                }
                else
                {
                    GUILayout.Space(10);
                    EditorGUILayout.LabelField("This character seems to be uninitialized. You need to initialize it first.");
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Initialize", GUILayout.ExpandWidth(false)))
                    {
                        InitializeCharacter(viewIndex - 1);
                    }
                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                GUIStyle lr = new GUIStyle(EditorStyles.label);
                lr.normal.textColor = new Color(0.7f, 0, 0);
                GUILayout.Space(10);
                EditorGUILayout.LabelField("List of characters seems to be empty.", lr);
                EditorGUILayout.LabelField("Add new ones by clicking the 'Add a new character' button above.", lr);
                EditorGUILayout.LabelField("Or try to find them by clicking the 'Find & add a character' button.", lr);
            }
            GUILayout.EndScrollView();
        }
        else
        {
            EditorGUILayout.LabelField("No list of characters found.");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Find list of characters", GUILayout.ExpandWidth(false)))
            {
                FindCharactersList();
            }
            if (GUILayout.Button("Create a new list of characters", GUILayout.ExpandWidth(false)))
            {
                CreateNewCharacterList();
            }
            GUILayout.EndHorizontal();
        }
    }
Example #12
0
 private void Separator()
 {
     GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
 }
Example #13
0
        private void PreviewEvent(Rect previewRect, EditorEventRef selectedEvent)
        {
            GUILayout.BeginArea(previewRect);

            bool isNarrow = previewRect.width < 400;

            var style = new GUIStyle(EditorStyles.label);

            EditorStyles.label.fontStyle = FontStyle.Bold;
            EditorGUIUtility.labelWidth  = 75;

            var copyIcon = EditorGUIUtility.Load("FMOD/CopyIcon.png") as Texture;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Full Path", selectedEvent.Path, style, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(copyIcon, GUILayout.ExpandWidth(false)))
            {
                EditorGUIUtility.systemCopyBuffer = selectedEvent.Path;
            }
            EditorGUILayout.EndHorizontal();



            StringBuilder builder = new StringBuilder();

            selectedEvent.Banks.ForEach((x) => { builder.Append(Path.GetFileNameWithoutExtension(x.Path)); builder.Append(", "); });
            EditorGUILayout.LabelField("Banks", builder.ToString(0, Math.Max(0, builder.Length - 2)), style);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Panning", selectedEvent.Is3D ? "3D" : "2D", style);
            EditorGUILayout.LabelField("Oneshot", selectedEvent.IsOneShot.ToString(), style);
            if (!isNarrow)
            {
                EditorGUILayout.LabelField("Streaming", selectedEvent.IsStream.ToString(), style);
            }
            EditorGUILayout.EndHorizontal();
            if (isNarrow)
            {
                EditorGUILayout.LabelField("Streaming", selectedEvent.IsStream.ToString(), style);
            }

            EditorGUIUtility.labelWidth  = 0;
            EditorStyles.label.fontStyle = FontStyle.Normal;

            if (Event.current.type == EventType.Repaint)
            {
                var lastRect = GUILayoutUtility.GetLastRect();
                if (!isNarrow)
                {
                    previewCustomRect = new Rect(lastRect.width / 2 - 200, lastRect.yMax + 10, 400, 150);
                }
                else
                {
                    previewCustomRect = new Rect(lastRect.width / 2 - 130, lastRect.yMax + 10, 260, 150);
                }
            }

            GUI.Box(new Rect(0, previewCustomRect.yMin, previewRect.width, 1), GUIContent.none);
            GUI.Box(new Rect(0, previewCustomRect.yMax, previewRect.width, 1), GUIContent.none);

            GUILayout.BeginArea(previewCustomRect);

            Texture playOff  = EditorGUIUtility.Load("FMOD/TransportPlayButtonOff.png") as Texture;
            Texture playOn   = EditorGUIUtility.Load("FMOD/TransportPlayButtonOn.png") as Texture;
            Texture stopOff  = EditorGUIUtility.Load("FMOD/TransportStopButtonOff.png") as Texture;
            Texture stopOn   = EditorGUIUtility.Load("FMOD/TransportStopButtonOn.png") as Texture;
            Texture openIcon = EditorGUIUtility.Load("FMOD/transportOpen.png") as Texture;

            var transportButtonStyle = new GUIStyle();

            transportButtonStyle.padding.left = 4;
            transportButtonStyle.padding.top  = 10;

            var  previewState = EditorUtils.PreviewState;
            bool playing      = previewState == PreviewState.Playing;
            bool paused       = previewState == PreviewState.Paused;
            bool stopped      = previewState == PreviewState.Stopped;

            EditorGUILayout.BeginVertical();
            if (!isNarrow)
            {
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(stopped || paused ? stopOn : stopOff, transportButtonStyle, GUILayout.ExpandWidth(false)))
            {
                forceRepaint = false;
                if (paused)
                {
                    EditorUtils.PreviewStop();
                }
                if (playing)
                {
                    EditorUtils.PreviewPause();
                }
            }
            if (GUILayout.Button(playing ? playOn : playOff, transportButtonStyle, GUILayout.ExpandWidth(false)))
            {
                if (playing || stopped)
                {
                    EditorUtils.PreviewEvent(selectedEvent);
                }
                else
                {
                    EditorUtils.PreviewPause();
                }
                forceRepaint = true;
            }
            if (GUILayout.Button(new GUIContent(openIcon, "Show Event in FMOD Studio"), transportButtonStyle, GUILayout.ExpandWidth(false)))
            {
                string cmd = string.Format("studio.window.navigateTo(studio.project.lookup(\"{0}\"))", selectedEvent.Guid.ToString("b"));
                EditorUtils.SendScriptCommand(cmd);
            }


            EditorGUILayout.EndHorizontal();
            if (!isNarrow)
            {
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndVertical();

            {
                Texture circle  = EditorGUIUtility.Load("FMOD/preview.png") as Texture;
                Texture circle2 = EditorGUIUtility.Load("FMOD/previewemitter.png") as Texture;

                var originalColour = GUI.color;
                if (!selectedEvent.Is3D)
                {
                    GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.1f);
                }

                Rect rect = new Rect(isNarrow ? 120 : 150, 10, 128, 128);
                GUI.DrawTexture(rect, circle);

                Vector2 centre = rect.center;
                Rect    rect2  = new Rect(rect.center.x + eventPosition.x - 6, rect.center.y + eventPosition.y - 6, 12, 12);
                GUI.DrawTexture(rect2, circle2);

                GUI.color = originalColour;


                if (selectedEvent.Is3D && (Event.current.type == EventType.mouseDown || Event.current.type == EventType.mouseDrag) && rect.Contains(Event.current.mousePosition))
                {
                    var     newPosition = Event.current.mousePosition;
                    Vector2 delta       = (newPosition - centre);
                    float   distance    = delta.magnitude;
                    if (distance < 60)
                    {
                        eventPosition   = newPosition - rect.center;
                        previewDistance = distance / 60.0f * selectedEvent.MaxDistance;
                        delta.Normalize();
                        float angle = Mathf.Atan2(delta.y, delta.x);
                        previewOrientation = angle + Mathf.PI * 0.5f;
                    }
                    Event.current.Use();
                }

                EditorUtils.PreviewUpdatePosition(previewDistance, previewOrientation);
            }


            float   hoffset  = isNarrow ? 15 : 300;
            float   voffset  = isNarrow ? 50 : 10;
            Texture meterOn  = EditorGUIUtility.Load("FMOD/LevelMeter.png") as Texture;
            Texture meterOff = EditorGUIUtility.Load("FMOD/LevelMeterOff.png") as Texture;

            float[] metering    = EditorUtils.GetMetering();
            int     meterHeight = isNarrow ? 86 : 128;
            int     meterWidth  = (int)((128 / (float)meterOff.height) * meterOff.width);

            foreach (float rms in metering)
            {
                GUI.DrawTexture(new Rect(hoffset, voffset, meterWidth, meterHeight), meterOff);

                float db = 20.0f * Mathf.Log10(rms * Mathf.Sqrt(2.0f));
                db = Mathf.Clamp(db, -80.0f, 10.0f);
                float   visible       = 0;
                int[]   segmentPixels = new int[] { 0, 18, 38, 60, 89, 130, 187, 244, 300 };
                float[] segmentDB     = new float[] { -80.0f, -60.0f, -50.0f, -40.0f, -30.0f, -20.0f, -10.0f, 0, 10.0f };
                int     segment       = 1;
                while (segmentDB[segment] < db)
                {
                    segment++;
                }
                visible = segmentPixels[segment - 1] + ((db - segmentDB[segment - 1]) / (segmentDB[segment] - segmentDB[segment - 1])) * (segmentPixels[segment] - segmentPixels[segment - 1]);

                visible *= meterHeight / (float)meterOff.height;

                Rect levelPosRect = new Rect(hoffset, meterHeight - visible + voffset, meterWidth, visible);
                Rect levelUVRect  = new Rect(0, 0, 1.0f, visible / meterHeight);
                GUI.DrawTextureWithTexCoords(levelPosRect, meterOn, levelUVRect);
                hoffset += meterWidth + 5.0f;
            }

            GUILayout.EndArea();

            Rect paramRect = new Rect(0, previewCustomRect.yMax + 10, previewRect.width, previewRect.height - (previewCustomRect.yMax + 10));

            GUILayout.BeginArea(paramRect);

            paramScroll = GUILayout.BeginScrollView(paramScroll, false, false);
            foreach (var paramRef in selectedEvent.Parameters)
            {
                if (!previewParamValues.ContainsKey(paramRef.Name))
                {
                    previewParamValues[paramRef.Name] = paramRef.Default;
                }
                previewParamValues[paramRef.Name] = EditorGUILayout.Slider(paramRef.Name, previewParamValues[paramRef.Name], paramRef.Min, paramRef.Max);
                EditorUtils.PreviewUpdateParameter(paramRef.Name, previewParamValues[paramRef.Name]);
            }
            GUILayout.EndScrollView();

            GUILayout.EndArea();
            GUILayout.EndArea();
        }
Example #14
0
        void OnGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
            {
                // Brute force hack to stop us calling DLL functions while Unity is starting up
                // playing in editor mode and will cause us to leak system objects
                this.ShowNotification(new GUIContent("Playing In Editor Starting"));
                return;
            }

            if (!EventManager.IsValid)
            {
                this.ShowNotification(new GUIContent("No FMOD Studio banks loaded. Please check your settings."));
                return;
            }

            if (Event.current.type == EventType.Layout)
            {
                RebuildDisplayFromCache();
            }

            //if (eventStyle == null)
            {
                eventStyle = new GUIStyle(GUI.skin.button);
                eventStyle.normal.background    = null;
                eventStyle.focused.background   = null;
                eventStyle.active.background    = null;
                eventStyle.onFocused.background = null;
                eventStyle.onNormal.background  = null;
                eventStyle.onHover.background   = null;
                eventStyle.onActive.background  = null;
                eventStyle.stretchWidth         = false;
                eventStyle.padding.left         = 0;
                eventStyle.stretchHeight        = false;
                eventStyle.fixedHeight          = eventStyle.lineHeight + eventStyle.margin.top + eventStyle.margin.bottom;
                eventStyle.alignment            = TextAnchor.MiddleLeft;

                eventIcon        = EditorGUIUtility.Load("FMOD/EventIcon.png") as Texture;
                folderOpenIcon   = EditorGUIUtility.Load("FMOD/FolderIconOpen.png") as Texture;
                folderClosedIcon = EditorGUIUtility.Load("FMOD/FolderIconClosed.png") as Texture;
                searchIcon       = EditorGUIUtility.Load("FMOD/SearchIcon.png") as Texture;
                bankIcon         = EditorGUIUtility.Load("FMOD/BankIcon.png") as Texture;
                snapshotIcon     = EditorGUIUtility.Load("FMOD/SnapshotIcon.png") as Texture;
                borderIcon       = EditorGUIUtility.Load("FMOD/Border.png") as Texture2D;
            }

            if (fromInspector)
            {
                var border = new GUIStyle(GUI.skin.box);
                border.normal.background = borderIcon;
                GUI.Box(new Rect(1, 1, position.width - 1, position.height - 1), GUIContent.none, border);
            }

            // Split the window int search box, tree view, preview pane (only if full browser)
            Rect searchRect, listRect, previewRect;

            SplitWindow(out searchRect, out listRect, out previewRect);

            // Scroll the selected item in the tree view - put above the search box otherwise it will take
            // our key presses
            if (selectedItem != null && Event.current.type == EventType.keyDown)
            {
                if (Event.current.keyCode == KeyCode.UpArrow)
                {
                    if (selectedItem.Prev != null)
                    {
                        SetSelectedItem(selectedItem.Prev);

                        // make sure it's visible
                        if (selectedItem.Rect.y < treeScroll.y)
                        {
                            treeScroll.y = selectedItem.Rect.y;
                        }
                    }
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.DownArrow)
                {
                    if (selectedItem.Next != null)
                    {
                        SetSelectedItem(selectedItem.Next);
                        // make sure it's visible
                        if (selectedItem.Rect.y + selectedItem.Rect.height > treeScroll.y + listRect.height)
                        {
                            treeScroll.y += (selectedItem.Rect.y + selectedItem.Rect.height) - listRect.height;
                        }
                    }
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.RightArrow)
                {
                    selectedItem.Expanded = true;
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.LeftArrow)
                {
                    selectedItem.Expanded = false;
                    Event.current.Use();
                }
            }

            // Show the search box at the top
            GUILayout.BeginArea(searchRect);
            GUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent(searchIcon), GUILayout.ExpandWidth(false));
            GUI.SetNextControlName("SearchBox");
            searchString = EditorGUILayout.TextField(searchString);
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            if (fromInspector)
            {
                EditorGUI.FocusTextInControl("SearchBox");

                if (selectedItem != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return &&
                    !(selectedItem.EventRef == null && selectedItem.BankRef == null))
                {
                    Event.current.Use();

                    if (selectedItem.EventRef != null)
                    {
                        outputProperty.stringValue = "";
                        outputProperty.stringValue = selectedItem.EventRef.Path;
                        EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, selectedItem.EventRef.Path);
                    }
                    else
                    {
                        outputProperty.stringValue = selectedItem.BankRef.Name;
                    }
                    outputProperty.serializedObject.ApplyModifiedProperties();
                    Close();
                }
                if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape)
                {
                    Close();
                }
            }

            // Show the tree view

            Predicate <TreeItem> searchFilter = null;

            searchFilter = (x) => (x.Name.ToLower().Contains(searchString.ToLower()) || x.Children.Exists(searchFilter));

            // Check if our selected item still matches the search string
            if (selectedItem != null && !String.IsNullOrEmpty(searchString) && selectedItem.Children.Count == 0)
            {
                Predicate <TreeItem> containsSelected = null;
                containsSelected = (x) => (x == selectedItem || x.Children.Exists(containsSelected));
                Predicate <TreeItem> matchForSelected = null;
                matchForSelected = (x) => (x.Name.ToLower().Contains(searchString.ToLower()) && (x == selectedItem || x.Children.Exists(containsSelected))) || x.Children.Exists(matchForSelected);
                if (!treeItems.Exists(matchForSelected))
                {
                    SetSelectedItem(null);
                }
            }

            GUILayout.BeginArea(listRect);
            treeScroll = GUILayout.BeginScrollView(treeScroll, GUILayout.ExpandHeight(true));

            lastDrawnItem = null;
            itemCount     = 0;

            if (showEvents)
            {
                treeItems[0].Expanded = fromInspector ? true : treeItems[0].Expanded;
                ShowEventFolder(treeItems[0], searchFilter);
                ShowEventFolder(treeItems[1], searchFilter);
            }
            if (showBanks)
            {
                treeItems[2].Expanded = fromInspector ? true : treeItems[2].Expanded;
                ShowEventFolder(treeItems[2], searchFilter);
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();

            // If the standalone event browser show a preview of the selected item
            if (!fromInspector)
            {
                GUI.Box(previewRect, GUIContent.none);

                if (selectedItem != null && selectedItem.EventRef != null && selectedItem.EventRef.Path.StartsWith("event:"))
                {
                    PreviewEvent(previewRect, selectedItem.EventRef);
                }

                if (selectedItem != null && selectedItem.EventRef != null && selectedItem.EventRef.Path.StartsWith("snapshot:"))
                {
                    PreviewSnapshot(previewRect, selectedItem.EventRef);
                }

                if (selectedItem != null && selectedItem.BankRef != null)
                {
                    PreviewBank(previewRect, selectedItem.BankRef);
                }
            }
        }
    public override void OnInspectorGUI()
    {
        resourceObject.Update();

        GUI.enabled = AssetDatabase.IsOpenForEdit(this.target, StatusQueryOptions.UseCachedIfPossible);

        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = resourceUpdateModeProperty.hasMultipleDifferentValues;
        VFXUpdateMode newUpdateMode = (VFXUpdateMode)EditorGUILayout.EnumPopup(EditorGUIUtility.TrTextContent("Update Mode", "Specifies whether particles are updated using a fixed timestep (Fixed Delta Time), or in a frame-rate independent manner (Delta Time)."), (VFXUpdateMode)resourceUpdateModeProperty.intValue);

        if (EditorGUI.EndChangeCheck())
        {
            resourceUpdateModeProperty.intValue = (int)newUpdateMode;
            resourceObject.ApplyModifiedProperties();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUI.showMixedValue = cullingFlagsProperty.hasMultipleDifferentValues;
        EditorGUILayout.PrefixLabel(EditorGUIUtility.TrTextContent("Culling Flags", "Specifies how the system recomputes its bounds and simulates when off-screen."));
        EditorGUI.BeginChangeCheck();
        int newOption = EditorGUILayout.Popup(Array.IndexOf(k_CullingOptionsValue, (VFXCullingFlags)cullingFlagsProperty.intValue), k_CullingOptionsContents);

        if (EditorGUI.EndChangeCheck())
        {
            cullingFlagsProperty.intValue = (int)k_CullingOptionsValue[newOption];
            resourceObject.ApplyModifiedProperties();
        }
        EditorGUILayout.EndHorizontal();

        if (prewarmDeltaTime != null && prewarmStepCount != null)
        {
            if (!prewarmDeltaTime.hasMultipleDifferentValues && !prewarmStepCount.hasMultipleDifferentValues)
            {
                var currentDeltaTime = prewarmDeltaTime.floatValue;
                var currentStepCount = prewarmStepCount.intValue;
                var currentTotalTime = currentDeltaTime * currentStepCount;
                EditorGUI.BeginChangeCheck();
                currentTotalTime = EditorGUILayout.FloatField(EditorGUIUtility.TrTextContent("PreWarm Total Time", "Sets the time in seconds to advance the current effect to when it is initially played. "), currentTotalTime);
                if (EditorGUI.EndChangeCheck())
                {
                    if (currentStepCount <= 0)
                    {
                        prewarmStepCount.intValue = currentStepCount = 1;
                    }

                    currentDeltaTime            = currentTotalTime / currentStepCount;
                    prewarmDeltaTime.floatValue = currentDeltaTime;
                    resourceObject.ApplyModifiedProperties();
                }

                EditorGUI.BeginChangeCheck();
                currentStepCount = EditorGUILayout.IntField(EditorGUIUtility.TrTextContent("PreWarm Step Count", "Sets the number of simulation steps the prewarm should be broken down to. "), currentStepCount);
                if (EditorGUI.EndChangeCheck())
                {
                    if (currentStepCount <= 0 && currentTotalTime != 0.0f)
                    {
                        prewarmStepCount.intValue = currentStepCount = 1;
                    }

                    currentDeltaTime            = currentTotalTime == 0.0f ? 0.0f : currentTotalTime / currentStepCount;
                    prewarmDeltaTime.floatValue = currentDeltaTime;
                    prewarmStepCount.intValue   = currentStepCount;
                    resourceObject.ApplyModifiedProperties();
                }

                EditorGUI.BeginChangeCheck();
                currentDeltaTime = EditorGUILayout.FloatField(EditorGUIUtility.TrTextContent("PreWarm Delta Time", "Sets the time in seconds for each step to achieve the desired total prewarm time."), currentDeltaTime);
                if (EditorGUI.EndChangeCheck())
                {
                    if (currentDeltaTime < k_MinimalCommonDeltaTime)
                    {
                        prewarmDeltaTime.floatValue = currentDeltaTime = k_MinimalCommonDeltaTime;
                    }

                    if (currentDeltaTime > currentTotalTime)
                    {
                        currentTotalTime = currentDeltaTime;
                    }

                    if (currentTotalTime != 0.0f)
                    {
                        var candidateStepCount_A = Mathf.FloorToInt(currentTotalTime / currentDeltaTime);
                        var candidateStepCount_B = Mathf.RoundToInt(currentTotalTime / currentDeltaTime);

                        var totalTime_A = currentDeltaTime * candidateStepCount_A;
                        var totalTime_B = currentDeltaTime * candidateStepCount_B;

                        if (Mathf.Abs(totalTime_A - currentTotalTime) < Mathf.Abs(totalTime_B - currentTotalTime))
                        {
                            currentStepCount = candidateStepCount_A;
                        }
                        else
                        {
                            currentStepCount = candidateStepCount_B;
                        }

                        prewarmStepCount.intValue = currentStepCount;
                    }
                    prewarmDeltaTime.floatValue = currentDeltaTime;
                    resourceObject.ApplyModifiedProperties();
                }
            }
            else
            {
                //Multi selection case, can't resolve total time easily
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = prewarmStepCount.hasMultipleDifferentValues;
                EditorGUILayout.PropertyField(prewarmStepCount, EditorGUIUtility.TrTextContent("PreWarm Step Count", "Sets the number of simulation steps the prewarm should be broken down to."));
                EditorGUI.showMixedValue = prewarmDeltaTime.hasMultipleDifferentValues;
                EditorGUILayout.PropertyField(prewarmDeltaTime, EditorGUIUtility.TrTextContent("PreWarm Delta Time", "Sets the time in seconds for each step to achieve the desired total prewarm time."));
                if (EditorGUI.EndChangeCheck())
                {
                    if (prewarmDeltaTime.floatValue < k_MinimalCommonDeltaTime)
                    {
                        prewarmDeltaTime.floatValue = k_MinimalCommonDeltaTime;
                    }
                    resourceObject.ApplyModifiedProperties();
                }
            }
        }

        if (initialEventName != null)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = initialEventName.hasMultipleDifferentValues;
            EditorGUILayout.PropertyField(initialEventName, new GUIContent("Initial Event Name", "Sets the name of the event which triggers once the system is activated. Default: ‘OnPlay’."));
            if (EditorGUI.EndChangeCheck())
            {
                resourceObject.ApplyModifiedProperties();
            }
        }

        if (!serializedObject.isEditingMultipleObjects)
        {
            VisualEffectAsset    asset    = (VisualEffectAsset)target;
            VisualEffectResource resource = asset.GetResource();

            m_OutputContexts.Clear();
            m_OutputContexts.AddRange(resource.GetOrCreateGraph().children.OfType <IVFXSubRenderer>().OrderBy(t => t.sortPriority));

            m_ReorderableList.DoLayoutList();

            VisualEffectEditor.ShowHeader(EditorGUIUtility.TrTextContent("Shaders"), false, false);

            var shaderSources = VFXExternalShaderProcessor.allowExternalization ? resource.shaderSources : null;

            string        assetPath = AssetDatabase.GetAssetPath(asset);
            UnityObject[] objects   = AssetDatabase.LoadAllAssetsAtPath(assetPath);
            string        directory = Path.GetDirectoryName(assetPath) + "/" + VFXExternalShaderProcessor.k_ShaderDirectory + "/" + asset.name + "/";

            foreach (var shader in objects)
            {
                if (shader is Shader || shader is ComputeShader)
                {
                    GUILayout.BeginHorizontal();
                    Rect r = GUILayoutUtility.GetRect(0, 18, GUILayout.ExpandWidth(true));

                    int buttonsWidth = VFXExternalShaderProcessor.allowExternalization ? 250 : 160;


                    Rect labelR = r;
                    labelR.width -= buttonsWidth;
                    GUI.Label(labelR, shader.name);
                    int index = resource.GetShaderIndex(shader);
                    if (index >= 0)
                    {
                        if (VFXExternalShaderProcessor.allowExternalization && index < shaderSources.Length)
                        {
                            string externalPath = directory + shaderSources[index].name;
                            if (!shaderSources[index].compute)
                            {
                                externalPath = directory + shaderSources[index].name.Replace('/', '_') + VFXExternalShaderProcessor.k_ShaderExt;
                            }
                            else
                            {
                                externalPath = directory + shaderSources[index].name + VFXExternalShaderProcessor.k_ShaderExt;
                            }

                            Rect buttonRect = r;
                            buttonRect.xMin  = labelR.xMax;
                            buttonRect.width = 80;
                            labelR.width    += 80;
                            if (System.IO.File.Exists(externalPath))
                            {
                                if (GUI.Button(buttonRect, "Reveal External"))
                                {
                                    EditorUtility.RevealInFinder(externalPath);
                                }
                            }
                            else
                            {
                                if (GUI.Button(buttonRect, "Externalize"))
                                {
                                    Directory.CreateDirectory(directory);

                                    File.WriteAllText(externalPath, "//" + shaderSources[index].name + "," + index.ToString() + "\n//Don't delete the previous line or this one\n" + shaderSources[index].source);
                                }
                            }
                        }

                        Rect buttonR = r;
                        buttonR.xMin  = labelR.xMax;
                        buttonR.width = 110;
                        labelR.width += 110;
                        if (GUI.Button(buttonR, "Show Generated"))
                        {
                            resource.ShowGeneratedShaderFile(index);
                        }
                    }

                    Rect selectButtonR = r;
                    selectButtonR.xMin  = labelR.xMax;
                    selectButtonR.width = 50;
                    if (GUI.Button(selectButtonR, "Select"))
                    {
                        Selection.activeObject = shader;
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }
        GUI.enabled = false;
    }
Example #16
0
        public override void OnInspectorGUI()
        {
            var oldSkin = GUI.skin;

            serializedObject.Update();
            if (skin)
            {
                GUI.skin = skin;
            }
            GUILayout.BeginVertical("Item Collection", "window");
            GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
            GUILayout.Space(10);

            GUI.skin = oldSkin;
            base.OnInspectorGUI();
            if (skin)
            {
                GUI.skin = skin;
            }

            if (manager.itemListData)
            {
                GUILayout.BeginVertical("box");
                if (itemReferenceList.arraySize > manager.itemListData.items.Count)
                {
                    manager.items.Resize(manager.itemListData.items.Count);
                }
                GUILayout.Box("Item Collection " + manager.items.Count);
                filteredItems = manager.itemsFilter.Count > 0 ? GetItemByFilter(manager.itemListData.items, manager.itemsFilter) : manager.itemListData.items;

                if (!inAddItem && filteredItems.Count > 0 && GUILayout.Button("Add Item", EditorStyles.miniButton))
                {
                    inAddItem = true;
                }
                if (inAddItem && filteredItems.Count > 0)
                {
                    GUILayout.BeginVertical("box");
                    selectedItem = EditorGUILayout.Popup(new GUIContent("SelectItem"), selectedItem, GetItemContents(filteredItems));
                    bool isValid       = true;
                    var  indexSelected = manager.itemListData.items.IndexOf(filteredItems[selectedItem]);
                    if (manager.items.Find(i => i.id == manager.itemListData.items[indexSelected].id) != null)
                    {
                        isValid = false;
                        EditorGUILayout.HelpBox("This item already exist", MessageType.Error);
                    }
                    GUILayout.BeginHorizontal();

                    if (isValid && GUILayout.Button("Add", EditorStyles.miniButton))
                    {
                        itemReferenceList.arraySize++;
                        itemReferenceList.GetArrayElementAtIndex(itemReferenceList.arraySize - 1).FindPropertyRelative("id").intValue     = manager.itemListData.items[indexSelected].id;
                        itemReferenceList.GetArrayElementAtIndex(itemReferenceList.arraySize - 1).FindPropertyRelative("amount").intValue = 1;
                        EditorUtility.SetDirty(manager);
                        serializedObject.ApplyModifiedProperties();
                        inAddItem = false;
                    }
                    if (GUILayout.Button("Cancel", EditorStyles.miniButton))
                    {
                        inAddItem = false;
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }

                GUIStyle boxStyle = new GUIStyle(GUI.skin.box);
                scroll = GUILayout.BeginScrollView(scroll, GUILayout.MinHeight(200), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
                for (int i = 0; i < manager.items.Count; i++)
                {
                    var item = manager.itemListData.items.Find(t => t.id.Equals(manager.items[i].id));
                    if (item)
                    {
                        GUILayout.BeginVertical("box");
                        GUILayout.BeginHorizontal();
                        GUILayout.BeginHorizontal();

                        var rect = GUILayoutUtility.GetRect(50, 50);

                        if (item.icon != null)
                        {
                            DrawTextureGUI(rect, item.icon, new Vector2(50, 50));
                        }

                        var name    = " ID " + item.id.ToString("00") + "\n - " + item.name + "\n - " + item.type.ToString();
                        var content = new GUIContent(name, null, "Click to Open");
                        GUILayout.Label(content, EditorStyles.miniLabel);
                        GUILayout.BeginVertical("box");
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Auto Equip", EditorStyles.miniLabel);
                        manager.items[i].autoEquip = EditorGUILayout.Toggle("", manager.items[i].autoEquip, GUILayout.Width(30));
                        if (manager.items[i].autoEquip)
                        {
                            GUILayout.Label("IndexArea", EditorStyles.miniLabel);
                            manager.items[i].indexArea = EditorGUILayout.IntField("", manager.items[i].indexArea, GUILayout.Width(30));
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Amount", EditorStyles.miniLabel);
                        manager.items[i].amount = EditorGUILayout.IntField(manager.items[i].amount, GUILayout.Width(30));

                        if (manager.items[i].amount < 1)
                        {
                            manager.items[i].amount = 1;
                        }

                        GUILayout.EndHorizontal();
                        if (item.attributes.Count > 0)
                        {
                            manager.items[i].changeAttributes = GUILayout.Toggle(manager.items[i].changeAttributes, new GUIContent("Change Attributes", "This is a override of the original item attributes"), EditorStyles.miniButton, GUILayout.ExpandWidth(true));
                        }
                        GUILayout.EndVertical();

                        GUILayout.EndHorizontal();

                        if (GUILayout.Button("x", GUILayout.Width(25), GUILayout.Height(25)))
                        {
                            itemReferenceList.DeleteArrayElementAtIndex(i);
                            EditorUtility.SetDirty(target);
                            serializedObject.ApplyModifiedProperties();
                            break;
                        }

                        GUILayout.EndHorizontal();

                        Color backgroundColor = GUI.backgroundColor;
                        GUI.backgroundColor = Color.clear;
                        var _rec = GUILayoutUtility.GetLastRect();
                        _rec.width -= 100;

                        EditorGUIUtility.AddCursorRect(_rec, MouseCursor.Link);

                        if (GUI.Button(_rec, ""))
                        {
                            if (manager.itemListData.inEdition)
                            {
                                if (vItemListWindow.Instance != null)
                                {
                                    vItemListWindow.SetCurrentSelectedItem(manager.itemListData.items.IndexOf(item));
                                }
                                else
                                {
                                    vItemListWindow.CreateWindow(manager.itemListData, manager.itemListData.items.IndexOf(item));
                                }
                            }
                            else
                            {
                                vItemListWindow.CreateWindow(manager.itemListData, manager.itemListData.items.IndexOf(item));
                            }
                        }
                        GUILayout.Space(7);
                        GUI.backgroundColor = backgroundColor;
                        if (item.attributes != null && item.attributes.Count > 0)
                        {
                            if (manager.items[i].changeAttributes)
                            {
                                if (GUILayout.Button("Reset", EditorStyles.miniButton))
                                {
                                    manager.items[i].attributes = null;
                                }
                                if (manager.items[i].attributes == null)
                                {
                                    manager.items[i].attributes = item.attributes.CopyAsNew();
                                }
                                else if (manager.items[i].attributes.Count != item.attributes.Count)
                                {
                                    manager.items[i].attributes = item.attributes.CopyAsNew();
                                }
                                else
                                {
                                    for (int a = 0; a < manager.items[i].attributes.Count; a++)
                                    {
                                        GUILayout.BeginHorizontal();
                                        GUILayout.Label(manager.items[i].attributes[a].name.ToString());
                                        manager.items[i].attributes[a].value = EditorGUILayout.IntField(manager.items[i].attributes[a].value, GUILayout.MaxWidth(60));
                                        GUILayout.EndHorizontal();
                                    }
                                }
                            }
                        }

                        GUILayout.EndVertical();
                    }
                    else
                    {
                        itemReferenceList.DeleteArrayElementAtIndex(i);
                        EditorUtility.SetDirty(manager);
                        serializedObject.ApplyModifiedProperties();
                        break;
                    }
                }
                GUILayout.EndScrollView();
                GUI.skin.box = boxStyle;

                GUILayout.EndVertical();
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(manager);
                    serializedObject.ApplyModifiedProperties();
                }
            }
            GUILayout.EndVertical();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
            serializedObject.ApplyModifiedProperties();
            GUI.skin = oldSkin;
        }
Example #17
0
	void OnGUI () {
		
		#region fonts variables
		var bold = new GUIStyle ("label");
		var boldFold = new GUIStyle ("foldout");
		bold.fontStyle = FontStyle.Bold;
		bold.fontSize = 14;
		boldFold.fontStyle = FontStyle.Bold;
		var Slim = new GUIStyle ("label");
		Slim.fontStyle = FontStyle.Normal;
		Slim.fontSize = 10;	
		var style = new GUIStyle ("label");
		style.wordWrap = true;
		#endregion fonts variables
		
		using (new Horizontal()) {
			GUILayout.Label ( "Races List", "toolbarbutton", GUILayout.ExpandWidth (true));
		}
		tmpObj = (Selection.activeObject as GameObject);
		if ( Selection.activeObject && Selection.activeObject.GetType().ToString() == "DKRaceData"){ 
			GUI.color = Color.yellow;
			GUILayout.Label ( "Selection is a Race. Select a Slot or an Overlay.", GUILayout.ExpandWidth (false));
		
		}
		GUI.color = Color.white;
		if ( EditorVariables.AutoDetLib == false 
		    && Selection.activeObject
		    && Selection.activeObject.GetType().ToString() != "DKRaceData"
		    && ( Selection.activeObject.GetType().ToString() == "DKSlotData" 
		    || Selection.activeObject.GetType().ToString() == "DKOverlayData"
		    || ( tmpObj && tmpObj.GetComponent<DK_SlotsAnatomyElement>() != null)))
		{
			SelectedElemObj =  ( Selection.activeObject as GameObject);
			using (new Horizontal()) {
				GUILayout.Label ( "Element :", GUILayout.ExpandWidth (false));
				if ( Selection.activeObject.GetType().ToString() == "DKSlotData" ) {
					SelectedElemName = Selection.activeObject.name;
					SelectedElemType = "DKSlotData";
				}
				else
				if ( Selection.activeObject.GetType().ToString() == "DKOverlayData" ) {
					SelectedElemName = Selection.activeObject.name;
					SelectedElemType = "DKOverlayData";
				}
				else{

					if ( tmpObj.GetComponent<DK_SlotsAnatomyElement>() != null ) {
						SelectedElemName = Selection.activeObject.name;
						SelectedElemType = "Anatomy Part";
					}
				}
				GUILayout.Label ( SelectedElemName, GUILayout.Width (120));
				GUILayout.Label ( "Type :", GUILayout.ExpandWidth (false));
				GUILayout.Label ( SelectedElemType, GUILayout.Width (120));
			}
		
			using (new Horizontal()) {
				GUILayout.Label ( "Element's Races List", "toolbarbutton", GUILayout.ExpandWidth (true));
			}
			// Slots Only
			if ( (Selection.activeObject.GetType().ToString() == "DKSlotData")){
				DKSlotData _SlotData = (Selection.activeObject as DKSlotData);
				// clear
				using (new Horizontal()) {
					if ( GUILayout.Button ( "clear Element's list",  GUILayout.ExpandWidth (true))) {
						_SlotData.Race.Clear();
					}
					if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
						RaceDataList.Clear();
					}
					if ( RaceDataList.Count != 0 
						&& _SlotData.Race.Count == 00 
						&& GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
					{
						if ( RaceDataList.Count != 0 && _SlotData.Race.Count == 00 ) _SlotData.Race = RaceDataList;
					}
				}
				for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
					if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
						
						
					}
					else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
				}	
				using (new Horizontal()) {
					if (_SlotData.Race.Count > 0 )using (new ScrollView(ref scroll1)) 
					{
							
						for(int i = 0; i < _SlotData.Race.Count; i ++){
							using (new Horizontal()) {
								GUI.color = new Color (0.9f, 0.5f, 0.5f);
								if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_SlotData.Race.Remove(_SlotData.Race[i]);
									EditorUtility.SetDirty(_SlotData);
									AssetDatabase.SaveAssets();
								}
								GUI.color = Color.white;
								if ( i < _SlotData.Race.Count ) if ( GUILayout.Button ( _SlotData.Race[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}

					if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
					{
							
						for(int i = 0; i < RaceDataList.Count; i ++){
							using (new Horizontal()) {
								if ( _SlotData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
								if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_SlotData.Race.Add(RaceDataList[i]);
									EditorUtility.SetDirty(_SlotData);
									AssetDatabase.SaveAssets();
								}
								if ( _SlotData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = Color.white;
								if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}
				}
			}
			// Overlays Only
			if ( (Selection.activeObject.GetType().ToString() == "DKOverlayData")){
				DKOverlayData _DKOverlayData = (Selection.activeObject as DKOverlayData);
				// clear
				using (new Horizontal()) {
					if ( GUILayout.Button ( "clear Element's list",  GUILayout.ExpandWidth (true))) {
						_DKOverlayData.Race.Clear();
					}
					if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
						RaceDataList.Clear();
					}
					if ( RaceDataList.Count != 0 
						&& _DKOverlayData.Race.Count == 00 
						&& GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
					{
						if ( RaceDataList.Count != 0 && _DKOverlayData.Race.Count == 00 ) _DKOverlayData.Race = RaceDataList;
					}
				}
				for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
					if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
						
						
					}
					else
					 RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
				}	
				using (new Horizontal()) {
					if (_DKOverlayData.Race.Count > 0 )using (new ScrollView(ref scroll1)) 
					{
							
						for(int i = 0; i < _DKOverlayData.Race.Count; i ++){
							using (new Horizontal()) {
								GUI.color = new Color (0.9f, 0.5f, 0.5f);
								if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_DKOverlayData.Race.Remove(_DKOverlayData.Race[i]);
									EditorUtility.SetDirty(_DKOverlayData);
									AssetDatabase.SaveAssets();
								}
								GUI.color = Color.white;
								if ( i < _DKOverlayData.Race.Count ) if ( GUILayout.Button ( _DKOverlayData.Race[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}
					if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
					{
							
						for(int i = 0; i < RaceDataList.Count; i ++){
							using (new Horizontal()) {
								if ( _DKOverlayData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
								if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_DKOverlayData.Race.Add(RaceDataList[i]);
									EditorUtility.SetDirty(_DKOverlayData);
									AssetDatabase.SaveAssets();
								}
								if ( _DKOverlayData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = Color.white;
								if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}
				}
			}
		}
		// Anatomy Only
		if ( EditorVariables.AutoDetLib == false && Selection.activeObject as GameObject && ((Selection.activeObject as GameObject).GetComponent<DK_Race>() != null)){
			DK_Race _DK_Race = (Selection.activeObject as GameObject).GetComponent<DK_Race>();

			// clear
			using (new Horizontal()) {
				if ( GUILayout.Button ( "clear Element's list",  GUILayout.ExpandWidth (true))) {
					_DK_Race.Race.Clear();
				}
				if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
					RaceDataList.Clear();
				}
				if ( RaceDataList.Count != 0 
					&& _DK_Race.Race.Count == 00 
					&& GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
				{
					if ( RaceDataList.Count != 0 && _DK_Race.Race.Count == 00 ) _DK_Race.Race = RaceDataList;
				}
			}
			for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
				if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
					
					
				}
				else
				 RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
			}	
			using (new Horizontal()) {
				if (_DK_Race.Race.Count > 0 )using (new ScrollView(ref scroll1)) 
				{
						
					for(int i = 0; i < _DK_Race.Race.Count; i ++){
						using (new Horizontal()) {
							GUI.color = new Color (0.9f, 0.5f, 0.5f);
							if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
								_DK_Race.Race.Remove(_DK_Race.Race[i]);
								EditorUtility.SetDirty(_DK_Race);
								AssetDatabase.SaveAssets();
							}
							GUI.color = Color.white;
							if ( i < _DK_Race.Race.Count ) if ( GUILayout.Button ( _DK_Race.Race[i], Slim, GUILayout.ExpandWidth (true))) {
								
							}
						}
					}
				}
				if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
				{
						
					for(int i = 0; i < RaceDataList.Count; i ++){
						using (new Horizontal()) {
							if ( _DK_Race.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
							if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
								_DK_Race.Race.Add(RaceDataList[i]);
								EditorUtility.SetDirty(_DK_Race);
								AssetDatabase.SaveAssets();
							}
							if ( _DK_Race.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = Color.white;
							if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
								
							}
						}
					}
				}
			}
		}
		// AutoDetectLib Only
		if ( EditorVariables.AutoDetLib == true ) {
			GUILayout.Label("AutoDetect Process Race's Section", GUILayout.ExpandWidth (true));
			if ( GUILayout.Button ( "Done",  GUILayout.ExpandWidth (true))) {
				EditorVariables.NewRaceName = "";
				for(int i = 0; i < EditorVariables.RaceToApplyList.Count; i ++){
					EditorVariables.NewRaceName = EditorVariables.NewRaceName+" -"+EditorVariables.RaceToApplyList[i];
				}
				this.Close();
			}
			// clear
			try{
			using (new Horizontal()) {
				if ( GUILayout.Button ( "clear Destination's list",  GUILayout.ExpandWidth (true))) {
				EditorVariables.RaceToApplyList.Clear();
				}
				if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
					RaceDataList.Clear();
				}
				if ( RaceDataList.Count != 0 
			 	   && EditorVariables.RaceToApplyList.Count == 00 
				    && GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
				{
				if ( RaceDataList.Count != 0 && EditorVariables.RaceToApplyList.Count == 00 ) EditorVariables.RaceToApplyList = RaceDataList;
				}
			}
			}catch(ArgumentException){}
			for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
				if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
					
				}
				else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
			}	
			using (new Horizontal()) {
			
				if (EditorVariables.RaceToApplyList.Count > 0 )using (new ScrollView(ref scroll1)) 
			
				{
					for(int i = 0; i < EditorVariables.RaceToApplyList.Count; i ++){
						using (new Horizontal()) {
							GUI.color = new Color (0.9f, 0.5f, 0.5f);
							if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
							EditorVariables.RaceToApplyList.Remove(EditorVariables.RaceToApplyList[i]);

							}
							GUI.color = Color.white;
						if ( i < EditorVariables.RaceToApplyList.Count ) if ( GUILayout.Button ( EditorVariables.RaceToApplyList[i], Slim, GUILayout.ExpandWidth (true))) {
								
							}
						}
					}
				}
				if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
				{
					for(int i = 0; i < RaceDataList.Count; i ++){
						using (new Horizontal()) {
							if ( EditorVariables.RaceToApplyList.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
							if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									EditorVariables.RaceToApplyList.Add(RaceDataList[i]);
							}
							if ( EditorVariables.RaceToApplyList.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = Color.white;
							if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
							
							}
						}
					}
				}
			}
		}
	}
Example #18
0
        public static void DrawMeshTerrainDropZone(DropZoneType dropZoneType, MeshTerrain meshTerrain, ref Boolean addedItem)
        {
            Event evt = Event.current;
            Texture2D iconTexture = GetDropZoneIconTexture(dropZoneType);

            Rect dropArea = GUILayoutUtility.GetRect(iconTexture.width, iconTexture.height, GUILayout.ExpandWidth(false));
            GUILayoutUtility.GetRect(5, iconTexture.height, GUILayout.ExpandWidth(false));
            EditorGUI.DrawPreviewTexture(dropArea, iconTexture);

            switch (evt.type)
            {
                case EventType.DragUpdated:
                case EventType.DragPerform:

                    if (!dropArea.Contains(evt.mousePosition))
                    {
                        return;
                    }

                    bool hasType = HasDropComponentType(DragAndDrop.objectReferences, dropZoneType);
                    if (!hasType) return;

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                    if (evt.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();

                        foreach (Object draggedObject in DragAndDrop.objectReferences)
                        {
                            GameObject droppedgo;
                            switch (dropZoneType)
                            {
                                case DropZoneType.Terrain:
                                    droppedgo = draggedObject as GameObject;
                                    if (!droppedgo) break;
                                    addedItem = true;
                                    meshTerrain.AddTerrain(droppedgo, TerrainSourceID.TerrainSourceID1);
                                    break;
                                case DropZoneType.MeshRenderer:
                                    droppedgo = draggedObject as GameObject;
                                    if (!droppedgo) break;
                                    addedItem = true;
                                    meshTerrain.AddMeshRenderer(droppedgo, TerrainSourceID.TerrainSourceID1);
                                    break;
                            }
                        }
                    }
                    break;
            }
        }
        private void LoadStyles()
        {
            if (stylesLoaded)
            {
                return;
            }

            layerHeight = GUILayout.Height(EditorGUIUtility.singleLineHeight + 5);
            noExpandW   = GUILayout.ExpandWidth(false);
            bigButton   = GUILayout.Height(30);
            icnFolder   = EditorGUIUtility.FindTexture("Folder Icon");
            icnTexture  = EditorGUIUtility.FindTexture("Texture Icon");

            styleHeader = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter,
                fontStyle = FontStyle.Bold
            };

            var tempStyle = GUI.skin.FindStyle("EyeDropperHorizontalLine");

            styleLayerEntry = new GUIStyle(GUI.skin.box)
            {
                margin        = new RectOffset(0, 0, 0, 0),
                padding       = new RectOffset(0, 0, 0, 0),
                contentOffset = new Vector2(0, 0),
                normal        = new GUIStyleState()
                {
                    background = tempStyle.normal.background
                }
            };

            tempStyle = GUI.skin.FindStyle("HelpBox");

            styleLayerSelected = new GUIStyle(GUI.skin.box)
            {
                margin        = new RectOffset(0, 0, 0, 0),
                padding       = new RectOffset(0, 0, 0, 0),
                contentOffset = new Vector2(0, 0),
                normal        = new GUIStyleState()
                {
                    background = tempStyle.normal.background
                }
            };

            styleLoader = new GUIStyle(GUI.skin.FindStyle("ObjectFieldThumb"))
            {
                margin       = new RectOffset(5, 5, 5, 5),
                padding      = new RectOffset(2, 2, 2, 2),
                alignment    = TextAnchor.MiddleCenter,
                fixedHeight  = 100,
                stretchWidth = true
            };

            styleLoadBoxEmpty = new GUIStyle()
            {
                padding   = new RectOffset(5, 5, 5, 5),
                alignment = TextAnchor.MiddleCenter,
                wordWrap  = true
            };

            styleBoldFoldout = new GUIStyle(EditorStyles.foldout)
            {
                fontStyle = FontStyle.Bold
            };

            // XXX: VisibilityToggle style is not exists in Unity 2018.3
#if UNITY_2018_3_OR_NEWER
            tempStyle = new GUIStyle()
            {
                normal = new GUIStyleState()
                {
                    background = EditorGUIUtility.Load("Icons/animationvisibilitytoggleoff.png") as Texture2D
                },
                onNormal = new GUIStyleState()
                {
                    background = EditorGUIUtility.Load("Icons/animationvisibilitytoggleon.png") as Texture2D
                },
                fixedHeight   = 11, fixedWidth = 13,
                border        = new RectOffset(2, 2, 2, 2), overflow = new RectOffset(-1, 1, -2, 2), padding = new RectOffset(3, 3, 3, 3), richText = false,
                stretchHeight = false, stretchWidth = false,
            };
#else
            tempStyle = GUI.skin.FindStyle("VisibilityToggle");
#endif

            styleVisOff = new GUIStyle(tempStyle)
            {
                margin = new RectOffset(10, 10, 3, 3)
            };
            styleVisOn = new GUIStyle(tempStyle)
            {
                normal = new GUIStyleState()
                {
                    background = tempStyle.onNormal.background
                },
                margin = new RectOffset(10, 10, 3, 3)
            };

            styleToolbar    = GUI.skin.FindStyle("Toolbar");
            styleToolSearch = GUI.skin.FindStyle("ToolbarSeachTextField");
            styleToolCancel = GUI.skin.FindStyle("ToolbarSeachCancelButton");

            stylesLoaded = true;
        }
Example #20
0
        public static void DrawVegetationItemDropZone(DropZoneType dropZoneType, VegetationPackagePro vegetationPackage, ref Boolean addedItem)
        {
            Event evt = Event.current;

            Type selectedType = GetDropZoneSystemType(dropZoneType);
            Texture2D iconTexture = GetDropZoneIconTexture(dropZoneType);

            Rect dropArea = GUILayoutUtility.GetRect(iconTexture.width, iconTexture.height, GUILayout.ExpandWidth(false));
            GUILayoutUtility.GetRect(5, iconTexture.height, GUILayout.ExpandWidth(false));
            EditorGUI.DrawPreviewTexture(dropArea, iconTexture);

            switch (evt.type)
            {
                case EventType.DragUpdated:
                case EventType.DragPerform:

                    if (!dropArea.Contains(evt.mousePosition))
                    {
                        return;
                    }

                    bool hasType = HasDropType(DragAndDrop.objectReferences, selectedType);
                    if (!hasType) return;

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                    if (evt.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();

                        foreach (Object draggedObject in DragAndDrop.objectReferences)
                        {
                            if (draggedObject.GetType() == selectedType)
                            {
                                switch (dropZoneType)
                                {
                                    case DropZoneType.GrassTexture:
                                        vegetationPackage.AddVegetationItem(draggedObject as Texture2D, VegetationType.Grass);
                                        break;
                                    case DropZoneType.PlantTexture:
                                        vegetationPackage.AddVegetationItem(draggedObject as Texture2D, VegetationType.Plant);
                                        break;
                                    case DropZoneType.GrassPrefab:
                                        vegetationPackage.AddVegetationItem(draggedObject as GameObject, VegetationType.Grass);
                                        break;
                                    case DropZoneType.PlantPrefab:
                                        vegetationPackage.AddVegetationItem(draggedObject as GameObject, VegetationType.Plant);
                                        break;
                                    case DropZoneType.TreePrefab:
                                        vegetationPackage.AddVegetationItem(draggedObject as GameObject, VegetationType.Tree);
                                        break;
                                    case DropZoneType.ObjectPrefab:
                                        vegetationPackage.AddVegetationItem(draggedObject as GameObject, VegetationType.Objects);
                                        break;
                                    case DropZoneType.LargeObjectPrefab:
                                        vegetationPackage.AddVegetationItem(draggedObject as GameObject, VegetationType.LargeObjects);
                                        break;
                                }
                                addedItem = true;
                            }
                        }
                    }
                    break;
            }

        }
        protected void doWindow(int windowID)
        {
            if (left_bold_label == null)
            {
                left_bold_label           = new GUIStyle(GUI.skin.label);
                left_bold_label.fontStyle = FontStyle.Bold;
                left_bold_label.font      = PluginHelper.MainFont;
            }

            if (right_bold_label == null)
            {
                right_bold_label           = new GUIStyle(GUI.skin.label);
                right_bold_label.fontStyle = FontStyle.Bold;
                right_bold_label.font      = PluginHelper.MainFont;
                right_bold_label.alignment = TextAnchor.MiddleRight;
            }

            if (green_label == null)
            {
                green_label = new GUIStyle(GUI.skin.label);
                green_label.normal.textColor = resource_name == ResourceManager.FNRESOURCE_WASTEHEAT ? Color.red : Color.green;
                green_label.font             = PluginHelper.MainFont;
                green_label.alignment        = TextAnchor.MiddleRight;
            }

            if (red_label == null)
            {
                red_label = new GUIStyle(GUI.skin.label);
                red_label.normal.textColor = resource_name == ResourceManager.FNRESOURCE_WASTEHEAT ? Color.green : Color.red;
                red_label.font             = PluginHelper.MainFont;
                red_label.alignment        = TextAnchor.MiddleRight;
            }

            if (left_aligned_label == null)
            {
                left_aligned_label           = new GUIStyle(GUI.skin.label);
                left_aligned_label.fontStyle = FontStyle.Normal;
                left_aligned_label.font      = PluginHelper.MainFont;
            }

            if (right_aligned_label == null)
            {
                right_aligned_label           = new GUIStyle(GUI.skin.label);
                right_aligned_label.fontStyle = FontStyle.Normal;
                right_aligned_label.font      = PluginHelper.MainFont;
                right_aligned_label.alignment = TextAnchor.MiddleRight;
            }

            if (render_window && GUI.Button(new Rect(windowPosition.width - 20, 2, 18, 18), "x"))
            {
                render_window = false;
            }

            GUILayout.Space(2);
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Theoretical Supply", left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(stored_stable_supply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Current Supply", left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(stored_supply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            if (resource_name == ResourceManager.FNRESOURCE_MEGAJOULES)
            {
                var stored_supply_percentage = stored_supply != 0 ? stored_total_power_supplied / stored_supply * 100 : 0;

                GUILayout.BeginHorizontal();
                GUILayout.Label("Current Distribution", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label(stored_supply_percentage.ToString("0.000") + "%", right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Power Demand", left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(stored_resource_demand), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            double new_power_supply       = getOverproduction();
            double net_utilisation_supply = getDemandStableSupply();

            GUIStyle net_poer_style    = new_power_supply < -0.001 ? red_label : green_label;
            GUIStyle utilisation_style = net_utilisation_supply > 1.001 ? red_label : green_label;

            GUILayout.BeginHorizontal();
            var new_power_label = (resource_name == ResourceManager.FNRESOURCE_WASTEHEAT) ? "Net Change" : "Net Power";

            GUILayout.Label(new_power_label, left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(new_power_supply), net_poer_style, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            if (!double.IsNaN(net_utilisation_supply) && !double.IsInfinity(net_utilisation_supply))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Utilisation", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label((net_utilisation_supply).ToString("P3"), utilisation_style, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
                GUILayout.EndHorizontal();
            }

            if (power_supply_list_archive != null)
            {
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Producer Component", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label("Supply", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.Label("Max", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.EndHorizontal();

                var groupedPowerSupply = power_supply_list_archive.GroupBy(m => m.Key.getResourceManagerDisplayName());

                foreach (var group in groupedPowerSupply)
                {
                    var sumOfCurrentSupply = group.Sum(m => m.Value.averageSupply);
                    var sumOfMaximumSupply = group.Sum(m => m.Value.maximumSupply);

                    // skip anything with less then 0.00 KW
                    if (sumOfCurrentSupply < 0.00005)
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    string name  = group.Key;
                    var    count = group.Count();
                    if (count > 1)
                    {
                        name = count + " " + name;
                    }

                    GUILayout.Label(name, left_aligned_label, GUILayout.ExpandWidth(true));
                    GUILayout.Label(getPowerFormatString(sumOfCurrentSupply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                    GUILayout.Label(getPowerFormatString(sumOfMaximumSupply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                    GUILayout.EndHorizontal();
                }
            }

            if (power_draw_list_archive != null)
            {
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Consumer Component", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label("Demand", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.Label("Rank", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(priorityWidth));
                GUILayout.EndHorizontal();

                var groupedPowerDraws = power_draw_list_archive.GroupBy(m => m.Key.getResourceManagerDisplayName());

                foreach (var group in groupedPowerDraws)
                {
                    var sumOfPowerDraw         = group.Sum(m => m.Value.Power_draw);
                    var sumOfPowerConsume      = group.Sum(m => m.Value.Power_consume);
                    var sumOfConsumePercentage = sumOfPowerDraw > 0 ? sumOfPowerConsume / sumOfPowerDraw * 100 : 0;

                    GUILayout.BeginHorizontal();

                    string name  = group.Key;
                    var    count = group.Count();
                    if (count > 1)
                    {
                        name = count + " " + name;
                    }
                    if (resource_name == ResourceManager.FNRESOURCE_MEGAJOULES && sumOfConsumePercentage < 99.5)
                    {
                        name = name + " " + sumOfConsumePercentage.ToString("0") + "%";
                    }

                    GUILayout.Label(name, left_aligned_label, GUILayout.ExpandWidth(true));

                    GUILayout.Label(getPowerFormatString(sumOfPowerDraw), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                    GUILayout.Label(group.First().Key.getPowerPriority().ToString(), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(priorityWidth));
                    GUILayout.EndHorizontal();
                }
            }

            if (resource_name == ResourceManager.FNRESOURCE_MEGAJOULES)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("DC Electrical System", left_aligned_label, GUILayout.ExpandWidth(true));
                GUILayout.Label(getPowerFormatString(stored_charge_demand), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.Label("0", right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(priorityWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Example #22
0
        private void OnGUI()
        {
            #region --- STYLES ---

            var mainTitleStyle = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter,
                fontStyle = FontStyle.Bold,
                fontSize  = 12
            };

            var titleStyle = new GUIStyle(GUI.skin.label)
            {
                fontStyle = FontStyle.Bold,
                fontSize  = 11
            };

            var titleStyleCenter = new GUIStyle(GUI.skin.label)
            {
                fontStyle = FontStyle.Bold,
                alignment = TextAnchor.MiddleCenter,
                fontSize  = 11
            };

            var labelStyle = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            };

            var targetButtonStyle = new GUIStyle(GUI.skin.button)
            {
                fixedWidth = 100
            };

            #endregion

            if (_selectedBrain == null)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(C.DEBUG_NO_AIBRAIN_COMPONENT, MessageType.Info);
            }
            else if (!Application.isPlaying)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(C.DEBUG_APPLICATION_NOT_PLAYING, MessageType.Warning);
            }
            else if (!_selectedBrain.gameObject.activeInHierarchy)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(C.DEBUG_GAMEOBJECT_DISABLED, MessageType.Warning);
            }
            else
            {
                EditorGUILayout.BeginVertical();

                _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.ExpandWidth(true));

                #region --- HEADER ---

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(C.DEBUG_SELECTED_BRAIN_LABEL + _selectedGameObject.name, mainTitleStyle, null);

                var label = C.DEBUG_BRAIN_IS_LABEL;
                label += _selectedBrain.BrainActive
                    ? C.DEBUG_ACTIVE_LABEL
                    : C.DEBUG_INACTIVE_LABEL;

                label += " | ";
                label += _selectedBrain.Target == null ? C.DEBUG_TARGET_NULL_LABEL : C.DEBUG_TARGET_LABEL + ": " + _selectedBrain.Target.name;
                EditorGUILayout.LabelField(label, labelStyle, null);

                #endregion

                #region --- STATE TRACKING --

                _previousStateName = _currentStateName == _selectedBrain.CurrentState.StateName
                    ? _previousStateName
                    : _currentStateName;
                _currentStateName = _selectedBrain.CurrentState.StateName;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical(GUI.skin.box);

                label = C.DEBUG_PREVIOUS_STATE_LABEL;
                EditorGUILayout.LabelField(label, titleStyleCenter, null);
                label = _previousStateName;
                EditorGUILayout.LabelField(label, labelStyle, null);
                label = C.DEBUG_TIME_IN_STATE_LABEL + ": " + _selectedBrain.TimeInPreviousState.ToString("0.##");
                EditorGUILayout.LabelField(label, labelStyle, null);

                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical(GUI.skin.box);

                label = C.DEBUG_CURRENT_STATE_LABEL;
                EditorGUILayout.LabelField(label, titleStyleCenter, null);
                label = _currentStateName;
                EditorGUILayout.LabelField(label, labelStyle, null);
                label = C.DEBUG_TIME_IN_STATE_LABEL + ": " + _selectedBrain.TimeInThisState.ToString("0.##");
                EditorGUILayout.LabelField(label, labelStyle, null);

                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();

                #endregion


                #region --- ACTIONS ---

                var ar = (from action in _actionList where action != null select action.GetType().Name).ToArray();
                label = C.DEBUG_PERFORMING_LABEL + ": " + string.Join(", ", ar);

                EditorGUILayout.LabelField(label, labelStyle, null);

                #endregion

                EditorGUILayout.Space();

                #region --- STATE TRANSITIONS ---

                label = C.DEBUG_STATE_TRANSITIONS_LABEL;
                EditorGUILayout.LabelField(label, titleStyle);

                foreach (var aiState in _selectedBrain.States)
                {
                    var buttonLabel = aiState.StateName;
                    GUI.backgroundColor = Color.white;
                    if (_selectedBrain.CurrentState.StateName == aiState.StateName)
                    {
                        GUI.backgroundColor = new Color(0f, .8f, 1f, 1);
                        buttonLabel         = "[C] " + aiState.StateName;
                    }
                    foreach (var transition in _selectedBrain.CurrentState.Transitions)
                    {
                        if (transition.FalseState != aiState.StateName && transition.TrueState != aiState.StateName)
                        {
                            continue;
                        }
                        GUI.backgroundColor = new Color(0f, .7f, 1f, 1);
                        buttonLabel         = "[>>] " + aiState.StateName;
                    }

                    EditorGUI.BeginDisabledGroup(_selectedBrain.CurrentState.StateName == aiState.StateName);
                    if (GUILayout.Button(buttonLabel))
                    {
                        TransitionToState(aiState.StateName);
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUI.backgroundColor = Color.white;

                #endregion

                EditorGUILayout.Space();

                #region --- TARGET ---

                label = C.DEBUG_SET_TARGET_LABEL;
                EditorGUILayout.LabelField(label, titleStyle);

                EditorGUILayout.BeginHorizontal();
                aiBrainTarget = EditorGUILayout.ObjectField(C.DEBUG_TARGET_LABEL, aiBrainTarget, typeof(GameObject), true) as GameObject;
                EditorGUI.BeginDisabledGroup(aiBrainTarget == null || !aiBrainTarget.scene.IsValid());
                if (GUILayout.Button(C.DEBUG_SET_LABEL, targetButtonStyle) && aiBrainTarget != null)
                {
                    _selectedBrain.Target = aiBrainTarget.transform;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(aiBrainTarget == null);
                if (GUILayout.Button(C.DEBUG_REMOVE_LABEL, targetButtonStyle))
                {
                    _selectedBrain.Target = null;
                    aiBrainTarget         = null;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.LabelField("Target: " + _selectedBrain.Target);
                EditorGUILayout.LabelField("LastKnownTargetPosition: " + _selectedBrain._lastKnownTargetPosition);

                #endregion

                EditorGUILayout.EndScrollView();
                EditorGUILayout.EndVertical();
            }
        }
Example #23
0
    protected virtual void UiSetupApp()
    {
        GUI.skin.label.wordWrap = true;
        if (!this.isSetupWizard)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false)))
            {
                this.photonSetupState = PhotonSetupStates.MainUi;
            }

            GUILayout.EndHorizontal();
        }


        // setup header
        UiTitleBox(CurrentLang.SetupWizardTitle, BackgroundImage);

        // setup info text
        GUI.skin.label.richText = true;
        GUILayout.Label(CurrentLang.SetupWizardInfo);

        // input of appid or mail
        EditorGUILayout.Separator();
        GUILayout.Label(CurrentLang.EmailOrAppIdLabel);
        this.mailOrAppId = EditorGUILayout.TextField(this.mailOrAppId).Trim(); // note: we trim all input

        if (this.mailOrAppId.Contains("@"))
        {
            // this should be a mail address
            this.minimumInput = (this.mailOrAppId.Length >= 5 && this.mailOrAppId.Contains("."));
            this.useMail      = this.minimumInput;
            this.useAppId     = false;
        }
        else
        {
            // this should be an appId
            this.minimumInput = ServerSettings.IsAppId(this.mailOrAppId);
            this.useMail      = false;
            this.useAppId     = this.minimumInput;
        }

        // button to skip setup
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button(CurrentLang.SkipButton, GUILayout.Width(100)))
        {
            this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings;
            this.useSkip          = true;
            this.useMail          = false;
            this.useAppId         = false;
        }

        // SETUP button
        EditorGUI.BeginDisabledGroup(!this.minimumInput);
        if (GUILayout.Button(CurrentLang.SetupButton, GUILayout.Width(100)))
        {
            this.useSkip = false;
            GUIUtility.keyboardControl = 0;
            if (this.useMail)
            {
                RegisterWithEmail(this.mailOrAppId); // sets state
            }
            if (this.useAppId)
            {
                this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings;
                Undo.RecordObject(PhotonNetwork.PhotonServerSettings, "Update PhotonServerSettings for PUN");
                PhotonNetwork.PhotonServerSettings.UseCloud(this.mailOrAppId);
                PhotonEditor.SaveSettings();
            }
        }
        EditorGUI.EndDisabledGroup();
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();


        // existing account needs to fetch AppId online
        if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered)
        {
            // button to open dashboard and get the AppId
            GUILayout.Space(15);
            GUILayout.Label(CurrentLang.AlreadyRegisteredInfo);


            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip), GUILayout.Width(205)))
            {
                Application.OpenURL(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId));
                this.mailOrAppId = "";
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }


        if (this.photonSetupState == PhotonSetupStates.GoEditPhotonServerSettings)
        {
            if (!this.highlightedSettings)
            {
                this.highlightedSettings = true;
                HighlightSettings();
            }

            GUILayout.Space(15);
            if (this.useSkip)
            {
                GUILayout.Label(CurrentLang.SkipRegistrationInfo);
            }
            else if (this.useMail)
            {
                GUILayout.Label(CurrentLang.RegisteredNewAccountInfo);
            }
            else if (this.useAppId)
            {
                GUILayout.Label(CurrentLang.AppliedToSettingsInfo);
            }


            // setup-complete info
            GUILayout.Space(15);
            GUILayout.Label(CurrentLang.SetupCompleteInfo);


            // close window (done)
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(CurrentLang.CloseWindowButton, GUILayout.Width(205)))
            {
                this.close = true;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        GUI.skin.label.richText = false;
    }
Example #24
0
    public override void NodeGUI()
    {
        GUILayout.BeginHorizontal();
#if UNITY_EDITOR
        if (GUILayout.Button(new GUIContent("Load", "Loads the group from an extern Canvas Asset File.")))
        {
            string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Saves/", "asset");
            if (!path.Contains(Application.dataPath))
            {
                // TODO: Generic Notification
                //if (path != String.Empty)
                //ShowNotification (new GUIContent ("You should select an asset inside your project folder!"));
                return;
            }
            path = path.Replace(Application.dataPath, "Assets");
            LoadNodeCanvas(path);
            //AdoptInputsOutputs ();
        }
        if (GUILayout.Button(new GUIContent("Save", "Saves the group as a new Canvas Asset File")))
        {
            NodeEditor.SaveNodeCanvas(nodeGroupCanvas, UnityEditor.EditorUtility.SaveFilePanelInProject("Save Group Node Canvas", "Group Canvas", "asset", "", NodeEditor.editorPath + "Saves/"));
        }
#endif
        if (GUILayout.Button(new GUIContent("New Group Canvas", "Creates a new Canvas")))
        {
            nodeGroupCanvas = CreateInstance <NodeCanvas> ();

            editorState         = CreateInstance <NodeEditorState> ();
            editorState.drawing = edit;
            editorState.name    = "GroupNode_EditorState";

            Node node = NodeTypes.getDefaultNode("exampleNode");
            if (node != null)
            {
                NodeCanvas prevNodeCanvas = NodeEditor.curNodeCanvas;
                NodeEditor.curNodeCanvas = nodeGroupCanvas;
                node = node.Create(Vector2.zero);
                node.InitBase();
                NodeEditor.curNodeCanvas = prevNodeCanvas;
            }
        }
        GUILayout.EndHorizontal();

        if (nodeGroupCanvas != null)
        {
            foreach (NodeInput input in Inputs)
            {
                input.DisplayLayout();
            }

            foreach (NodeOutput output in Outputs)
            {
                output.DisplayLayout();
            }

            if (!edit)
            {
                if (GUILayout.Button("Edit Node Canvas"))
                {
                    rect = openedRect;
                    edit = true;
                    editorState.canvasRect = GUILayoutUtility.GetRect(canvasSize.x, canvasSize.y, GUIStyle.none);
                    editorState.drawing    = true;
                }
            }
            else
            {
                if (GUILayout.Button("Stop editing Node Canvas"))
                {
                    nodeRect.position = openedRect.position + new Vector2(canvasSize.x / 2 - nodeRect.width / 2, 0);
                    rect = nodeRect;
                    edit = false;
                    editorState.drawing = false;
                }

                Rect canvasRect = GUILayoutUtility.GetRect(canvasSize.x, canvasSize.y, new GUILayoutOption[] { GUILayout.ExpandWidth(false) });
                if (Event.current.type != EventType.Layout)
                {
                    editorState.canvasRect = canvasRect;
                    Rect canvasControlRect = editorState.canvasRect;
                    canvasControlRect.position += rect.position + contentOffset;
                    NodeEditor.curEditorState.ignoreInput.Add(NodeEditorFramework.NodeEditor.CanvasGUIToScreenRect(canvasControlRect));
                }

                NodeEditor.DrawSubCanvas(nodeGroupCanvas, editorState);


                GUILayout.BeginArea(new Rect(canvasSize.x + 8, 45, 200, canvasSize.y), GUI.skin.box);
                GUILayout.Label(new GUIContent("Node Editor (" + nodeGroupCanvas.name + ")", "The currently opened canvas in the Node Editor"));
                                #if UNITY_EDITOR
                editorState.zoom = UnityEditor.EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), editorState.zoom, 0.6f, 2);
                                #endif
                GUILayout.EndArea();


                // Node is drawn by parent nodeCanvas, usually the mainNodeCanvas, because the zoom feature requires it to be drawn outside of any GUI group
            }
        }
    }
Example #25
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            Undo.RecordObject(instance, "PerkManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Game Scene:", "Check to to indicate if the scene is not an actual game scene\nIntend if the a perk menu scene, purchased perk wont take effect ");
            instance.inGameScene = EditorGUILayout.Toggle(cont, instance.inGameScene);

            cont = new GUIContent("Carry Over:", "Check to have carry the progress made in previous level to this level, the progress made in this level will be carry over to the next level.\n\nIf this is the first level, the specified setting value is used instead");
            instance.carryOver = EditorGUILayout.Toggle(cont, instance.carryOver);

            EditorGUILayout.Space();


            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            EditorGUIUtility.labelWidth += 35;
            cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for perk cost");
            instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost);
            EditorGUIUtility.labelWidth  -= 35;

            cont = new GUIContent("Resource:", "The resource used  to cast perk");
            if (instance.useRscManagerForCost)
            {
                EditorGUILayout.LabelField("Resource:", "-");
            }
            else
            {
                instance.rsc = EditorGUILayout.IntField(cont, instance.rsc);
            }

            GUILayout.EndVertical();

            if (!instance.useRscManagerForCost)
            {
                Sprite icon = PerkDB.GetRscIcon();
                icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40));
                PerkDB.SetRscIcon(icon);
            }

            GUILayout.EndHorizontal();


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showList = EditorGUILayout.Foldout(showList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = PerkDB.GetPrefabIDList();
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();


                List <Perk> perkList = PerkDB.GetList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].hideInInspector)
                    {
                        continue;
                    }

                    Perk perk = perkList[i];

                    GUILayout.BeginHorizontal();

                    EditorGUILayout.Space();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    TDE.DrawSprite(GUILayoutUtility.GetLastRect(), perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    float cachedL = EditorGUIUtility.labelWidth;      EditorGUIUtility.labelWidth = 80;
                    float cachedF = EditorGUIUtility.fieldWidth;      EditorGUIUtility.fieldWidth = 10;

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailablePrefabIDList.Contains(perk.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the perk in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailablePrefabIDList.Contains(perk.prefabID))
                        {
                            instance.unavailablePrefabIDList.Add(perk.prefabID);
                            instance.purchasedPrefabIDList.Remove(perk.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailablePrefabIDList.Remove(perk.prefabID);
                        }
                    }

                    if (!instance.unavailablePrefabIDList.Contains(perk.prefabID))
                    {
                        EditorGUI.BeginChangeCheck();
                        flag = instance.purchasedPrefabIDList.Contains(perk.prefabID);
                        flag = EditorGUILayout.Toggle(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), flag);

                        if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                        {
                            if (flag)
                            {
                                instance.purchasedPrefabIDList.Add(perk.prefabID);
                            }
                            else
                            {
                                instance.purchasedPrefabIDList.Remove(perk.prefabID);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(" - purchased: ", "- ");
                    }

                    EditorGUIUtility.labelWidth = cachedL;    EditorGUIUtility.fieldWidth = cachedF;

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Example #26
0
        private void OnUserSettingsGUI()
        {
            GUILayout.Label(GitConfigTitle, EditorStyles.boldLabel);

            EditorGUI.BeginDisabledGroup(isBusy);
            {
                newGitName  = EditorGUILayout.TextField(GitConfigNameLabel, newGitName);
                newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail);

                var needsSaving = newGitName != gitName || newGitEmail != gitEmail;
                EditorGUI.BeginDisabledGroup(!needsSaving);
                {
                    if (GUILayout.Button(GitConfigUserSave, GUILayout.ExpandWidth(false)))
                    {
                        GitClient.SetConfig("user.name", newGitName, GitConfigSource.User)
                        .Then((success, value) =>
                        {
                            if (success)
                            {
                                if (Repository != null)
                                {
                                    Repository.User.Name = value;
                                }
                                else
                                {
                                    if (cachedUser == null)
                                    {
                                        cachedUser = new User();
                                    }
                                    cachedUser.Name = value;
                                }
                            }
                        })
                        .Then(
                            GitClient.SetConfig("user.email", newGitEmail, GitConfigSource.User)
                            .Then((success, value) =>
                        {
                            if (success)
                            {
                                if (Repository != null)
                                {
                                    Repository.User.Email = value;
                                }
                                else
                                {
                                    cachedUser.Email   = value;
                                    userDataHasChanged = true;
                                }
                            }
                        }))
                        .FinallyInUI((_, __) =>
                        {
                            isBusy = false;
                            Redraw();
                        })
                        .Start();
                        isBusy = true;
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            EditorGUI.EndDisabledGroup();
        }
Example #27
0
    void GUIChangeConfig()
    {
        GUILayout.BeginVertical();
        //绘制标题
        GUILayout.Space(10);
        //是否开启添加配置信息
        ISChangeConfig = EditorGUILayout.Toggle("是否修改配置信息", ISChangeConfig);
        if (ISChangeConfig)
        {
            string SDKPluginspath = SDKPluginsPath.path;
            if (!Directory.Exists(SDKPluginspath))
            {
                this.ShowNotification(new GUIContent("暂无配置信息文件夹,以自动创建")); Directory.CreateDirectory(SDKPluginspath); return;
            }
            if (Directory.GetDirectories(SDKPluginspath).Length == 0)
            {
                this.ShowNotification(new GUIContent("暂无配置信息,请添加配置2")); return;
            }

            string[] SDKNames = Directory.GetDirectories(SDKPluginspath);
            GUILayout.Space(10);
            if (IsCanShowBtn)
            {
                for (int i = 0; i < SDKNames.Length; i++)
                {
                    if (GUILayout.Button(SDKNames[i], GUILayout.Width(20), GUILayout.ExpandWidth(true)))
                    {
                        IsCanShowBtn = false;
                        if (BuildToFolder == null)
                        {
                            ShowNotification(new GUIContent("请选择打包的路径")); return;
                        }
                        string           PluginsName = new DirectoryInfo(SDKNames[i]).Name; //找到plugins文件夹的名字
                        SavedPliginsPath PliginsPath = new SavedPliginsPath(PluginsName);
                        string           txt         = File.ReadAllText(PliginsPath.JsonPath, Encoding.UTF8);
                        ChangeProject = JsonUtility.FromJson <Project>(txt);
                    }
                }
            }
            else
            {
                if (ChangeProject != null)
                {
                    GUILayout.Label(ChangeProject.Name);
                    ChangeProject.ProjectName       = EditorGUILayout.TextField("软件名:", ChangeProject.ProjectName);
                    ChangeProject.IconName          = EditorGUILayout.TextField("Icon路径:", ChangeProject.IconName);
                    ChangeProject.PackageName       = EditorGUILayout.TextField("包名:", ChangeProject.PackageName);
                    ChangeProject.Version           = EditorGUILayout.TextField("版本:", ChangeProject.Version);
                    ChangeProject.BundleVersionCode = EditorGUILayout.TextField("bundleVersionCode:", ChangeProject.BundleVersionCode);

                    if (GUILayout.Button("保存配置信息", GUILayout.Height(20), GUILayout.Width(200)))
                    {
                        SavedPliginsPath path = new SavedPliginsPath(ChangeProject.Name);
                        if (File.Exists(path.JsonPath))
                        {
                            File.Delete(path.JsonPath);
                        }
                        AssetDatabase.Refresh();
                        AssetDatabase.SaveAssets();

                        string       str = ChangeProject.SaveToString();
                        StreamWriter sw  = new StreamWriter(path.JsonPath);
                        sw.WriteLine(str);
                        sw.Close();
                        AssetDatabase.Refresh();
                        AssetDatabase.SaveAssets();

                        string TitleTxt = UtilTHIS.ProjectToString(ChangeProject);
                        EditorUtility.DisplayDialog("配置信息更改完毕", TitleTxt, "确认");
                        ChangeProject  = null;
                        ISChangeConfig = false;
                    }
                }
            }
        }
        else
        {
            IsCanShowBtn = true;
        }
        GUILayout.EndVertical();
    }
Example #28
0
        private void OnInstallPathGUI()
        {
            string gitExecPath    = null;
            string extension      = null;
            string gitInstallPath = null;

            if (Environment != null)
            {
                extension = Environment.ExecutableExtension;
                if (Environment.IsWindows)
                {
                    extension = extension.TrimStart('.');
                }

                gitInstallPath = Environment.GitInstallPath;

                if (Environment.GitExecutablePath != null)
                {
                    gitExecPath = Environment.GitExecutablePath.ToString();
                }
            }

            // Install path
            GUILayout.Label(GitInstallTitle, EditorStyles.boldLabel);

            GUI.enabled = !isBusy && gitExecPath != null;

            // Install path field
            EditorGUI.BeginChangeCheck();
            {
                //TODO: Verify necessary value for a non Windows OS
                Styles.PathField(ref gitExecPath,
                                 () => EditorUtility.OpenFilePanel(GitInstallBrowseTitle,
                                                                   gitInstallPath,
                                                                   extension), ValidateGitInstall);
            }
            if (EditorGUI.EndChangeCheck())
            {
                Logger.Trace("Setting GitExecPath: " + gitExecPath);

                Manager.SystemSettings.Set(Constants.GitInstallPathKey, gitExecPath);
                Environment.GitExecutablePath = gitExecPath.ToNPath();
            }

            GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

            GUILayout.BeginHorizontal();
            {
                // Find button - for attempting to locate a new install
                if (GUILayout.Button(GitInstallFindButton, GUILayout.ExpandWidth(false)))
                {
                    var task = new ProcessTask <NPath>(Manager.CancellationToken, new FirstLineIsPathOutputProcessor())
                               .Configure(Manager.ProcessManager, Environment.IsWindows ? "where" : "which", "git")
                               .FinallyInUI((success, ex, path) =>
                    {
                        if (success && !string.IsNullOrEmpty(path))
                        {
                            Environment.GitExecutablePath = path;
                            GUIUtility.keyboardControl    = GUIUtility.hotControl = 0;
                        }
                    });
                }
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;
        }
Example #29
0
        static void OnPostHeaderGUI(Editor editor)
        {
            var aaSettings = AddressableAssetSettingsDefaultObject.Settings;
            AddressableAssetEntry entry = null;

            if (editor.targets.Length > 0)
            {
                int  addressableCount = 0;
                bool foundValidAsset  = false;
                bool foundAssetGroup  = false;
                foreach (var t in editor.targets)
                {
                    foundAssetGroup |= t is AddressableAssetGroup;
                    foundAssetGroup |= t is AddressableAssetGroupSchema;
                    if (AddressableAssetUtility.GetPathAndGUIDFromTarget(t, out var path, out var guid, out var mainAssetType))
                    {
                        // Is asset
                        if (!BuildUtility.IsEditorAssembly(mainAssetType.Assembly))
                        {
                            foundValidAsset = true;

                            if (aaSettings != null)
                            {
                                entry = aaSettings.FindAssetEntry(guid);
                                if (entry != null && !entry.IsSubAsset)
                                {
                                    addressableCount++;
                                }
                            }
                        }
                    }
                }

                if (foundAssetGroup)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Profile: " + AddressableAssetSettingsDefaultObject.GetSettings(true).profileSettings.
                                    GetProfileName(AddressableAssetSettingsDefaultObject.GetSettings(true).activeProfileId));

                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("System Settings", "MiniButton"))
                    {
                        EditorGUIUtility.PingObject(AddressableAssetSettingsDefaultObject.Settings);
                        Selection.activeObject = AddressableAssetSettingsDefaultObject.Settings;
                    }
                    GUILayout.EndHorizontal();
                }

                if (!foundValidAsset)
                {
                    return;
                }

                if (addressableCount == 0)
                {
                    if (GUILayout.Toggle(false, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), editor.targets, true);
                    }
                }
                else if (addressableCount == editor.targets.Length)
                {
                    GUILayout.BeginHorizontal();
                    if (!GUILayout.Toggle(true, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(aaSettings, editor.targets, false);
                        GUIUtility.ExitGUI();
                    }

                    if (editor.targets.Length == 1 && entry != null)
                    {
                        string newAddress = EditorGUILayout.DelayedTextField(entry.address, GUILayout.ExpandWidth(true));
                        if (newAddress != entry.address)
                        {
                            if (newAddress.Contains("[") && newAddress.Contains("]"))
                            {
                                Debug.LogErrorFormat("Rename of address '{0}' cannot contain '[ ]'.", entry.address);
                            }
                            else
                            {
                                entry.address = newAddress;
                                AddressableAssetUtility.OpenAssetIfUsingVCIntegration(entry.parentGroup, true);
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    if (s_ToggleMixed == null)
                    {
                        s_ToggleMixed = new GUIStyle("ToggleMixed");
                    }
                    if (GUILayout.Toggle(false, s_AddressableAssetToggleText, s_ToggleMixed, GUILayout.ExpandWidth(false)))
                    {
                        SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), editor.targets, true);
                    }
                    EditorGUILayout.LabelField(addressableCount + " out of " + editor.targets.Length + " assets are addressable.");
                    GUILayout.EndHorizontal();
                }
            }
        }
Example #30
0
        void DoStandardModeGUI(bool hdr)
        {
            if (!hdr)
            {
                PropertyField(m_LdrLut);

                var lut = (target as ColorGrading).ldrLut.value;
                CheckLutImportSettings(lut);
            }

            if (hdr)
            {
                EditorGUILayout.Space();
                EditorUtilities.DrawHeaderLabel("Tonemapping");
                PropertyField(m_Tonemapper);

                if (m_Tonemapper.value.intValue == (int)Tonemapper.Custom)
                {
                    DrawCustomToneCurve();
                    PropertyField(m_ToneCurveToeStrength);
                    PropertyField(m_ToneCurveToeLength);
                    PropertyField(m_ToneCurveShoulderStrength);
                    PropertyField(m_ToneCurveShoulderLength);
                    PropertyField(m_ToneCurveShoulderAngle);
                    PropertyField(m_ToneCurveGamma);
                }
            }

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("White Balance");

            PropertyField(m_Temperature);
            PropertyField(m_Tint);

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("Tone");

            if (hdr)
            {
                PropertyField(m_PostExposure);
            }

            PropertyField(m_ColorFilter);
            PropertyField(m_HueShift);
            PropertyField(m_Saturation);

            if (!hdr)
            {
                PropertyField(m_Brightness);
            }

            PropertyField(m_Contrast);

            EditorGUILayout.Space();
            int currentChannel = GlobalSettings.currentChannelMixer;

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.PrefixLabel("Channel Mixer", GUIStyle.none, Styling.labelHeader);

                EditorGUI.BeginChangeCheck();
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayoutUtility.GetRect(9f, 18f, GUILayout.ExpandWidth(false)); // Dirty hack to do proper right column alignement
                        if (GUILayout.Toggle(currentChannel == 0, EditorUtilities.GetContent("Red|Red output channel."), EditorStyles.miniButtonLeft))
                        {
                            currentChannel = 0;
                        }
                        if (GUILayout.Toggle(currentChannel == 1, EditorUtilities.GetContent("Green|Green output channel."), EditorStyles.miniButtonMid))
                        {
                            currentChannel = 1;
                        }
                        if (GUILayout.Toggle(currentChannel == 2, EditorUtilities.GetContent("Blue|Blue output channel."), EditorStyles.miniButtonRight))
                        {
                            currentChannel = 2;
                        }
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    GUI.FocusControl(null);
                }
            }

            GlobalSettings.currentChannelMixer = currentChannel;

            if (currentChannel == 0)
            {
                PropertyField(m_MixerRedOutRedIn);
                PropertyField(m_MixerRedOutGreenIn);
                PropertyField(m_MixerRedOutBlueIn);
            }
            else if (currentChannel == 1)
            {
                PropertyField(m_MixerGreenOutRedIn);
                PropertyField(m_MixerGreenOutGreenIn);
                PropertyField(m_MixerGreenOutBlueIn);
            }
            else
            {
                PropertyField(m_MixerBlueOutRedIn);
                PropertyField(m_MixerBlueOutGreenIn);
                PropertyField(m_MixerBlueOutBlueIn);
            }

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("Trackballs");

            using (new EditorGUILayout.HorizontalScope())
            {
                PropertyField(m_Lift);
                GUILayout.Space(4f);
                PropertyField(m_Gamma);
                GUILayout.Space(4f);
                PropertyField(m_Gain);
            }

            EditorGUILayout.Space();
            EditorUtilities.DrawHeaderLabel("Grading Curves");

            DoCurvesGUI(hdr);
        }