static void ChangeToEntityShader() { CorruptShaderReplacement.ReadShaderPairsTbl(false, true); for (int i = 0; i < Selection.gameObjects.Length; i++) { if (CorruptShaderReplacement.ReplaceShaderShellWithEntity(Selection.gameObjects[i])) { Debug.Log("Succeed in ToEntityShader:" + Selection.gameObjects[i].name); } } }
void Awake() { Renderer[] renders = transform.GetComponentsInChildren <Renderer>(); foreach (Renderer rd in renders) { foreach (Material mat in rd.materials) { Shader sh = CorruptShaderReplacement.FindValidShader(mat.shader.name); if (sh != null) { mat.shader = sh; } } } }
static void CreateAssetBundlesEach(string dirName) { string dirSubPath = dirName == null ? "" : (dirName + "/"); string dirPath = GameConfig.AssetBundlePath + dirSubPath; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } int nGo = Selection.gameObjects.Length; CorruptShaderReplacement.ReadShaderPairsTbl(true, true); for (int i = 0; i < nGo; i++) { CorruptShaderReplacement.ReplaceShaderEntityWithShell(Selection.gameObjects[i]); } List <AssetBundleBuild> builds = new List <AssetBundleBuild>(); int nObj = Selection.objects.Length; for (int i = 0; i < nObj; i++) { //ExportResource(dirPath, Selection.objects[i]); AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = Selection.objects[i].name + ".unity3d"; build.assetNames = new string[] { AssetDatabase.GetAssetPath(Selection.objects[i]) }; builds.Add(build); } BuildPipeline.BuildAssetBundles(dirPath, builds.ToArray()); for (int i = 0; i < nGo; i++) { CorruptShaderReplacement.ReplaceShaderShellWithEntity(Selection.gameObjects[i]); } }