Ejemplo n.º 1
0
    public static void AssetBundleClearMark()
    {
        string[] list = AssetDatabase.GetAllAssetBundleNames();
        for (int i = 0; i < list.Length; i++)
        {
            AssetDatabase.RemoveAssetBundleName(list[i], true);
        }
        ABBuilder builder = ABBuilderTools.Create(true);

        builder.config.ClearMark();
        builder.SaveConfig();
    }
Ejemplo n.º 2
0
    static void CreateReplaceShaderScript(string[] files)
    {
        List <Renderer> renderList = new List <Renderer>();
        List <Image>    imageList  = new List <Image>();

        for (int i = 0; i < files.Length; i++)
        {
            renderList.Clear();
            imageList.Clear();
            GameObject obj     = AssetDatabase.LoadAssetAtPath <GameObject>(files[i]);
            var        renders = obj.GetComponentsInChildren <Renderer>(true);
            ABBuilderTools.DisplayProgressBar("shader", i, files.Length);

            for (int k = 0; k < renders.Length; k++)
            {
                Renderer render = renders[k];
                if (render.sharedMaterial != null && !string.IsNullOrEmpty(render.sharedMaterial.shader.name))
                {
                    renderList.Add(render);
                }
            }

            var images = obj.GetComponentsInChildren <Image>(true);
            for (int k = 0; k < images.Length; k++)
            {
                Image image = images[k];
                if (image.material != null && !string.IsNullOrEmpty(image.material.shader.name) && image.material.shader.name.IndexOf("Error") == -1)
                {
                    imageList.Add(image);
                }
            }
            ShaderReplace shaderReplace = obj.GetComponent <ShaderReplace>();
            if (renderList.Count == 0 && imageList.Count == 0)
            {
                if (shaderReplace != null)
                {
                    GameObject.DestroyImmediate(shaderReplace, true);
                    EditorUtility.SetDirty(obj);
                }
            }
            else
            {
                if (shaderReplace == null)
                {
                    shaderReplace = obj.AddComponent <ShaderReplace>();
                }
                shaderReplace.renderArray = renderList.ToArray();
                shaderReplace.imageArray  = imageList.ToArray();
                EditorUtility.SetDirty(obj);
            }
        }
        ABBuilderTools.ClearProgressBar();
    }