- Home /
JavaScript to c# problem.
Hey guys, why i have this error? In c#?
GUI.color.a = LogoAlpha;
error CS1612: Cannot modify a value type return value of `UnityEngine.GUI.color'. Consider storing the value in a temporary variable
Comment
Best Answer
Answer by Borgo · Sep 02, 2011 at 01:19 PM
Cause you can not modify directly a unique struct item, cause these itens are "read only".
The structs gives you only a "Get" method to these itens, but not a "Set" method.
You need to assign a object, even if you need to set only a unique item.
Exemple:
GUI.color.a = LogoAlpha; //this will give you the error
You need to do:
Gui.color = new Color(Gui.color.r, Gui.color.g, Gui.color.b, LogoAlpha);
Hope this help and sorry for my poor english,
Borgo
Answer by NiklasK · Sep 02, 2011 at 01:15 PM
You cant set the individual component "a" in C#. You will have to do something like this
GUI.color = new Color(r, g, b, LogoAlpha);