Пример #1
0
    private void OnGUI()
    {
        // 方法一:
        // 需要构建的路径
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("需要打包的路径 (鼠标拖拽文件夹到这里)");
        EditorGUILayout.Space();
        // this.path = EditorGUILayout.TextField(this.path);
        GUI.SetNextControlName("input1");//设置下一个控件的名字
        pathRect = EditorGUILayout.GetControlRect(GUILayout.Width(400));
        path     = EditorGUI.TextField(pathRect, path);
        EditorGUILayout.Space();

        // 构建后的路径
        EditorGUILayout.LabelField("打包后的路径 (鼠标拖拽文件夹到这里)");
        EditorGUILayout.Space();
        // this.buildPath = EditorGUILayout.TextField(this.buildPath);
        GUI.SetNextControlName("input2");//设置下一个控件的名字
        buildPathRect = EditorGUILayout.GetControlRect(GUILayout.Width(400));
        buildPath     = EditorGUI.TextField(buildPathRect, buildPath);
        EditorGUILayout.Space();

        // 文件拖拽
        DragFolder();


        // 方法二(更简洁):
        EditorGUILayoutTools.DrawObjectField("添加文件夹", ref destDir, typeof(Object), (v) =>
        {
            path1 = AssetDatabase.GetAssetPath(destDir);
            Debug.Log("路径:" + path1);
        });
        EditorGUILayout.TextField(path1);
    }
Пример #2
0
        void OnGUI()
        {
            EditorGUILayoutTools.Horizontal(() =>
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("快速定位GUI文件夹", GUILayout.Width(150), GUILayout.Height(30)))
                {
                    var assetObj = AssetDatabase.LoadAssetAtPath <Object>(GUIPath);
                    EditorGUIUtility.PingObject(assetObj);
                }
                GUILayout.FlexibleSpace();
            });

            GUILayout.Space(15);

            EditorGUILayoutTools.Horizontal(() =>
            {
                inputText = EditorGUILayout.TextField("输入需要查找的Text", inputText);
            });

            EditorGUILayoutTools.Horizontal(() =>
            {
                searchType = (SearchType)EditorGUILayout.EnumPopup("匹配模式", searchType, "ToolbarPopup");
            });

            for (int i = 0; i < destDirList.Count; i++)
            {
                EditorGUILayoutTools.Horizontal(() =>
                {
                    destDirList[i] = EditorGUILayout.ObjectField("文件夹" + (i + 1), destDirList[i], typeof(Object), false);
                    if (GUILayout.Button("Delete", GUILayout.Width(50), GUILayout.Height(15)))
                    {
                        destDirList.RemoveAt(i);
                    }
                });
            }

            EditorGUILayoutTools.DrawObjectField("添加文件夹", ref destDir, typeof(Object), (v) =>
            {
                if (destDirList.Contains(destDir))
                {
                    EditorUtility.DisplayDialog("添加失败!", "已经添加该文件夹", "OK");
                    destDir = null;
                }
                else
                {
                    destDirList.Add(destDir);
                    destDir = null;
                }
            });

            if (prefabList.Count > 0)
            {
                EditorGUILayoutTools.DrawPopup("预制体列表", ref selectIndex, prefabList.ToArray(), (path) =>
                {
                    selectPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(RecoverPrefabPath(path));
                    EditorGUIUtility.PingObject(selectPrefab);
                });
            }

            GUILayout.Space(30);
            EditorGUILayoutTools.Horizontal(() =>
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("查找预制体", GUILayout.Width(300), GUILayout.Height(40)))
                {
                    if (inputText == null || inputText.Equals(""))
                    {
                        EditorUtility.DisplayDialog("查找失败!", "请输入需要查找的字符!", "OK");
                        return;
                    }
                    var stime = EditorApplication.timeSinceStartup;
                    StartSearch();
                    Debug.Log("查询时间:" + (EditorApplication.timeSinceStartup - stime).ToString());
                }
                GUILayout.FlexibleSpace();
            });
            GUILayout.Space(30);
        }
Пример #3
0
    private void OnGUI()
    {
        GUIStyle style = new GUIStyle();

        style.fontSize         = 16;
        style.normal.textColor = new Color32(255, 255, 255, 255);
        GUILayout.Space(15);

        EditorGUILayoutTools.DrawSliderField("曲线宽度", ref lineWidth, 1, (v) =>
        {
            SetLineWidth(v);
        });
        EditorGUILayout.Space(10);

        EditorGUILayout.BeginHorizontal();
        {
            EditorGUILayoutTools.DrawObjectField("曲线材质", ref lineMat, typeof(Material), (v) =>
            {
                SetLineMat(v);
            });

            EditorGUILayoutTools.DrawGradientField("曲线颜色", ref lineColor, (v) =>
            {
                SetLineColor();
            });
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space(10);
        EditorGUILayoutTools.DrawColorField("辅助线颜色", ref sublineColor, (v) =>
        {
            SetSublineColor(v);
        });
        EditorGUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        {
            EditorGUILayoutTools.DrawObjectField("执行对象", ref player, typeof(GameObject), (v) =>
            {
                // SetLineMat(player);
            });

            EditorGUILayoutTools.DrawFloatField("运动时长", ref duration, (v) => { });

            EditorGUILayoutTools.DrawEnumPopup("Ease", ref ease, (value) => { });
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space(10);

        EditorGUILayoutTools.DrawTextField("曲线保存路径", ref curPath, (v) => { });

        EditorGUILayout.Space(10);

        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("保存曲线为预制体", GUILayout.Height(20)))
            {
                SaveCurvePrefab();
            }

            if (GUILayout.Button("播放", GUILayout.Height(20)))
            {
                Run();
            }
        }
        EditorGUILayout.EndHorizontal();
    }