예제 #1
0
        private void OnGUI()
        {
            if (DrawWorking(guidMapGen))
            {
                return;
            }

            findThingType = UTGUI.EnumToolbar(findThingType);

            EditorGUILayout.BeginVertical("box");

            scrollerPos = EditorGUILayout.BeginScrollView(scrollerPos);

            switch (findThingType)
            {
            case FindThingType.Assets:
                DrawFindAssetView();
                break;

            case FindThingType.CustomStr:
                DrawFindStrView();
                break;

            case FindThingType.BuiltinComponent:
                DrawFindBuiltinComponentView();
                break;
            }

            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            DrawOptionsView();
            GUILayout.EndVertical();
        }
예제 #2
0
    private void OnGUI()
    {
        curTab = UTGUI.EnumToolbar(curTab);
        switch (curTab)
        {
        case Tab.All:
            drawHistory(position.height / 2);
            drawBookmark();
            break;

        case Tab.Bookmark:
            drawBookmark();
            break;

        case Tab.History:
            drawHistory();
            break;
        }

        void drawHistory(float height = -1)
        {
            scrollPosHistory = height >= 0
                ? EditorGUILayout.BeginScrollView(scrollPosHistory, false, false, GUILayout.Height(height))
                : EditorGUILayout.BeginScrollView(scrollPosHistory, false, false);

            var removeCount = histories.RemoveAll(v => !v.asset);

            if (removeCount > 0)
            {
                saveHistories();
            }

            for (var i = histories.Count - 1; i >= 0; i--)
            {
                var v = histories[i];
                EditorGUILayout.ObjectField(v.asset, v.AssetType, false);
                GUILayout.Space(1.5f);
            }

            EditorGUILayout.EndScrollView();
        }

        void drawBookmark(float height = -1)
        {
            EditorGUILayout.BeginVertical("box");
            scrollPosBookmark = height >= 0
                ? EditorGUILayout.BeginScrollView(scrollPosBookmark, false, false, GUILayout.Height(height))
                : EditorGUILayout.BeginScrollView(scrollPosBookmark, false, false);

            for (var i = 0; i < bookmarks.Count; i++)
            {
                var v = bookmarks[i];
                if (v.path.IsNOE())
                {
                    bookmarks.RemoveAt(i);
                    saveBookmarks();
                    i--;
                    continue;
                }

                drawPath(v, i);
            }

            EditorGUILayout.BeginVertical("box", GUILayout.Height(30f));
            GUILayout.Space(10f);
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Drag folder here to add bookmark");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10f);
            EditorGUILayout.EndVertical();
            var dragObjs = UTGUI.HandleDrag();

            if (dragObjs != null && dragObjs.Length > 0)
            {
                foreach (var obj in dragObjs)
                {
                    if (obj != null && obj is DefaultAsset)
                    {
                        var path = AssetDatabase.GetAssetPath(obj);
                        if (!bookmarks.Exists(v => v.path == path))
                        {
                            bookmarks.Add(new Bookmark(path));
                            saveBookmarks();
                            Repaint();
                        }
                    }
                }
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }

        void drawPath(Bookmark bookmark, int index)
        {
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Space(4f);
            bookmark.path = EditorGUILayout.TextField(bookmark.path);
            GUILayout.EndVertical();

            if (GUILayout.Button(bookmark.name))
            {
                UToolsUtil.HighlightProjectPath(bookmark.path);
            }

            GUILayout.EndHorizontal();
            var dragObjs = UTGUI.HandleDrag(DragAndDropVisualMode.Copy);

            if (dragObjs != null && dragObjs.Length > 0)
            {
                foreach (var obj in dragObjs)
                {
                    if (obj.IsAsset())
                    {
                        var assetPath = AssetDatabase.GetAssetPath(obj);
                        var assetName = Path.GetFileName(assetPath);
                        var newPath   = Path.Combine(bookmark.path, assetName);
                        if (newPath == assetPath)
                        {
                            return;
                        }

                        var error = AssetDatabase.MoveAsset(assetPath, newPath);
                        if (error.IsNNOE())
                        {
                            Debug.LogError(error);
                        }
                    }
                }
            }
        }
    }
예제 #3
0
        private void DrawFindAssetView()
        {
            if (DrawWorking(assetRefFinder))
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();

            findAssetMode = UTGUI.EnumToolbar(findAssetMode);

            if (findAssetMode == FindAssetsMode.Field)
            {
                whenShouldFind = WhenShouldFind.ClickFind;
            }

            EditorGUI.BeginDisabledGroup(findAssetMode == FindAssetsMode.Field);
            whenShouldFind = UTGUI.EnumToolbar(whenShouldFind);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndHorizontal();

//            this.findAssetFrom = MaidEditorGUI.EnumToolbar<FindAssetFrom>(0x1004);

            var objType = ReferenceToolUtil.type_object;

            if (curFindAsset && !(curFindAsset is DefaultAsset))
            {
                objType = curFindAsset.GetType();
            }

            if (findAssetMode == FindAssetsMode.Field)
            {
                curFindAsset = EditorGUILayout.ObjectField(
                    "FindTarget:",
                    curFindAsset,
                    objType,
                    false
                    );
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("FindTarget:", curFindAsset, objType, false);
                EditorGUI.EndDisabledGroup();
            }

            if (enableReplace)
            {
                EditorGUILayout.BeginHorizontal();

                replaceTargetAsset = EditorGUILayout.ObjectField(
                    "ReplaceTarget:",
                    replaceTargetAsset,
                    objType,
                    false
                    );

                EditorGUILayout.EndHorizontal();
            }

            if (curFindAsset is GameObject)
            {
                enableReplace = false;
            }
            else
            {
                enableReplace = EditorGUILayout.ToggleLeft(
                    "EnableReplace",
                    enableReplace,
                    GUILayout.Width(100f)
                    );
            }

            if (GUILayout.Button("Find"))
            {
                DoFindAssets();
            }

            DrawResultView(assetRefFinder);
        }