Author Topic: Disable an item from Grid (Draggable panel)  (Read 2860 times)

TifaOng

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Disable an item from Grid (Draggable panel)
« on: January 13, 2014, 12:18:52 PM »
I want to disable an item from a grid. Let's say Team Selection. User selected Team A and CPU cannot be Team A, or CPU selected Team A, User cannot select Team A.

How to do this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disable an item from Grid (Draggable panel)
« Reply #1 on: January 13, 2014, 05:41:30 PM »
I assume you want to disable it visually. Easiest thing to do is to have a UIButton script on your selection, and to set its UIButton.isEnabled flag to false. Otherwise use your own logic to make it "disabled" visually -- by changing the color, changing the sprite, or whatever you like.

TifaOng

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Disable an item from Grid (Draggable panel)
« Reply #2 on: January 15, 2014, 10:50:07 PM »
Thanks for the reply, but if I disable visually, then an empty space will appear.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Disable an item from Grid (Draggable panel)
« Reply #3 on: January 17, 2014, 12:31:26 AM »
Empty space? Setting "isEnabled" on a button changes its color to the disabled state. It doesn't remove it from the list. If you want it to be removed, disable the game object itself, then call UIGrid's Reposition() function.