Thanks for the reply. I did get this to work on the PC perfectly, but not on the mobile version. I believe that it is because on the PC version, it "hovers" and changes to green, then when it unhovers it changes back to red. But since mobile doesn't have a hover to green, it doesn't change to red..... but it does but it's offset.
The button is already set and the function is called from a UIButton Message with onClick calling toggleMainGun (this part all works, it calls the function just fine)
// method that toggles between a red and white button color for the shooting button.
public void toggleMainGun()
{
// toggle main gun weapon value
canUseMainGun = (canUseMainGun == 1) ? 0 : 1;
mainGunButton.GetComponent<UIButton>().defaultColor = (canUseMainGun == 1) ? Color.white : Color.red;
// set the playerprefs so the value is saved between game states.
PlayerPrefs.SetInt("UseMainGun", canUseMainGun);
}
When hit the button in the PC version, (editor really, this is a mobile game) I mouse over the button, it turns green (default hover color) and then I click it, mouse out, button is red.. and the gun is disabled as intended.
when I hit the button on the android im testing with, I click press the button down (does the default pressed color) and when I take my finger off.. the color does not change.. but the gun is disabled properly.... if I hit the button again... it turns red... and the gun is enabled... if I hit it again.. it goes white.. and the button is disabled... so the color seems to be offset.
I also tried doing this with UISprite.color like you mentioned.. and I even tried a TweenColor setting up the from and to and Play() but it doesn't seem to be working either way. Is there a way I can trigger a hover-like effect of changing to green and then when it changes back it goes to red? and visa versa?
and as for using 1 and 0 instead of true and false is because playerprefs does not have a bool save value (they should... but meh)
Thank you.