- Home /
The question is answered, right answer was accepted
how to change content offset of a style
i created a style named playStyle.
public GUIStyle playStyle;
But i cant able to change content offset of playStyle using code.
in void OnGUI() i given
playStyle.contentOffset.x = -40f;
Gets Error: error CS1612: Cannot modify a value type return value of `UnityEngine.GUIStyle.contentOffset'. Consider storing the value in a temporary variable
How to give contentOffset?
Answer by iwaldrop · May 21, 2013 at 05:44 AM
The error message is telling you that you can't modify the value, and to store it in a temporary variable. It means that you should do exactly that (like this):
Vector2 contentOffset = playStyle.contentOffset;
contentOffset.x = -40;
playStyle.contentOffset = contentOffset;
Isn't C# fun?
Follow this Question
Related Questions
Null in GetValidMethodInfo 0 Answers
A node in a childnode? 1 Answer
press play, game objects get deleted, game breaks. 1 Answer
Old Script errors messing up a new scene 1 Answer
Targetting error please help 0 Answers