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
Post a Comment