How do you change the Sprite Mesh Value Anima2d?
I am using Anima2D to animate my characters. I need to programically lower the Mesh Color value.
Below is what I try but it doesn't seem to work. I think its because it used the Sprite Mesh Instance Script.
I am trying this:
Renderer rend = thePlayer.GetComponentInChildren();
//Set the main Color of the Material to green
rend.material.shader = Shader.Find("_Color");
rend.material.SetColor("_Color", Color.green);
//Find the Specular shader and change its Color to red
rend.material.shader = Shader.Find("Specular");
rend.material.SetColor("_SpecColor", Color.red);
Thank You for the Help
Answer by NoDumbQuestion · Jul 09, 2018 at 01:52 AM
You gotta used rend.sharedMaterial
If you call rend.material.shader
. It will make a new copy of that material. You are just changing value of nothing.
Note: If you call sharedMaterial, every Object made from same prefab will be change color too.
If you want only to change 1 object material. You must create new material at runtime and apply it.
Your answer
Follow this Question
Related Questions
Please help with mesh render order 0 Answers
Can't uncheck mash renderer 0 Answers
What is Screen-Space Error 0 Answers
How can I access material of a mesh renderer without receiving and instance of it? 1 Answer
custom mesh render problem 0 Answers