示例#1
0
 /// <summary>
 ///
 /// </summary>
 void OnGUI()
 {
     if (GUILayoutHelper.DrawHeader("常规", "1", true, false))
     {
         DrawGeneral();
     }
     if (GUILayoutHelper.DrawHeader("场景(" + EditorCommon.SCENE_START_PATH + ")", "2", true, false))
     {
         DrawScenes();
     }
     if (GUILayoutHelper.DrawHeader("资源(" + EditorCommon.ASSET_START_PATH + ")", "3", true, false))
     {
         DrawAssets();
     }
 }
        /// <summary>
        ///
        /// </summary>
        void OnGUI()
        {
            GUI.color = Color.white;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Current Resources Package", GUILayout.Width(176f));
            current_pack_name_ = GUILayout.TextField(current_pack_name_);
            if (GUILayout.Button("新建", GUILayout.Width(40f)))
            {
                ResourcesPackagesData.Package pack = new ResourcesPackagesData.Package()
                {
                    Name = current_pack_name_
                };
                AddPack(pack);
            }
            if (lastest_pack_ != null)
            {
                if (lastest_pack_.Name != current_pack_name_)
                {
                    if (GUILayout.Button("更新", GUILayout.Width(40f)))
                    {
                        UpdatePackName(lastest_pack_.Name, current_pack_name_);
                    }
                }
                else
                {
                    if (GUILayout.Button("删除", GUILayout.Width(40f)))
                    {
                        DeletePack(lastest_pack_.Name);
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            scroll_ = GUILayout.BeginScrollView(scroll_);
            foreach (var pack in Packages.Data.Packages)
            {
                GUI.color = Color.white;

                bool   state = EditorPrefs.GetBool(pack.Key, true);
                string head  = pack.Key;
                if (lastest_pack_ != null && head == lastest_pack_.Name)
                {
                    head = "<color=green>" + head + "</color>";
                }
                bool show = GUILayoutHelper.DrawHeader(head, pack.Key, true, false);
                if (show != state)
                {
                    lastest_pack_      = pack.Value;
                    current_pack_name_ = pack.Key;
                }

                if (show)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10f);
                    GUILayout.BeginVertical();
                    List <string> temp = new List <string>(pack.Value.AssetList);
                    foreach (var asset in temp)
                    {
                        string path  = EditorCommon.ProjectDirectory + asset;
                        bool   exist = System.IO.File.Exists(path) || System.IO.Directory.Exists(path);
                        GUI.color = exist ? Color.white : Color.red;
                        GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                        GUI.backgroundColor = Color.white;
                        GUILayout.Label(asset);

                        if (!exist)
                        {
                            GUILayout.Label("?", GUILayout.Width(22f));
                        }
                        if (GUILayout.Button("X", GUILayout.Width(22f)))
                        {
                            RemoveAsset(pack.Value, asset);
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();

                    GUI.color = Color.white;
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10f);
                    if (GUILayout.Button("添加选中的资源", GUILayout.Width(160f)))
                    {
                        AddSelectionAsset(pack.Value);
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(8f);
            if (GUILayout.Button("保存文件"))
            {
                SaveData();
                BuildAssetBundle.CopyResourcesPackageFileToStreamingAssets();
            }
        }