Author Topic: [Solved] UIButtons do not animate to disabled color when disabled in the editor  (Read 3049 times)

scapegoat57

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
I have a scene with just the simple button control prefab. When the scene is running and I disable the UIButton script the button does not tween to the disabled color. It also does not set its color to the disabled color when the UIButton script is disabled before running the scene. Adding isEnabled=true/false to UIButton::OnEnable/OnDisable fixed the toggling error but I have not found a way to get the button's color disabled on start up.
« Last Edit: December 29, 2013, 02:32:30 AM by scapegoat57 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButtons do not animate to disabled color when disabled in the editor
« Reply #1 on: December 29, 2013, 01:26:51 AM »
UIButton is a script that makes it possible to change the color of its target. If you disable it, there won't be a color change. UIButton.isEnabled actually toggles the collider, not the button script.

scapegoat57

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIButtons do not animate to disabled color when disabled in the editor
« Reply #2 on: December 29, 2013, 02:28:46 AM »
I see what you're saying, isEnabled is not a property I want to change. What I need is a button that can be disabled without its collider being disabled so it can still work with UIDragScrollView. So I got rid of the isEnabled = true in UIButton::OnEnable and replaced the isEnabled=false in OnDisable to UpdateColor(false,false). This works great since it allows me to disable and re enable the button at run-time in the inspector. The only hurdle left to jump over is tweening the color to the disabled color if the script is disabled. Awake is called even if the script is disabled. Putting UpdateColor(enabled, true) in there causes the desired effect. Thanks for your help.