在全球範圍內修改着色器值,這種材料的所有實例:
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);
這是一個錯字?你在狀態參數上方稱之爲「Radio 1」,但你在「Radio2」上設置了浮標 – Jerdak 2013-03-08 02:54:58