Exemplo n.º 1
0
    public static void GenAtlas()
    {
        LoadConfig();
        string[] dirs = config.GetChangedDir();
        PathUtil.EnsuerFolder(PathUtil.GetFullPath("Atlas"));

        // 召唤一个工人 ㄟ( ▔ , ▔ )ㄏ
        UGUIAtlasWorker worker = new UGUIAtlasWorker();
        Shader          shader = AssetDatabase.LoadAssetAtPath <Shader>("Assets/Shader/UI-Default.shader");

        // work work  (╯‵□′)╯︵┻━┻(摔!)
        if (dirs.Length > 0)
        {
            Process(GenAtlasProcessor, dirs, worker, FormatArg());
            Process(SplitAlphaProcessor, dirs, worker);    // mark readable
            Process(UpdateBorderProcessor, dirs, worker);
            Process(UpdateSettingProcessor, dirs, worker); // isReadable = false
            Process(GenMaterialProcessor, dirs, worker, shader);
            TTLoger.Log("哦!太感动了,居然成功了!");
        }
        else
        {
            TTLoger.Log("无美术资源变化,不需生成!");
        }

        dirs = config.GetRemovedList();
        Process(RemoveUnUsedProcessor, dirs, worker);

        // 验收记录 Y( ̄o ̄)Y
        config.UpdateAndGetChangedAtlas();
        EditorUtility.SetDirty(config);
        shader = null;
        Resources.UnloadUnusedAssets();
        AssetDatabase.Refresh();
    }
Exemplo n.º 2
0
    static void Log(StreamReader streamReader)
    {
        string s = streamReader.ReadToEnd();

        if (string.IsNullOrEmpty(s))
        {
            return;
        }
        TTLoger.Log(s);
    }
        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();
        }