Пример #1
0
        public static void SplitChannelETC(Material mat)
        {
            if (mat.shader.name != ShaderId.UI)
            {
                return;
            }
            string[] paths   = TextureUtil.SplitChannel4ETC(mat.mainTexture);
            string   rgbPath = paths[0];
            string   aPath   = paths[1];

            if (mat.mainTexture.width == mat.mainTexture.height)
            {
                mat.shader = Shader.Find(ShaderId.UI_SPLIT);
                mat.SetTexture("_MainTex", AssetDatabase.LoadAssetAtPath <Texture>(rgbPath));
                mat.SetTexture("_AlphaTex", AssetDatabase.LoadAssetAtPath <Texture>(aPath));
            }
            else if (mat.mainTexture.width == mat.mainTexture.height * 2)
            {
                string appendPath = TextureUtil.AppendVertically(rgbPath, aPath);
                mat.shader = Shader.Find(ShaderId.UI_VERT);
                mat.SetVector("_Coord", new Vector4(0.5f, 0, 0.5f, 0.5f));
                mat.SetTexture("_MainTex", AssetDatabase.LoadAssetAtPath <Texture>(appendPath));
            }

            BuildScript.SetDirty(mat);
            AssetDatabase.SaveAssets();
        }