Esempio n. 1
0
 private static bool _Cutoff2RMat(Material mat, string path)
 {
     if (mat.shader.name.Contains("CutoutDiffuse") ||
         mat.shader.name.Contains("TransparentDiffuse"))
     {
         Texture2D tex = mat.mainTexture as Texture2D;
         if (tex != null)
         {
             Texture2D alphaTex = TextureModify.ConvertTexRtex(tex);
             if (mat.shader.name.Contains("RimLight/CutoutDiffuse"))
             {
                 mat.shader = Shader.Find("Custom/RimLight/CutoutDiffuseMaskR");
             }
             else if (mat.shader.name.Contains("CutoutDiffuse") && mat.shader.name.Contains("NoLight"))
             {
                 mat.shader = Shader.Find("Custom/Common/CutoutDiffuseMaskRNoLight");
             }
             else if (mat.shader.name.Contains("CutoutDiffuse"))
             {
                 mat.shader = Shader.Find("Custom/Common/CutoutDiffuseMaskR");
             }
             else if (mat.shader.name.Contains("Common/TransparentDiffuse") && mat.shader.name.Contains("NoLight"))
             {
                 mat.shader = Shader.Find("Custom/Common/TransparentDiffuseMaskRNoLight");
             }
             else if (mat.shader.name.Contains("Common/TransparentDiffuse"))
             {
                 mat.shader = Shader.Find("Custom/Common/TransparentDiffuseMaskR");
             }
             mat.SetTexture("_Mask", alphaTex);
         }
     }
     return(true);
 }
Esempio n. 2
0
 private static void _PrcessSceneMat(Material mat, bool recover)
 {
     if (!processedMat.Contains(mat) && mat.shader != null)
     {
         if (mat.shader.name == "Transparent/Cutout/Diffuse" ||
             mat.shader.name == "Custom/Scene/CutoutDiffuseMaskLM")
         {
             Texture2D tex = mat.mainTexture as Texture2D;
             if (tex != null)
             {
                 if (recover)
                 {
                     string          texPath     = AssetDatabase.GetAssetPath(tex);
                     int             size        = tex.width > tex.height ? tex.width : tex.height;
                     TextureImporter texImporter = AssetImporter.GetAtPath(texPath) as TextureImporter;
                     texImporter.textureType   = TextureImporterType.Default;
                     texImporter.anisoLevel    = 0;
                     texImporter.mipmapEnabled = size > 256;
                     texImporter.npotScale     = TextureImporterNPOTScale.ToNearest;
                     texImporter.wrapMode      = TextureWrapMode.Repeat;
                     texImporter.filterMode    = FilterMode.Bilinear;
                     TextureImporterPlatformSettings pseting = new TextureImporterPlatformSettings();
                     pseting.format         = TextureImporterFormat.RGBA16;
                     pseting.name           = BuildTarget.Android.ToString();
                     pseting.maxTextureSize = size;
                     texImporter.SetPlatformTextureSettings(pseting);
                     pseting.name = BuildTarget.iOS.ToString();
                     texImporter.SetPlatformTextureSettings(pseting);
                     texImporter.isReadable = false;
                     AssetDatabase.ImportAsset(texPath, ImportAssetOptions.ForceUpdate);
                     mat.shader = Shader.Find("Transparent/Cutout/Diffuse");
                 }
                 else
                 {
                     Texture2D alphaTex = TextureModify.ConvertTexRtex(tex);
                     mat.shader = Shader.Find("Custom/Scene/CutoutDiffuseMaskLM");
                     mat.SetTexture("_Mask", alphaTex);
                 }
             }
             processedMat.Add(mat);
         }
     }
 }