Example #1
0
        public static void CollectMainFilter(AssetBundleFilterMain filter, ref AssetBundleCollector collector)
        {
            AssetBundleCollector mainCollector = new AssetBundleCollector();
            AssetBundleCollector subCollector  = new AssetBundleCollector();
            AssetBundleFilter    tmpF;

            mainCollector.Collect(filter.option, filter.resType, filter.path, filter.pattern, filter.assetbundleName);
            if (filter.HasSub())
            {
                for (int i = 0; i < filter.subFilterList.Count; ++i)
                {
                    tmpF = filter.subFilterList[i];
                    if (filter.subFilterList[i].isAppend)
                    {
                        subCollector.CollectAppend(mainCollector, tmpF.option, tmpF.resType, tmpF.path, tmpF.pattern, tmpF.assetbundleName, tmpF.independent);
                    }
                    else
                    {
                        subCollector.Collect(tmpF.option, tmpF.resType, tmpF.path, tmpF.pattern, tmpF.assetbundleName);
                    }
                }
            }
            collector.Mearge(mainCollector);
            collector.Mearge(subCollector);
        }
        int DrawFilter(AssetBundleFilterMain mainFilter, AssetBundleFilter filter)
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(50);



                //filter.independent = GUILayout.Toggle(filter.independent, "", GUILayout.ExpandWidth(false));

                if (filter.isAppend)
                {
                    if (filter.independent)
                    {
                        if (GUILayout.Button("I", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            filter.independent = false;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("A", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            filter.independent = true;
                        }
                    }
                    // 如果是添加类型子删选器,显示路径
                    filter.path = GUILayout.TextField(filter.path, GUILayout.MinWidth(150));
                }
                else
                {
                    // 否则,显示文件/文件夹
                    filter.target = EditorGUILayout.ObjectField(filter.target, filter.target.GetType(), GUILayout.MinWidth(150));
                }

                // 显示通用内容
                DrawContent(filter);

                // 转换类型按钮
                if (GUILayout.Button("┥", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                {
                    filter.isAppend = !filter.isAppend;
                }

                // 删除
                if (GUILayout.Button("X", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                {
                    mainFilter.subFilterList.Remove(filter);
                    return(1);
                }
            }
            GUILayout.EndHorizontal();
            return(0);
        }
Example #3
0
        public static AssetBundleCollector Collect(AssetBundleBuildConfig config)
        {
            AssetBundleCollector collector = new AssetBundleCollector();

            for (int i = 0; i < config.filters.Count; ++i)
            {
                AssetBundleFilterMain filter = config.filters[i];
                if (filter.valid)
                {
                    CollectMainFilter(filter, ref collector);
                }
            }
            return(collector);
        }
Example #4
0
 // 资源清单处理方法
 #region GameRes
 public static void ClearGameRes(AssetBundleBuildConfig config)
 {
     for (int i = 0; i < config.filters.Count; ++i)
     {
         AssetBundleFilterMain filter = config.filters[i];
         if (filter.valid)
         {
             ClearGameRes(filter.resType);
             if (filter.HasSub())
             {
                 for (int j = 0; j < filter.subFilterList.Count; ++j)
                 {
                     ClearGameRes(filter.subFilterList[j].resType);
                 }
             }
         }
     }
 }
        int DrawMainFilter(AssetBundleFilterMain filter)
        {
            GUILayout.BeginHorizontal();
            {
                //--------------------  展开/折叠 --------------------------------
                if (filter.HasSub())
                {
                    if (filter.showSub)
                    {
                        if (GUILayout.Button("◢", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            filter.showSub = !filter.showSub;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("▶", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            filter.showSub = !filter.showSub;
                        }
                    }
                }
                else
                {
                    GUILayout.Space(27);
                }

                // 勾选框
                filter.valid = GUILayout.Toggle(filter.valid, "", GUILayout.ExpandWidth(false));

                // 文件夹/文件
                filter.target = EditorGUILayout.ObjectField(filter.target, filter.target.GetType(), GUILayout.MinWidth(150));

                // 通用内容
                DrawContent(filter);

                // filter.searchOption = (SearchOption)EditorGUILayout.EnumPopup(filter.searchOption, GUILayout.MinWidth(120), GUILayout.ExpandWidth(false));

                // 添加子筛选器
                if (GUILayout.Button("+", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                {
                    filter.AddSubFilter(new AssetBundleFilter());
                }

                // 删除
                if (GUILayout.Button("X", GUILayout.ExpandWidth(false), GUILayout.Width(20), GUILayout.Height(15)))
                {
                    config.filters.Remove(filter);
                    return(1);
                }
            }
            GUILayout.EndHorizontal();

            // 显示子筛选器
            if (filter.IsShowSub())
            {
                for (int i = 0; i < filter.subFilterList.Count; ++i)
                {
                    i -= DrawFilter(filter, filter.subFilterList[i]);
                }
            }

            return(0);
        }
        void OnGUI()
        {
            bool hasNotValid = false;
            bool hasValid    = false;

            if (config == null)
            {
                config = LoadConfig();
                if (config == null)
                {
                    config = new AssetBundleBuildConfig();
                }
            }

            UpdateStyles();

            GUILayout.BeginHorizontal(Styles.toolbar);
            {
                for (int i = 0; i < config.filters.Count; ++i)
                {
                    if (!config.filters[i].valid)
                    {
                        hasNotValid = true;
                    }
                    else
                    {
                        hasValid = true;
                    }
                }

                if (GUILayout.Button(hasNotValid ? "SelectAll" : "UnselectAll", Styles.toolbarButton))
                {
                    for (int i = 0; i < config.filters.Count; ++i)
                    {
                        config.filters[i].valid = hasNotValid;
                    }
                }

                if (GUILayout.Button("Add", Styles.toolbarButton))
                {
                    config.filters.Add(new AssetBundleFilterMain());
                }

                if (GUILayout.Button("Gen", Styles.toolbarButton))
                {
                    AssetBundleBuilder.Build(config, true);
                }

                if (GUILayout.Button("Clear", Styles.toolbarButton))
                {
                    EditorApplication.delayCall += () =>
                    {
                        PathUtil.DeleteFileOrFolder(Application.streamingAssetsPath);
                        AssetDatabase.Refresh();
                        TTLoger.Log("清理完成!");
                    };
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            UnityEngine.Event e = UnityEngine.Event.current;
            if (e.type == EventType.scrollWheel)
            {
                scrollPos = new Vector2(0f, scrollPos.y + (-10) * e.delta.y);
            }
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);

            GUILayout.BeginVertical();
            for (int i = 0; i < config.filters.Count; i++)
            {
                AssetBundleFilterMain filter = config.filters[i];
                i -= DrawMainFilter(filter);
            }

            if (!hasValid)
            {
                GUI.enabled = false;
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Build"))
            {
                EditorApplication.delayCall += Build;
            }
            if (!hasValid)
            {
                GUI.enabled = true;
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();

            //set dirty
            if (GUI.changed)
            {
                Save();
            }

            UpdateEvent();
            Repaint();
        }