BeginHorizontal() public static method

Begin a horizontal group and get its rect back.

public static BeginHorizontal ( ) : Rect
return UnityEngine.Rect
示例#1
0
    public static string ProjectFileBrowser(string title, string description, string file, string extention)
    {
        string path = file;

        EGL.BeginHorizontal();
        {
            EGL.PrefixLabel(title);
            GUILayout.Label(file, Skin.textField);

            string newPath = file;
            if (GUILayout.Button("Browse", GUILayout.Width(64f)))
            {
                newPath = EditorUtility.OpenFilePanel(description, Path.GetFullPath(UPath.GetAbsolutePath(file)), extention);
                if (newPath != string.Empty)
                {
                    newPath = UPath.GetProjectPath(newPath);
                }
                else
                {
                    newPath = file;
                }
            }
            path = newPath;
        }
        EGL.EndHorizontal();

        return(path);
    }
示例#2
0
            public override void OnGUI(Rect rect)
            {
                searchText = searchField.OnGUI(searchText);

                scrollPosition = EGL.BeginScrollView(scrollPosition);

                foreach (var type in behaviourTypes)
                {
                    if (type.ToLower().Contains(searchText.ToLower()))
                    {
                        EGL.BeginHorizontal();
                        EGL.LabelField(type, GL.Width(140));
                        if (GL.Button("Add", GL.Width(40)))
                        {
                            var instance = (StateBehaviour)ScriptableObject.CreateInstance(type);
                            instance.name      = type;
                            instance.hideFlags = HideFlags.HideInHierarchy;
                            list.Add(instance);

                            AssetDatabase.AddObjectToAsset(instance, profile);
                            AssetDatabase.SaveAssets();

                            editorWindow.Close();
                        }
                        EGL.EndHorizontal();
                    }
                }

                EGL.EndScrollView();
            }
    void OnGUI()
    {
        EGL.LabelField("Generated texture", EditorStyles.boldLabel);

        EGL.LabelField("Show channels:");
        EGL.BeginHorizontal();
        _c[3] = GUILayout.Toggle(_c[3], "A");
        EG.BeginDisabledGroup(_c[3]);
        _c[0] = GUILayout.Toggle(_c[0], "R");
        _c[1] = GUILayout.Toggle(_c[1], "G");
        _c[2] = GUILayout.Toggle(_c[2], "B");
        EG.EndDisabledGroup();
        EGL.EndHorizontal();

        EGL.LabelField("Zoom");
        zoom = EGL.Slider(zoom, 0.2f, 3f);

        EGL.LabelField("Slice");
        slice = EGL.Slider(slice, 0f, 1f);

        Rect r_tex = EGL.BeginVertical(GUILayout.ExpandHeight(true));

        r_tex.height = r_tex.width = Mathf.Min(r_tex.height, r_tex.width);
        if (texture)
        {
            previewMaterial.SetFloat("_Zoom", zoom);
            previewMaterial.SetFloat("_Slice", slice);
            previewMaterial.SetVector("_Channels", ChannelVector());
            EG.DrawPreviewTexture(r_tex, texture, previewMaterial);
        }
        EGL.EndVertical();
    }
    /* TODO: Show the below struct editors using standard inspector drawing tools */

    bool ShowSplatPrototype(SplatPrototype splatPrototype, int id)
    {
        bool removeThis = false;

        EGL.BeginVertical(GuiUtils.Skin.box);
        {
            GUILayout.Label(id.ToString() + ". " + (splatPrototype.texture != null ? splatPrototype.texture.name : ""));

            EGL.BeginHorizontal();
            {
                splatPrototype.texture = EGL.ObjectField(splatPrototype.texture, typeof(Texture2D), false, GUILayout.Width(64f), GUILayout.Height(64f)) as Texture2D;

                EGL.BeginVertical();
                {
                    splatPrototype.tileOffset = EGL.Vector2Field("Tile Offset", splatPrototype.tileOffset);
                    splatPrototype.tileSize   = EGL.Vector2Field("Tile Size", splatPrototype.tileSize);
                }
                EGL.EndVertical();

                if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f)))
                {
                    removeThis = true;
                }
            }
            EGL.EndHorizontal();
        }
        EGL.EndVertical();

        return(removeThis);
    }
示例#5
0
    public static string ProjectFolderBrowser(string title, string description, string folder, string defaultName)
    {
        string path = folder;

        EGL.BeginHorizontal();
        {
            EGL.PrefixLabel(title);
            GUILayout.Label(folder, Skin.textField);

            string newPath = folder;
            if (GUILayout.Button("Browse", GUILayout.Width(64f)))
            {
                newPath = EditorUtility.SaveFolderPanel(description, folder, defaultName);
                if (newPath != string.Empty)
                {
                    newPath = UPath.GetProjectPath(newPath);
                }
                else
                {
                    newPath = folder;
                }
            }
            path = newPath;
        }
        EGL.EndHorizontal();

        return(path);
    }
    bool ShowTreePrototype(TreePrototype treePrototype, int id)
    {
        bool removeThis = false;

        EGL.BeginVertical(GuiUtils.Skin.box);
        {
            GUILayout.Label(id.ToString() + ". " + (treePrototype.prefab != null ? treePrototype.prefab.name : ""));

            EGL.BeginHorizontal();
            {
                treePrototype.prefab = EGL.ObjectField(treePrototype.prefab, typeof(GameObject), false) as GameObject;

                EGL.BeginVertical();
                {
                    treePrototype.bendFactor = EGL.FloatField("Bend Factor", treePrototype.bendFactor);
                }
                EGL.EndVertical();

                if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f)))
                {
                    removeThis = true;
                }
            }
            EGL.EndHorizontal();
        }
        EGL.EndVertical();

        return(removeThis);
    }
示例#7
0
 string ToolbarSearchField(string str, SearchField field)
 {
     EGL.BeginHorizontal(EditorStyles.toolbar);
     GL.Label("", GL.Width(150));
     str = field.OnToolbarGUI(str);
     EGL.EndHorizontal();
     return(str);
 }
 public static string OnGUI(this SearchField self, string label, string content)
 {
     EGL.BeginHorizontal();
     EGL.PrefixLabel(label);
     content = self.OnGUI(content);
     EGL.EndHorizontal();
     return(content);
 }
示例#9
0
 static bool CenteredButton(string content)
 {
     EGL.BeginHorizontal();
     GL.FlexibleSpace();
     var res = GL.Button(content, GL.Width(150));
     GL.FlexibleSpace();
     EGL.EndHorizontal();
     return res;
 }
 public static IntRange FrameRangeInput(string text, IntRange range)
 {
     EGL.BeginHorizontal();
     EGL.PrefixLabel(text);
     range.from = EGL.IntField(range.from);
     EGL.LabelField("->", GL.Width(30));
     range.to = EGL.IntField(range.to);
     EGL.EndHorizontal();
     return(range);
 }
示例#11
0
        private void TextureGUI()
        {
            data.curve = UGL.CurveField(data.curve);
            int?toRemove = null;

            for (int i = 0; i < data.textureNames.Count; i++)
            {
                UGL.BeginHorizontal();
                data.textureNames[i] = UGL.DelayedTextField(data.textureNames[i], GUILayout.MaxWidth(Screen.width));
                GUILayout.FlexibleSpace();
                Texture2D oldVal = i < data.textures.Count ? data.textures[i]: null;
                Texture2D newVal = (Texture2D)UGL.ObjectField("", oldVal, typeof(Texture2D), true, GUILayout.Width(100));
                UGL.BeginVertical();
                if (GUILayout.Button("Set As Curve", GUILayout.Width(100)))
                {
                    Texture2D text = new Texture2D(100, 1);
                    for (int j = 0; j < text.width; j++)
                    {
                        float sample = data.curve.Evaluate((float)j / text.width);
                        text.SetPixel(j, 0, new Color(sample, sample, sample));
                    }
                    text.Apply();
                    if (text != oldVal)
                    {
                        string path = AssetDatabase.GetAssetPath(data);
                        AssetDatabase.AddObjectToAsset(text, path);
                        newVal = text;
                    }
                }
                GUI.color = Color.red;
                if (GUILayout.Button("-", GUILayout.Width(100)))
                {
                    toRemove = i;
                }
                UGL.EndVertical();
                GUI.color = Color.white;
                if (oldVal != newVal)
                {
                    if (!data.textures.Contains(oldVal))
                    {
                        data.textures.Add(newVal);
                    }
                    else
                    {
                        data.textures[data.textures.IndexOf(oldVal)] = newVal;
                    }
                }
                UGL.EndHorizontal();
            }
            if (toRemove != null)
            {
                data.textureNames.RemoveAt((int)toRemove);
            }
        }
示例#12
0
        private void StartGUI(string name)
        {
            Rect r = EGL.BeginVertical( );

            GL.Space(3);
            EGL.BeginHorizontal();
            GUI.backgroundColor = Color.black * 2;
            GUI.contentColor    = Color.white;
            GUI.Box(r, GUIContent.none);
            GUI.contentColor = Color.white * 10;
            EGL.LabelField(" " + name, EditorStyles.boldLabel, GL.Width(85));
        }
    void OnGUI()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;

        if (editorUtilities == null)
        {
            GUILayout.Label("No running instance of LandmassImporter found");
            return;
        }

        if (editorUtilities.IsProcessing)
        {
            ShowProgressBar();
        }

        GUI.enabled = !editorUtilities.IsProcessing;

        EGL.BeginVertical();
        {
            EGL.Separator();

            _currentState = (MenuState)GUILayout.Toolbar((int)_currentState, menuTitles);

            EGL.BeginHorizontal();
            {
                _globalScrollPos = EGL.BeginScrollView(_globalScrollPos, GuiUtils.Skin.box);
                {
                    EGL.BeginVertical();
                    {
                        EGL.Separator();

                        _menus[_currentState]();
                        GUILayout.FlexibleSpace();

                        EGL.Separator();
                    }
                    EGL.EndVertical();
                }
                EGL.EndScrollView();
            }
            EGL.EndHorizontal();

            EGL.Separator();

            ShowSaveButtons();

            GUILayout.Space(16);
        }
        EGL.EndVertical();

        GUI.enabled = true;
    }
示例#14
0
        void FromStateFilterInspector(TransitionProfile profile, FromStateFilter filter, ref Rect stateRect)
        {
            EGL.BeginHorizontal();
            filter.type = (FromStateType)EGL.EnumPopup(filter.type, GL.Width(70));

            if (filter.type == FromStateType.State)
            {
                EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, allStateNames, str => filter.stateOrTagName = str, ref stateRect);
            }
            else if (filter.type == FromStateType.Tag)
            {
                EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, transition.profile.tags, str => filter.stateOrTagName = str, ref stateRect);
            }

            if (filter.type == FromStateType.State)
            {
                var state = transition.profile.FindState(filter.stateOrTagName);
                if (state == null)
                {
                    EGL.EndHorizontal();
                    EGL.HelpBox("No Source State", MessageType.Error);
                }
                else
                {
                    List <string> portionSelections = new List <string>();
                    portionSelections.Add("<any>");
                    foreach (var p in state.allPortions)
                    {
                        portionSelections.Add(p.name);
                    }

                    var prevIndex = portionSelections.IndexOf(filter.portionName);
                    if (prevIndex == -1)
                    {
                        prevIndex = 0;
                    }

                    prevIndex          = EGL.Popup(prevIndex, portionSelections.ToArray());
                    filter.portionName = prevIndex == 0 ? "" : portionSelections[prevIndex];

                    if (GL.Button("Focus"))
                    {
                        Utils.FocusEditingAnimation(profile, state.stateName);
                    }
                    EGL.EndHorizontal();
                }
            }
            else
            {
                EGL.EndHorizontal();
            }
        }
示例#15
0
        string PathSelection(string id, string path)
        {
            EGL.BeginHorizontal();
            EGL.PrefixLabel(id);
            path = EGL.TextField(path);
            if (GL.Button("...", GL.Width(30)))
            {
                path = GetAssetPath(EditorUtility.OpenFolderPanel("Select path", path, ""));
            }

            EGL.EndHorizontal();
            return(path);
        }
        /// <summary>
        /// Draw an element inside the target array property.
        /// </summary>
        /// <param name="arrayProperty">Array property.</param>
        /// <param name="elementIndex">Element index to get the element out of the array property.</param>
        /// <param name="getSelectedIndex">Get selected index.</param>
        /// <param name="setSelectedIndex">Set selected index.</param>
        /// <param name="drawInnerProperties">Action to draw inner properties of the element property.</param>
        void DrawArrayElement(SP arrayProperty, int elementIndex, string minSizeWarning, int minSize,
                              Func <int> getSelectedIndex, Action <int> setSelectedIndex, Action <SP> drawInnerProperties)
        {
            var elementProperty = arrayProperty.GetArrayElementAtIndex(elementIndex);

            EGL.BeginHorizontal();

            EGL.BeginVertical(E_SM.GetCustomStyle("Item Box"));

            if (drawInnerProperties != null)
            {
                drawInnerProperties(elementProperty);
            }

            EGL.EndVertical();

            var deleteIcon           = EditorGUIUtility.IconContent("Toolbar Minus");
            var deleteButtonStyle    = GUIStyle.none;
            var deleteButtonMinWidth = GUILayout.MaxWidth(E_SM.smallButtonWidth);

            /// Draw a button to remove element property from array property.
            bool canDelete = arrayProperty.arraySize > minSize;

            EditorGUI.BeginDisabledGroup(!canDelete); // Disable the "-" button
            if (GUILayout.Button(deleteIcon, deleteButtonStyle, deleteButtonMinWidth))
            {
                if (arrayProperty.arraySize > minSize)
                {
                    if (getSelectedIndex() > elementIndex)
                    {
                        setSelectedIndex(getSelectedIndex() - 1);
                    }

                    arrayProperty.DeleteArrayElementAtIndex(elementIndex);

                    /// We need to return here so the deleted element won't be displayed in the codes below,
                    /// causing unexpected error.
                    return;
                }

                if (!string.IsNullOrEmpty(minSizeWarning))
                {
                    Debug.Log(minSizeWarning);
                }
            }
            EditorGUI.EndDisabledGroup();

            EGL.EndHorizontal();
        }
    bool ShowDetailPrototype(DetailPrototype prototype, int id)
    {
        bool removeThis = false;

        EGL.BeginVertical(GuiUtils.Skin.box);
        {
            EGL.BeginHorizontal();
            {
                EGL.BeginVertical();
                {
                    prototype.usePrototypeMesh = EGL.Toggle("Use Mesh", prototype.usePrototypeMesh);
                    prototype.prototype        = EGL.ObjectField(prototype.prototype, typeof(GameObject), false) as GameObject;
                    prototype.prototypeTexture = EGL.ObjectField(prototype.prototypeTexture, typeof(Texture2D), false, GUILayout.Width(64f),
                                                                 GUILayout.Height(64f)) as Texture2D;
                }
                EGL.EndVertical();

                EGL.BeginVertical();
                {
                    prototype.bendFactor   = EGL.FloatField("Bend Factor", prototype.bendFactor);
                    prototype.dryColor     = EGL.ColorField("Dry Color", prototype.dryColor);
                    prototype.healthyColor = EGL.ColorField("Healthy Color", prototype.healthyColor);
                    prototype.maxHeight    = EGL.FloatField("Max Height", prototype.maxHeight);
                    prototype.minHeight    = EGL.FloatField("Min Height", prototype.minHeight);
                    prototype.maxWidth     = EGL.FloatField("Max Width", prototype.maxWidth);
                    prototype.minWidth     = EGL.FloatField("Min Width", prototype.minWidth);
                    prototype.noiseSpread  = EGL.FloatField("Noise Spread", prototype.noiseSpread);
                    prototype.renderMode   = (DetailRenderMode)EGL.EnumPopup("Noise Spread", prototype.renderMode);
                }
                EGL.EndVertical();

                if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f)))
                {
                    removeThis = true;
                }
            }
            EGL.EndHorizontal();
        }
        EGL.EndVertical();

        return(removeThis);
    }
        void DrawInsertDropdown(SP dialog, int cursorIndex, TextEditor textEditor, string name,
                                List <string> ids, string insertButtonText, string pattern, Func <int> getSelectedIndex, Action <int> setSelectedIndex)
        {
            if (ids == null || ids.Count < 1)
            {
                return;
            }

            EGL.BeginHorizontal(ES.helpBox);

            float insertButtonWidth = insertButtonText.Length * CharacterPixelWidth;

            if (GUILayout.Button(insertButtonText, ES.miniButton, GUILayout.MinWidth(insertButtonWidth), GUILayout.ExpandHeight(true)))
            {
                string id         = ids[getSelectedIndex()];
                string insertText = pattern + "Id = " + id + ">";
                dialog.stringValue = dialog.stringValue.Insert(cursorIndex, insertText);

                Debug.Log(string.Format("Inserted {0} into content at index: {1}", insertText, cursorIndex));
            }

            string[] displayIdsText = ids.Select(id => id = "Id: " + id).ToArray();
            float    maxPopupWidth  = displayIdsText[getSelectedIndex()].Length * CharacterPixelWidth;
            GUIStyle popupStyle     = new GUIStyle(ES.popup)
            {
                alignment = TextAnchor.MiddleCenter
            };

            GUI.SetNextControlName(name);
            int index = EGL.Popup(
                getSelectedIndex(),
                displayIdsText,
                popupStyle,
                GUILayout.MinWidth(maxPopupWidth),
                GUILayout.MinHeight(GUILayoutUtility.GetLastRect().height)
                );

            setSelectedIndex(index);
            EGL.EndHorizontal();
        }
示例#19
0
        public void OnGUI()
        {
            if (data != null)
            {
                scroll = UGL.BeginScrollView(scroll, EditorStyles.helpBox);
                UGL.BeginHorizontal(EditorStyles.miniButton);
                type      = (DataTypes)GUILayout.Toolbar((int)type, System.Enum.GetNames(typeof(DataTypes)));
                GUI.color = Color.green;
                if (GUILayout.Button("+"))
                {
                    data.Add(type, string.Empty);
                }
                GUI.color = Color.white;
                UGL.EndHorizontal();
                switch (type)
                {
                case DataTypes.Color:
                    ColorGUI();
                    break;

                case DataTypes.Float:
                    FloatGUI();
                    break;

                case DataTypes.Texture:
                    TextureGUI();
                    break;

                case DataTypes.Vector:
                    VectorGUI();
                    break;
                }
                UGL.EndScrollView();
                //UGL.EndVertical();
                if (data != null)
                {
                    data.SetValues();
                }
            }
        }
    void ShowSaveButtons()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            EGL.BeginHorizontal();
            {
                EGL.Separator();

                if (GUILayout.Button("Save Settings"))
                {
                    editorUtilities.SaveSettings();
                }
                if (GUILayout.Button("Load Settings"))
                {
                    editorUtilities.LoadSettings();
                }
                GUI.enabled = true;

                EGL.Separator();
            }
            EGL.EndHorizontal();

            EGL.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                if (importCfg.IsDirty)
                {
                    GUILayout.Label("You have unsaved settings.");
                }
                GUILayout.FlexibleSpace();
            }
            EGL.EndHorizontal();
        }
        EGL.EndVertical();
    }
示例#21
0
    void OnGUI()
    {
        EGL.LabelField("3D Texture properties", EditorStyles.boldLabel);

        int new_size = EGL.IntField("Resolution", data.size);

        new_size  = new_size <= 512 ? new_size : 512;
        new_size  = new_size >= 8 ? new_size : 8;
        data.size = new_size;

        EGL.LabelField("Worley noise");
        data.freqs[0]   = EGL.FloatField("Frequency", data.freqs[0]);
        data.octaves[0] = EGL.IntField("Octaves", data.octaves[0]);
        bool inv = EGL.Toggle("Invert", data.inverts[0] > 0);

        data.inverts[0] = inv ? 1 : 0;

        if (GUILayout.Button("Generate"))
        {
            CreateTexture();
        }

        EGL.HelpBox(status, MessageType.None, true);

        if (GUILayout.Button("Preview"))
        {
            CloudPreviewer.ShowTexture(texture);
        }

        EGL.BeginHorizontal();
        assetName = EGL.TextField("Asset name:", assetName);
        if (GUILayout.Button("Save"))
        {
            AssetDatabase.CreateAsset(texture, "Assets/" + assetName + ".asset");
        }
        EGL.EndHorizontal();
    }
示例#22
0
        private void FloatGUI()
        {
            int?toRemove = null;

            for (int i = 0; i < data.floatNames.Count; i++)
            {
                UGL.BeginHorizontal();
                data.floatNames[i] = UGL.DelayedTextField(data.floatNames[i], GUILayout.MaxWidth(Screen.width));
                GUILayout.FlexibleSpace();
                float oldVal = i < data.floats.Count?data.floats[i]:0;
                float newVal = UGL.FloatField(oldVal);
                GUILayout.FlexibleSpace();
                GUI.color = Color.red;
                if (GUILayout.Button("-", GUILayout.Width(100)))
                {
                    toRemove = i;
                }
                GUI.color = Color.white;
                if (oldVal != newVal)
                {
                    if (!data.floats.Contains(oldVal))
                    {
                        data.floats.Add(newVal);
                    }
                    else
                    {
                        data.floats[data.floats.IndexOf(oldVal)] = newVal;
                    }
                }
                UGL.EndHorizontal();
            }
            if (toRemove != null)
            {
                data.floatNames.RemoveAt((int)toRemove);
            }
        }
示例#23
0
    private void OnPlaneGenerationGUI()
    {
        planeGenerationData = planeGenerationData ?? new PlaneGenerationData();

        planeGenerationData.direction = (PlaneGenerationData.Direction)UG.EnumPopup("平面方向", planeGenerationData.direction);

        UG.BeginHorizontal();

        planeGenerationData.length = UG.DelayedFloatField("长", planeGenerationData.length);
        planeGenerationData.width  = UG.DelayedFloatField("宽", planeGenerationData.width);

        UG.EndHorizontal();

        UG.BeginHorizontal();

        planeGenerationData.verticesPerLength = UG.DelayedIntField("长顶点数", planeGenerationData.verticesPerLength);
        planeGenerationData.verticesPerWidth  = UG.DelayedIntField("宽顶点数", planeGenerationData.verticesPerWidth);

        UG.EndHorizontal();

        bool   legal        = true;
        string errorMessage = String.Empty;

        if (defaultMaterial == null)
        {
            legal         = false;
            errorMessage += "默认材质不能为空";
        }

        if (planeGenerationData.length <= 0)
        {
            legal         = false;
            errorMessage += "平面长必须大于0\n";
        }

        if (planeGenerationData.width <= 0)
        {
            legal         = false;
            errorMessage += "平面宽必须大于0\n";
        }

        if (planeGenerationData.verticesPerLength <= 0)
        {
            legal         = false;
            errorMessage += "平面长顶点数必须大于0\n";
        }

        if (planeGenerationData.verticesPerWidth <= 0)
        {
            legal         = false;
            errorMessage += "平面宽顶点数必须大于0\n";
        }

        if (legal)
        {
            if (GUILayout.Button("生成"))
            {
                MeshTool.InstantiatePlane(planeGenerationData, defaultMaterial);
            }
        }
        else
        {
            UG.HelpBox(errorMessage, MessageType.Error);
        }
    }
        void DrawConsentDialogContentEditor()
        {
            // TextEditor for selecting and editing portions of text.
            TextEditor textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
            SP         dialog     = PrivacyProperties.consentDialogContent.property;

            /// Fix error that make indexes reset to 0 when lose focus.
            int startIndex, endIndex;

            FixIndexesResetError(textEditor, out startIndex, out endIndex);

            // TextEditor inherently requires GUILayout.TextArea which doesn't work with copy & paste.
            // To enable copy & paste we'll need to use EditorGUILayout.TextArea which will make
            // text selection unavailable.
            // Since we can't have both things at the same time, we need a toggle to switch between them.
            EnableCopyPasteMode = EGL.ToggleLeft(PrivacyProperties.enableCopyPasteMode.content, EnableCopyPasteMode);

            /// These functions are not available when enabling copy & paste.
            if (!EnableCopyPasteMode)
            {
                EGL.BeginHorizontal();

                EGL.BeginHorizontal(ES.helpBox);
                DrawHyperlinkButton(textEditor.SelectedText, startIndex, endIndex);
                DrawEditButtons(textEditor.SelectedText, dialog, startIndex, endIndex);
                EGL.EndHorizontal();

                // Draw insert toggle dropdown.
                DrawInsertDropdown(dialog, endIndex, textEditor, "ToggleDropdown",
                                   DefaultConsentDialog.GetAllToggleIds(), "Insert Toggle", ConsentDialog.TogglePattern,
                                   () => SelectedToggleIndex, param => SelectedToggleIndex = param);

                // Draw insert button dropwdown.
                DrawInsertDropdown(dialog, endIndex, textEditor, "ButtonDropDown",
                                   DefaultConsentDialog.GetAllButtonIds(), "Insert Button", ConsentDialog.ButtonPattern,
                                   () => SelectedButtonIndex, param => SelectedButtonIndex = param);

                EGL.EndHorizontal();
            }
            else
            {
                EGL.Space();
            }

            DrawHyperLinkInputSection(dialog);

            /// We need to do this because GUILayout.TextArea, the only TextArea that work with TextEditor, doesn't work with copy & paste.
            GUIStyle style = new GUIStyle(ES.textArea)
            {
                wordWrap = true
            };

            mainContentTextAreaScroll = GUILayout.BeginScrollView(mainContentTextAreaScroll,
                                                                  false, false, GUILayout.Height(EditorGUIUtility.singleLineHeight * 10));

            GUI.SetNextControlName(textAreaControlName);
            dialog.stringValue = EnableCopyPasteMode ?
                                 EGL.TextArea(dialog.stringValue, style, GUILayout.ExpandHeight(true)) :
                                 GUILayout.TextArea(dialog.stringValue, style, GUILayout.ExpandHeight(true));

            EGL.EndScrollView();
        }
示例#25
0
 public override void OnInspectorGUI()
 {
     EGL.LabelField("已有道具:");
     items = ItemXmlManager.XmlReader.FindItems();
     for (int i = 0; i < items.Count; i++)
     {
         EGL.BeginHorizontal();
         EGL.LabelField(items[i]);
         if (!tryToAddNewItem && tryToModify == -1)
         {
             if (GUILayout.Button("修改"))
             {
                 tryToModify = i;
                 sm.LoadItemClassInfo(items[tryToModify]);
                 so.Update();
             }
             if (GUILayout.Button("删除"))
             {
                 sm.DeleteItemClass(items[i]);
                 so.Update();
             }
         }
         EGL.EndHorizontal();
     }
     if (tryToModify == -1 && tryToAddNewItem == false)
     {
         EGL.Separator();
         EGL.Separator();
         EGL.Separator();
         EGL.Separator();
         if (GUILayout.Button("添加一个新道具"))
         {
             tryToAddNewItem = true;
             sm.GetNewItemTemplate();
             so.Update();
         }
     }
     if (tryToModify != -1)
     {
         tryToAddNewItem = false;
         EGL.Separator();
         EGL.Separator();
         EGL.LabelField("类名:  " + items[tryToModify]);
         EGL.PropertyField(newItemName, new GUIContent("道具名字"));
         EGL.PropertyField(resources, new GUIContent("道具预置体"));
         EGL.LabelField("该预置体必须处于\"Resource/ItemPrefabs\"文件夹下!");
         EGL.BeginHorizontal();
         EGL.PropertyField(parameterName, new GUIContent("参数名字"), true);
         EGL.PropertyField(parameterValue, new GUIContent("参数值"), true);
         EGL.EndHorizontal();
         EGL.BeginHorizontal();
         if (GUILayout.Button("应用"))
         {
             so.ApplyModifiedProperties();
             sm.ModifyItem(items[tryToModify]);
             so.Update();
             tryToModify = -1;
         }
         if (GUILayout.Button("取消"))
         {
             tryToModify = -1;
         }
         EGL.EndHorizontal();
     }
     if (tryToAddNewItem)
     {
         EGL.Separator();
         EGL.Separator();
         EGL.PropertyField(newItemClassName, new GUIContent("类名"));
         EGL.PropertyField(newItemName, new GUIContent("道具名字"));
         EGL.PropertyField(resources, new GUIContent("道具预置体"));
         EGL.LabelField("该预置体必须处于\"Resource/ItemPrefabs\"文件夹下!");
         EGL.BeginHorizontal();
         EGL.PropertyField(parameterName, new GUIContent("参数名字"), true);
         EGL.PropertyField(parameterValue, new GUIContent("参数值"), true);
         EGL.EndHorizontal();
         EGL.BeginHorizontal();
         if (GUILayout.Button("应用"))
         {
             so.ApplyModifiedProperties();
             if (sm.CreateNewItemClass())
             {
                 tryToAddNewItem = false;
                 msg             = "";
             }
             else
             {
                 msg = "请先删除重名类!或更改一个新类名";
             }
         }
         if (GUILayout.Button("取消"))
         {
             tryToAddNewItem = false;
             msg             = "";
         }
         EGL.EndHorizontal();
     }
     EGL.LabelField(msg);
 }
示例#26
0
        public override void OnInspectorGUI()
        {
            var settings = (ImportSettings)target;

            Undo.RecordObject(settings, "AseFileSettings");

            using (new GL.HorizontalScope(EditorStyles.toolbar))
            {
                GL.Label("Options");
            }

            settings.generatePrefab = EGL.Toggle("Generate Prefab", settings.generatePrefab);
            settings.ppu            = EGL.IntField("Pixel Per Unit", settings.ppu);
            settings.alignment      = (SpriteAlignment)EGL.EnumPopup("Default Align", settings.alignment);
            if (settings.alignment == SpriteAlignment.Custom)
            {
                settings.customPivot = EGL.Vector2Field("Custom Pivot", settings.customPivot);
            }

            settings.densePacked = EGL.Toggle("Dense Pack", settings.densePacked);
            settings.border      = EGL.IntField("Border", settings.border);

            EGL.Space();
            if (settings.generatePrefab)
            {
                using (new GL.HorizontalScope(EditorStyles.toolbar))
                {
                    GL.Label("Prefab Options");
                }
                EGL.BeginHorizontal();

                string[] opetions = SortingLayer.layers.Select(it => it.name).ToArray();
                settings.sortIndex          = EGL.Popup("Sort In Layer", settings.sortIndex, opetions);
                settings.spritesSortInLayer = SortingLayer.NameToID(opetions[settings.sortIndex]);

                if (GL.Button("Edit", GL.Width(36)))
                {
                    Selection.objects = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");
                }
                EGL.EndHorizontal();
                settings.orderInLayerInterval = EGL.IntField("Interval of order in layer", settings.orderInLayerInterval);
            }

            EGL.Space();
            using (new GL.HorizontalScope(EditorStyles.toolbar))
            {
                GL.Label("Output");
            }

            settings.atlasOutputDirectory = PathSelection("Atlas Directory", settings.atlasOutputDirectory);
            settings.clipOutputDirectory  = PathSelection("Anim Clip Directory", settings.clipOutputDirectory);

            settings.controllerPolicy = (AnimControllerOutputPolicy)EGL.EnumPopup("Anim Controller Policy", settings.controllerPolicy);
            if (settings.controllerPolicy == AnimControllerOutputPolicy.CreateOrOverride || settings.controllerPolicy == AnimControllerOutputPolicy.CreateNotOverride)
            {
                settings.animControllerOutputPath = PathSelection("Anim Controller Directory", settings.animControllerOutputPath);
            }

            if (settings.generatePrefab)
            {
                settings.prefabsDirectory = PathSelection("Prefab Directory", settings.prefabsDirectory);
            }
        }
    void ShowTreemaps()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            GUILayout.Label("The settings for processing tree maps.");

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Postfix for treemap files.");
                importCfg.TreemapTag = EGL.TextField("Name postfix", importCfg.TreemapTag);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Treemap file specifications. Please use x^2.");
                importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("The prototypes to assign. (Current count: " + editorUtilities.TreePrototypes.Count + ")");

                EGL.Separator();

                EGL.BeginHorizontal();
                {
                    if (editorUtilities.TreePrototypes.Count >= 8)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Add Prototype"))
                    {
                        editorUtilities.TreePrototypes.Add(new TreePrototype());
                        importCfg.IsDirty = true; // Todo: Nasty
                    }
                    GUI.enabled = true;
                }
                EGL.EndHorizontal();

                // Show the list
                EGL.BeginVertical();
                {
                    _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        List <TreePrototype> removeThese = new List <TreePrototype>();
                        int i = 0;
                        foreach (TreePrototype prototype in editorUtilities.TreePrototypes)
                        {
                            if (ShowTreePrototype(prototype, i))
                            {
                                removeThese.Add(prototype);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (TreePrototype prototype in removeThese)
                        {
                            editorUtilities.TreePrototypes.Remove(prototype);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
    void ShowDetailMaps()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            GUILayout.Label("The settings for processing detail maps.");

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Postfix for detailmap files.");
                importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Splatmap file specifications. Please use x^2.");
                importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention);
                importCfg.SplatmapFlipX     = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX);
                importCfg.SplatmapFlipY     = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.DetailPrototypes.Count + ")");

                EGL.Separator();

                EGL.BeginHorizontal();
                {
                    if (editorUtilities.DetailPrototypes.Count >= 8)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Add Prototype"))
                    {
                        editorUtilities.DetailPrototypes.Add(new DetailPrototype());
                        importCfg.IsDirty = true; // Todo: Nasty, because the above prototypes still need to be converted to a serializable format, which is not directly done here
                    }
                    GUI.enabled = true;
                }
                EGL.EndHorizontal();

                // Show the list
                EGL.BeginVertical();
                {
                    _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        List <DetailPrototype> removeThese = new List <DetailPrototype>();
                        int i = 0;
                        foreach (DetailPrototype prototype in editorUtilities.DetailPrototypes)
                        {
                            if (ShowDetailPrototype(prototype, i))
                            {
                                removeThese.Add(prototype);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (DetailPrototype prototype in removeThese)
                        {
                            editorUtilities.DetailPrototypes.Remove(prototype);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
    void ShowSplatmaps()
    {
        LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance;
        ImporterConfiguration   importCfg       = editorUtilities.ImportCfg;

        EGL.BeginVertical();
        {
            GUILayout.Label("The settings for processing splatmaps.");

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Postfix for splatmap files.");
                importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("Splatmap file specifications. Please use x^2.");
                importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention);
                importCfg.SplatmapFlipX     = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX);
                importCfg.SplatmapFlipY     = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY);
                importCfg.TrimEmptyChannels = EGL.Toggle("Trim empty", importCfg.TrimEmptyChannels);
                importCfg.NormalizationMode = (NormalizationMode)EditorGUILayout.EnumPopup("Normalize mode", importCfg.NormalizationMode);
            }
            EGL.EndVertical();

            EGL.Separator();

            EGL.BeginVertical(GuiUtils.Skin.box);
            {
                GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.SplatPrototypes.Count + ")");

                EGL.Separator();

                EGL.BeginHorizontal();
                {
                    if (editorUtilities.SplatPrototypes.Count >= 8)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Add Prototype"))
                    {
                        editorUtilities.SplatPrototypes.Add(new SplatPrototype());
                        importCfg.IsDirty = true; // Todo: Nasty
                    }
                    GUI.enabled = true;

                    if (GUILayout.Button("Grab from Selected Terrain Object or Asset"))
                    {
                        GetPrototypesFromSelectedTerrain();
                        importCfg.IsDirty = true; // Todo: Nasty
                    }
                }
                EGL.EndHorizontal();

                // Show the list
                EGL.BeginVertical();
                {
                    _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height));
                    {
                        List <SplatPrototype> removeThese = new List <SplatPrototype>();
                        int i = 0;
                        foreach (SplatPrototype splatPrototype in editorUtilities.SplatPrototypes)
                        {
                            if (ShowSplatPrototype(splatPrototype, i))
                            {
                                removeThese.Add(splatPrototype);
                                importCfg.IsDirty = true; // Nasty
                            }
                            i++;
                        }
                        foreach (SplatPrototype splatPrototype in removeThese)
                        {
                            editorUtilities.SplatPrototypes.Remove(splatPrototype);
                        }
                    }
                    EGL.EndScrollView();
                }
                EGL.EndVertical();
            }
            EGL.EndVertical();
        }
        EGL.EndVertical();
    }
示例#30
0
        public override void OnInspectorGUI()
        {
            transition = (Transition)target;

            EditorGUI.BeginChangeCheck();

            var fromName    = transition.fromState.GetStatePreview();
            var toName      = transition.targetInfo;
            var displayName = fromName + "->" + toName;

            EGL.LabelField(displayName);
            EGL.Space();

            FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect);
            EGL.Space();

            transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType);

            if (transition.triggerRangeType == TriggerRangeType.Range)
            {
                transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange);
            }
            if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore)
            {
                transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec);
            }

            transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer);

            using (new EGL.VerticalScope(EditorStyles.helpBox))  {
                var conds      = transition.conditions;
                var paramNames = transition.profile.parameters.Select(it => it.name).ToArray();

                using (new EGL.HorizontalScope()) {
                    EGL.LabelField("Conditions", EditorStyles.boldLabel);
                    GL.FlexibleSpace();
                    if (GL.Button("+", GL.Width(30)))
                    {
                        conds.Add(new Condition());
                    }
                }
                for (int i = 0; i < conds.Count; ++i)
                {
                    var cond = conds[i];

                    EGL.BeginHorizontal();

                    int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name));

                    // cond.name = EGL.TextField(cond.name, GL.Width(70));
                    condSelectIndex = EGL.Popup(condSelectIndex, paramNames);
                    cond.name       = paramNames[condSelectIndex];

                    var param = transition.profile.FindParam(cond.name);
                    if (param == null)
                    {
                        EGL.LabelField("!Doesn't exist");
                    }
                    else
                    {
                        var type = param.type;
                        if (type == ParamType.Bool)
                        {
                            cond.boolValue = EGL.Toggle(cond.boolValue);
                        }
                        else if (type != ParamType.Trigger) // Trigger 不需要编辑
                        {
                            cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50));

                            if (type == ParamType.Int)
                            {
                                cond.intValue = EGL.IntField(cond.intValue);
                            }
                            else
                            {
                                cond.floatValue = EGL.FloatField(cond.floatValue);
                            }
                        }
                    }

                    GL.FlexibleSpace();
                    if (GL.Button("-", GL.Width(30)))
                    {
                        conds.RemoveAt(i);
                        --i;
                    }

                    EGL.EndHorizontal();
                }
            }

            EGL.LabelField("", GUI.skin.horizontalSlider);

            transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType);

            if (transition.actionType == ActionType.ChangeState)
            {
                EGL.BeginHorizontal();
                EGL.PrefixLabel("Target State");
                EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames,
                                               str => transition.targetStateName = str, ref targetStateRect);

                transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30));
                EGL.LabelField("F", GUILayout.Width(20));

                var targetState = transition.profile.FindState(transition.targetStateName);
                if (targetState)
                {
                    if (GL.Button("Focus"))
                    {
                        Utils.FocusEditingAnimation(transition.profile, targetState.stateName);
                    }
                }
                EGL.EndHorizontal();

                if (!targetState)
                {
                    EGL.HelpBox("No target state " + targetState, MessageType.Error);
                }
            }
            else // SendMessage
            {
                transition.messageName = EGL.TextField("Message Name", transition.messageName);

                EGL.Space();
                transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType);

                switch (transition.messageParType)
                {
                case MessageParType.Int:
                    transition.messageParInt = EGL.IntField("Value", transition.messageParInt);
                    break;

                case MessageParType.Float:
                    transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat);
                    break;

                case MessageParType.Bool:
                    transition.messageParBool = EGL.Toggle("Value", transition.messageParBool);
                    break;
                }
            }

            transition.priority    = EGL.IntField("Priority", transition.priority);
            transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay);
            if (transition.shouldDelay)
            {
                transition.delay = EGL.FloatField("Delay", transition.delay);
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(transition);
            }

            if (transition.fromState.type == FromStateType.State)
            {
                EGL.LabelField("", GUI.skin.horizontalSlider);
                using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                    EGL.LabelField("From State", EditorStyles.boldLabel);
                    ++EditorGUI.indentLevel;
                    var fromState = transition.profile.FindState(transition.fromState.stateOrTagName);
                    if (fromState)
                    {
                        GUI.enabled = false;
                        if (!fromStateEditor || fromStateEditor.target != fromState)
                        {
                            if (fromStateEditor)
                            {
                                DestroyImmediate(fromStateEditor);
                            }
                            fromStateEditor = Editor.CreateEditor(fromState);
                        }

                        fromStateEditor.OnInspectorGUI();
                        GUI.enabled = true;
                    }
                    --EditorGUI.indentLevel;
                }
            }
        }