private void MaterialSplit(List <string> matPaths) { HashSet <string> texCache = new HashSet <string>(); foreach (var matPath in matPaths) { Material mat = AssetDatabase.LoadAssetAtPath <Material>(matPath); Shader shader = mat.shader; if (shader == null) { LogUtility.Log("[{0}]{1} Shader is Null ", "MaterialSplitAlphaModifier", matPath); continue; } string shaderPath = AssetDatabase.GetAssetPath(shader); if (shaderPath == "Resources/unity_builtin_extra") { LogUtility.LogError("[{0}]{1} Have No Alpha ETC1 Shader ", "MaterialSplitAlphaModifier", matPath); continue; } if (!shaderPath.EndsWith(m_AddedSuffix + ".shader", System.StringComparison.Ordinal)) { shaderPath = CRUtlity.DeleteExtension(shaderPath) + m_AddedSuffix + ".shader"; if (System.IO.File.Exists(shaderPath)) { shader = mat.shader = AssetDatabase.LoadAssetAtPath <Shader>(shaderPath); } else { LogUtility.LogError("[{0}]{1} Have No Alpha ETC1 Shader ", "MaterialSplitAlphaModifier", matPath); continue; } } for (int i = 0; i < ShaderUtil.GetPropertyCount(shader); ++i) { if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) { string propertyName = ShaderUtil.GetPropertyName(shader, i); if (propertyName.EndsWith(m_ShaderPropertyAlphaAddedSuffix, System.StringComparison.Ordinal)) { string mainPropertyName = propertyName.Replace(m_ShaderPropertyAlphaAddedSuffix, ""); Texture2D tex = (UnityEngine.Texture2D)mat.GetTexture(mainPropertyName); if (tex == null) { LogUtility.LogError("{0} {1} Texture is Null", matPath, mainPropertyName); continue; } string texPath = AssetDatabase.GetAssetPath(tex); string alphaTexPath = CRUtlity.DeleteExtension(texPath) + m_AddedSuffix + ".png"; if (!texCache.Contains(texPath)) { SplitAlphaTexture(texPath, alphaTexPath); texCache.Add(texPath); } Texture2D alpahTex = AssetDatabase.LoadAssetAtPath <Texture2D>(alphaTexPath); mat.SetTexture(propertyName, alpahTex); Resources.UnloadAsset(alpahTex); Resources.UnloadAsset(tex); } } } } }
public void Statistics(int inputCount, int outputCount) { m_InputCount = inputCount; m_OutputCount = outputCount; LogUtility.Log("Input Count :{0} * Output Count :{1} ", m_InputCount, m_OutputCount); }
public void StatisticsUseTime() { LogUtility.Log(" Use Time {0}", Time.realtimeSinceStartup - m_RunUseTime); }
public void Build() { try { InitPipline(); List <AssetFile> assetsNeedBuild = null; if (m_IAssetCollector != null) { m_IAssetCollector.Hanlde(out assetsNeedBuild); } else { return; } List <AssetFile> ganeraterAssets = null; m_IAssetGaneraters.ForEach(p => { p.Hanlde(assetsNeedBuild, out ganeraterAssets); assetsNeedBuild = ganeraterAssets; }); List <AssetFile> modifyAssets = null; m_IAssetModifiers.ForEach(p => { p.Hanlde(assetsNeedBuild, out modifyAssets); assetsNeedBuild = modifyAssets; }); List <AssetFileGroup> groups = null; if (m_IBundleBuidler != null) { m_IBundleNameBuilder.Hanlde(assetsNeedBuild, out groups); } else { return; } List <BundleFile> bundleFiles = null; if (m_IBundleBuidler != null) { m_IBundleBuidler.Hanlde(groups, out bundleFiles); } if (m_IBundleExporter != null) { m_IBundleExporter.Hanlde(bundleFiles); } else { return; } } catch (CResourcesException e) { LogUtility.LogError("{0} {1}", e.Message, e.StackTrace); } }