示例#1
0
        void OnDrawList(int _id)
        {
            if (GUILayout.Button("Pickup Path"))
            {
                string path = "";
                foreach (var v in Selection.objects)
                {
                    path = AssetDatabase.GetAssetPath(v);
                    if (!string.IsNullOrEmpty(path))
                    {
                        int nameLen = Path.GetFileName(path).Length;
                        PathRoot = path.Remove(path.Length - nameLen - 1, nameLen + 1);
                        PathRoot = PathRoot.Substring(6);
                        Debug.Log(PathRoot);
                        break;
                    }
                }
            }

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("AssemblyName:", GUILayout.MaxWidth(120));
            AssemlyName = EditorGUILayout.TextField(AssemlyName);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Path:", GUILayout.MaxWidth(50));
            PathRoot = GUILayout.TextField(PathRoot);
            if (GUILayout.Button("Search", GUILayout.MaxWidth(listRect.width / 4f)))
            {
                SearchListFile();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Search:", GUILayout.MaxWidth(50));
            string nextSearch = GUILayout.TextField(SearchFile);

            GUILayout.EndHorizontal();

            if (nextSearch != SearchFile)
            {
                SearchFile = nextSearch;
                FileFilter.Clear();
                if (SearchFile != "")
                {
                    foreach (var v in Files)
                    {
                        if (v.name.Contains(SearchFile))
                        {
                            FileFilter.Add(v);
                        }
                    }
                }
            }

            var show = SearchFile.Length > 0 ? FileFilter : Files;

            ListScrollViewPos = GUILayout.BeginScrollView(ListScrollViewPos);
            GUILayout.BeginVertical();
            float normal = listRect.width / 4 * 3;
            float select = listRect.width;

            foreach (var v in show)
            {
                bool seem = Seem(Select, v);
                if (GUILayout.Button(v.name, GUILayout.MaxWidth(seem ? select:normal)))
                {
                    if (!seem)
                    {
                        Select = v;
                        TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(AssetDatabase.GetAssetPath(v.targetInstaneId));
                        if (asset != null)
                        {
                            string      assemlyName = string.IsNullOrEmpty(AssemlyName) ? "Assembly-CSharp" : AssemlyName;
                            string      key         = Assembly.CreateQualifiedName(assemlyName, v.name);
                            System.Type type        = System.Type.GetType(key);
                            if (type != null)
                            {
                                DB.LoadData(type, asset.text);
                                Titles = DB.GetTitle(v.name);
                                SetContents(DB.Select(v.name, "", true));
                            }
                        }
                    }
                    else
                    {
                        if (Seem(Focus, v))
                        {
                            Focus = null;
                        }
                        else
                        {
                            Focus = v;
                            EditorGUIUtility.PingObject(v.targetInstaneId);
                        }
                    }
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            if (show.Count == 0)
            {
                EditorGUILayout.HelpBox("Empty", MessageType.Warning);
            }
            EditorGUILayout.HelpBox(Application.dataPath + PathRoot, MessageType.None);
        }