全局修改此材质的所有实例的着色器值:
Material mat = Resources.Load("BGRingMat") as Material;
mat.SetFloat( "Radio2", bgRingMaterialRadio2);
或修改 1 个对象:
renderer.material = Resources.Load("BGRingMat") as Material;
renderer.material.SetFloat( "Radio2", bgRingMaterialRadio2);
请注意,如果您先直接修改对象的材质,然后尝试使用共享材质,则不会发生任何事情:
Material mat = Resources.Load("BGRingMat") as Material;
// Sets Radio2 to bgRingMaterialRadio2
renderer.material.SetFloat( "Radio2", bgRingMaterialRadio2);
// Doesn't do anything to the current object as this object now has its own copy.
mat.SetFloat( "Radio2", 0.0f);