Author Topic: Changing Default-Color of an Image Button?  (Read 3624 times)

BurSari92

  • Guest
Changing Default-Color of an Image Button?
« on: July 27, 2013, 10:10:05 PM »
Hello Community,
my problem is: I dont know how to access the Color Tint of an Image Button (from another script) to change the Default color to grey.
Script is like this example but won´t work:

public UIImageButton objAttack1; //The Image Button i want to access.

   void Start()
   {
            objAttack1.UIButtonColor.defaultColor = Color.gray   //needs to change the Default color now.
   }

Hoping for help :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing Default-Color of an Image Button?
« Reply #1 on: July 28, 2013, 08:38:21 AM »
Image button doesn't have anything to do with colors. Do you mean a UIButtonColor script?

objAttack1.color = Color.gray; <-- changes the color immediately

objAttack1.GetComponent<UIButtonColor>().defaultColor = Color.gray; <-- default color

BurSari92

  • Guest
Re: Changing Default-Color of an Image Button?
« Reply #2 on: July 28, 2013, 06:47:36 PM »
Woow thank you very much it works now :)
But i have to change the code a little bit for that.

for coloring the Image Button i used the backgroud sprite of the Image Button:

public UISprite objSprite;

   void AttackButton1()
   {
      objSprite.color = Color.gray;
   }

and now it works thanks, your my hero :)