コード例 #1
0
ファイル: Sample.cs プロジェクト: tylearymf/UnityStepPlayTool
 static void A()
 {
     EditorInputDialog.Display("test", string.Empty, pValue =>
     {
         Debug.Log(pValue);
     }, pOkCloseView: false);
 }
コード例 #2
0
 static void StepPlay()
 {
     EditorInputDialog.Display("请输入延迟时间(>=0)", mStepTime.ToString(), pText =>
     {
         var tDelayTime = 0F;
         if (float.TryParse(pText, out tDelayTime) && tDelayTime >= 0)
         {
             StepPlayLogic(tDelayTime);
         }
         else
         {
             Debug.LogError("输入有误");
         }
     }, () =>
     {
         CancelStepPlay();
     }, false, "重新播放延迟", "取消延迟", false, false);
 }
コード例 #3
0
    public static void CreateUI()
    {
        GameObject uiParent = Selection.activeGameObject;

        if (uiParent == null)
        {
            Debug.LogError("请选择UI的父节点");
            return;
        }

        string scriptPath = Application.dataPath + "/Scripts/UI";

        if (!Directory.Exists(scriptPath))
        {
            Debug.Log("创建脚本文件夹" + scriptPath);
            Directory.CreateDirectory(scriptPath);
        }

        EditorInputDialog editorInputDialog = EditorWindow.GetWindowWithRect <EditorInputDialog>(new Rect(Input.mousePosition.x, Input.mousePosition.y, 300, 100), true, "创建UI");

        editorInputDialog.Show((input) =>
        {
        });
    }
コード例 #4
0
        protected override void OnBeginDrawEditors()
        {
            var selected      = this.MenuTree.Selection.FirstOrDefault();
            var toolbarHeight = this.MenuTree.Config.SearchToolbarHeight;

            // Draws a toolbar with the name of the currently selected menu item.
            SirenixEditorGUI.BeginHorizontalToolbar(toolbarHeight);
            {
                if (selected != null)
                {
                    GUILayout.Label(selected.Name);

                    if (selected.Value.GetType() == typeof(Domain))
                    {
                        Domain currentDomain = (Domain)selected.Value;
                        if (SirenixEditorGUI.ToolbarButton(new GUIContent("Add New Feature")))
                        {
                            // Add Feature Here
                            EditorInputDialog.Show("New Feature", "Enter new Feature name", "", ret: val =>
                            {
                                if (!string.IsNullOrEmpty(val))
                                {
                                    var newFeature = new Feature()
                                    {
                                        name       = val,
                                        components = new List <Component>(),
                                    };
                                    _currentFeatures.AddIfNotContains(newFeature);
                                    MenuTree.Add($"{currentDomain.name}/{newFeature.name}", newFeature);
                                    base.TrySelectMenuItemWithObject(newFeature);
                                    hasUnsavedChanges = true;
                                }
                            });
                        }

                        if (SirenixEditorGUI.ToolbarButton(new GUIContent("Add Existing Feature")))
                        {
                            // Add Feature Here
                            var features             = domains.Select(item => item.features).ToList();
                            var distinctFeatures     = features.SelectMany(list => list).Distinct().ToList();
                            var distinctFeatureNames = distinctFeatures.Select(item => item.name).ToList();

                            string selectedFeatureName = distinctFeatureNames[0];

                            GenericSelector <string> selector = new GenericSelector <string>("Title", false, distinctFeatureNames);
                            selector.SetSelection(selectedFeatureName);
                            selector.SelectionTree.Config.DrawSearchToolbar = true;
                            selector.SelectionTree.DefaultMenuStyle.Height  = 22;
                            selector.SelectionConfirmed += (selection) =>
                            {
                                selectedFeatureName = selection.FirstOrDefault();
                                var selectedFeature = new Feature(distinctFeatures.FirstOrDefault(item => item.name == selectedFeatureName));
                                _currentFeatures.AddIfNotContains(selectedFeature);
                                MenuTree.Add($"{currentDomain.name}/{selectedFeature.name}", selectedFeature);
                                base.TrySelectMenuItemWithObject(selectedFeature);
                                hasUnsavedChanges = true;
                            };
                            var popup = selector.ShowInPopup();
                        }

                        if (SirenixEditorGUI.ToolbarButton(new GUIContent("Delete Domain")))
                        {
                            // Delete Domains Here
                            EditorYesNoDialog.Show("Delete Domain?", "Are you sure, this will delete the\n domain with its entire hierarchy!", () =>
                            {
                                domains.Remove(currentDomain);
                                ForceMenuTreeRebuild();
                                hasUnsavedChanges = true;
                            }, () =>
                            {
                                // Do Nothing
                            });
                        }
                    }
                    else if (selected.Value.GetType() == typeof(Feature))
                    {
                        Domain  currentDomain  = (Domain)selected.Parent.Value;
                        Feature currentFeature = (Feature)selected.Value;
                        if (SirenixEditorGUI.ToolbarButton(new GUIContent("Add Component")))
                        {
                            // Add Component Here
                            EditorInputDialog.Show("New Component", "Enter new Component name", "", ret: val =>
                            {
                                if (!string.IsNullOrEmpty(val))
                                {
                                    var newComponent = new Component()
                                    {
                                        name  = val,
                                        asset = null,
                                    };
                                    _currentComponents.Add(newComponent);
                                    MenuTree.Add($"{currentDomain.name}/{currentFeature.name}/{newComponent.name}", newComponent);
                                    base.TrySelectMenuItemWithObject(newComponent);
                                    hasUnsavedChanges = true;
                                }
                            });
                        }

                        if (SirenixEditorGUI.ToolbarButton(new GUIContent("Delete Feature")))
                        {
                            // Delete Domains Here
                            EditorYesNoDialog.Show("Delete Feature?", "Are you sure, this will delete the\n feature with its entire hierarchy!", () =>
                            {
                                currentDomain.features.Remove(currentFeature);
                                ForceMenuTreeRebuild();
                                hasUnsavedChanges = true;
                            }, () =>
                            {
                                // Do Nothing
                            });
                        }
                    }
                    else if (selected.Value.GetType() == typeof(Component))
                    {
                        Domain    currentDomain    = (Domain)selected.Parent.Parent.Value;
                        Feature   currentFeature   = (Feature)selected.Parent.Value;
                        Component currentComponent = (Component)selected.Value;
                        if (SirenixEditorGUI.ToolbarButton(new GUIContent("Delete Component")))
                        {
                            // Delete Domains Here
                            EditorYesNoDialog.Show("Delete Component?", "Are you sure, this will delete the component!", () =>
                            {
                                currentFeature.components.Remove(currentComponent);
                                ForceMenuTreeRebuild();
                                hasUnsavedChanges = true;
                            }, () =>
                            {
                                // Do Nothing
                            });
                        }
                    }
                }

                if (SirenixEditorGUI.ToolbarButton(new GUIContent("Add Domain")))
                {
                    // Add Domain Here
                    EditorInputDialog.Show("New Domain", "Enter new Domain name", "", ret: val =>
                    {
                        if (!string.IsNullOrEmpty(val))
                        {
                            var newDomain = new Domain()
                            {
                                name     = val,
                                features = new List <Feature>(),
                            };
                            domains.Add(newDomain);
                            MenuTree.Add(newDomain.name, newDomain);
                            base.TrySelectMenuItemWithObject(newDomain);
                            hasUnsavedChanges = true;
                        }
                    });
                }

                if (SirenixEditorGUI.ToolbarButton(new GUIContent("Save")))
                {
                    SaveChanges();
                    hasUnsavedChanges = false;
                }
            }
            SirenixEditorGUI.EndHorizontalToolbar();
        }