Trying to create this simple funcion:
Each time you press the Game Object, its changes the color, and switches between two colors(Off and On colors) becuase im randomizing the colors of the game object, I need to save the original color before the switch, but… its doesnt work. Im getting The color white insted of the game object’s color.
Heres the script:
notes: IsActive is a bool, Rend is the Sprite Renderer, And c is the color i want to switch to.
right now, it switches to c perfectly, but when it needs to turn back to the original color, it just turns white.
I didnt want to post the whole script here, becuase it has other uses too and is long, So i posted the part thats responsible for the color change, but i can say that. by the first time you press the object its already has his selected color, and you can see that in the OnMouseDown Funcion i call SwitchX and Check. SwitchX just switches the state of the variable “Is active” And the check funcion is doing the part that isnt working, if the IsActive bool is false it should save the curret gameobject’s color in the array RealColor and then change the color. And if IsActive is true, its should apply the RealColor’s Saved color to the gameObject.
also, theres an print in that script that prints the state of the variable IsActive, and its works. it switches the state everytime.