[Unity] Assetbundle Shader 遺失的解決方案
物件打包成 AssetBundle 後有的物件上的材質的shader 會 lost 變一塊紫色
//assetbundle後shader會lost的處理 gameObject.renderer.material.shader = Shader.Find(gameObject.renderer.material.shader.name);或是
using UnityEngine; using System.Collections; public class ApplyShader : MonoBehaviour { private Material[] thisMaterial; private string[] shaders; void Start () { thisMaterial = this.renderer.sharedMaterials; shaders = new string[thisMaterial.Length]; for( int i = 0; i < thisMaterial.Length; i++){ shaders[i] = thisMaterial[i].shader.name; } for( int i = 0; i < thisMaterial.Length; i++){ thisMaterial[i].shader = Shader.Find(shaders[i]); } } }