The title says all, I already tryed everything.
I begin with the error it gives me :
error CS1612: Cannot modify a value type return value of UnityEngine.UI.Selectable.spriteState. Consider storing the value in a temporary variable
and the code that gives that error :
cont.GetComponent<Button> ().spriteState.pressedSprite = theme.pressbuttons [0];
pause.GetComponent<Button> ().spriteState.pressedSprite = theme.pressbuttons [1];
help.GetComponent<Button> ().spriteState.pressedSprite = theme.pressbuttons [2];
.... etc
First i tryed instantiating a Sprite object and assigning it theme.pressbuttons sprite, but it gives the same error.
Then I tryed instantiating a SpriteState object and assigning it the spritestate of the button to change tha sprite, this way it won’t give me the error but i don’t the get the sprite to be changed
The error tells me to store the value in a temp variable, I tryied for both the variables but it doesn’t work either way…
What I could try is storing the Button in a temp variable, but it doesn’t make sense to me, since I already tried with the attached SpriteState.
I think i’m missing something, the code to change the normal state sprite works because i only have to change the Image().sprite value, but this one accessing the Button().spriteState is not.
The Editor suggest me when I type “pressedSprite” a {get; set;} method but I don’t really know how to use it… Thanks for answers!
Oh, I’m using C# .