- Home /
Question by
anirudha_vfx · Oct 22, 2013 at 06:58 PM ·
shaderruntimesetcolor
"Setcolor " is permanently changing the color of shader in Assets
Hello. I am trying to change the color of multiple material in runtime. So I have created a public variable of material and than used "Setcolor" to change the main color after pressing the button. The problem I'm facing is, the change of color remains permanent in the project even after stopping the game.
Only "renderer.material.color" changes the color on runtime. I understand that this command changes the color in runtime and not the color of the shader in library.
Here is my testcode
using UnityEngine;
using System.Collections;
public class GUIColorPicker : MonoBehaviour {
public Material materialOne;
void OnGUI() {
if(GUI.Button(new Rect(Screen.width * 0.5f - 100, 5, 100, 50),"1")){
materialOne.SetColor ("_Color", Color.red);
}
}
}
Is there a way to changes the material color in runtime. I would really appreciate any help.
Comment