コード例 #1
0
        private bool EnsureReplaceToStr(ReferenceToolBase maid)
        {
            var result = false;

            switch (findThingType)
            {
            case FindThingType.Assets:
                if (replaceTargetAsset)
                {
                    var(guid, fileID) =
                        UToolsUtil.GetAssetGUIDAndFileID(replaceTargetAsset);
                    if (guid.IsNNOE())
                    {
                        replaceTargetString = $"guid: {guid}";
                        result = true;
                    }
                }

                break;

            case FindThingType.BuiltinComponent:
                result = false;
                break;

            case FindThingType.CustomStr:
                result = replaceTargetString.IsNNOE();
                break;
            }

            maid.EnsureReplaceToStr(replaceTargetString);
            return(result);
        }
コード例 #2
0
        private void DrawResultView(ReferenceToolBase worker)
        {
            GUILayout.Space(3f);
            EditorGUILayout.LabelField($"Find Result:{worker.findResult.Count}");
            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginDisabledGroup(!(enableReplace && worker.findResult.Count > 0));
            EditorGUI.BeginDisabledGroup(worker.findResult.Count == 0);

            if (enableReplace && replaceTargetAsset)
            {
                if (GUILayout.Button("ReplaceAll", GUILayout.Width(90f), GUILayout.Height(16)))
                {
                    if (EnsureReplaceToStr(worker))
                    {
                        worker.ReplaceStringAll();
                    }
                }

                EditorGUI.BeginDisabledGroup(worker.replaceResult.Count == 0);
                if (GUILayout.Button("RevertAll", GUILayout.Width(90f), GUILayout.Height(16)))
                {
                    worker.RevertReplaceInfoAll();
                }
            }

            EditorGUI.EndDisabledGroup();
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(3f);
            foreach (var v in worker.findResult)
            {
                if (v == null)
                {
                    continue;
                }

                DrawUFileInfo(v, worker);
                GUILayout.Space(2f);
            }
        }
コード例 #3
0
        private void DrawUFileInfo(UFileInfo v, ReferenceToolBase maid)
        {
            GUILayout.BeginHorizontal();
            var content = EditorGUIUtility.ObjectContent(null, v.assetType);

            content.text = v.fileName;
            if (GUILayout.Button(
                    content,
                    EditorStyles.objectField,
                    GUILayout.Height(16f),
                    GUILayout.Width(250f)
                    ))
            {
                EditorGUIUtility.PingObject(v.asset);
            }

//        EditorGUI.BeginDisabledGroup(true);
//        EditorGUILayout.ObjectField(v.Obj, v.ObjType, false);
//        EditorGUI.EndDisabledGroup();
            switch (v.extension)
            {
            case ".prefab":
            case ".unity":
                if (GUILayout.Button("Open", GUILayout.Height(16)))
                {
                    EditRefer(v);
                }

                break;
            }

            EditorGUI.BeginDisabledGroup(!enableReplace);
            DrawUFileInfoReplacePne(v, maid);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
コード例 #4
0
        private void DrawUFileInfoReplacePne(UFileInfo v, ReferenceToolBase worker)
        {
            if (v.assetFrom == AssetFrom.Resources)
            {
                //todo 暂时禁用
                return;
            }

            if (v.isWaiting)
            {
                GUILayout.Label("Waiting...", GUILayout.Height(16));
            }

            else
            {
                var replaceInfo = worker.FindReplaceInfo(v.relativePath);
                if (replaceInfo != null)
                {
                    if (GUILayout.Button("Revert", GUILayout.Width(60f), GUILayout.Height(16)))
                    {
                        worker.RevertReplace(replaceInfo);
                    }
                }
                else
                {
                    switch (findThingType)
                    {
                    case FindThingType.Assets:
                        if (!(curFindAsset is GameObject))
                        {
                            EditorGUI.BeginDisabledGroup(!replaceTargetAsset);
                            {
                                if (GUILayout.Button(
                                        "Replace",
                                        GUILayout.Width(60f),
                                        GUILayout.Height(16)
                                        ))
                                {
                                    if (EnsureReplaceToStr(worker))
                                    {
                                        worker.ReplaceOne(v);
                                    }
                                }

                                EditorGUI.EndDisabledGroup();
                            }
                        }


                        break;

                    case FindThingType.CustomStr:
                        EditorGUI.BeginDisabledGroup(!replaceTargetString.IsNNOE());
                        if (GUILayout.Button(
                                "Replace",
                                GUILayout.Width(60f),
                                GUILayout.Height(16)
                                ))
                        {
                            if (EnsureReplaceToStr(worker))
                            {
                                worker.ReplaceOne(v);
                            }
                        }

                        EditorGUI.EndDisabledGroup();
                        break;
                    }
                }
            }
        }