unity3d - Cannot modify a value type return value of `UnityEngine.Material.color' for changing alpha of gameobject -


i'm having trouble this, although improvement code can make gameobject change it's alpha want simpler.

here code:

spriterenderer go; color colora; float x = 0f; void start () {     go = getcomponent<spriterenderer> ();   }  // update called once per frame void update () {     colora = new color(255f,255f,255f,.5f);     go.material.color.a = colora.a; } 

this error one. make code simpler.

color struct , valuetype.

go.material.color // return copy of color 

you have make instance of color assign go.material.color

go.material.color = new color(255f,255f,255f,.5f); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -