Author Topic: Creating an "invisible" widget  (Read 2418 times)

Kermitt

  • Guest
Creating an "invisible" widget
« on: October 19, 2013, 02:05:50 AM »
I need a widget which has a size, but has no sprite or text, and should have a depth like other widgets so it can react to OnHover, OnPress and OnDrag events.  Up till now I've done this with my own scripts and a collider, which worked fine as long as I set the collider Z correctly.  Today I upgraded to 3.0.2 and have found that this no longer works since other widgets no longer require the collider Z to be set based on depth.  In some cases, no matter what I set the depth of my "invisible" widget to, I can never get it to be on top of the other widgets and receive the mouse events.

So I'm wondering, would it be possible/sensible to make an actual invisible widget, something which derives from UIWidget, so that it inherits all the depth functionality?  I've looked into the code of other widgets and had a go at creating one of these myself, but couldn't really work out which bits I need and which bits I didn't.  Could anyone give me pointers on how to go about creating this, or is there any easier options that I'm missing?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Creating an "invisible" widget
« Reply #1 on: October 19, 2013, 08:12:04 PM »
I've thought about this feature myself since 3.0 and it does make sense. I'll make it so that a blank UIWidget is a valid component you can add in 3.0.3 like you can with any other sprite.

Kermitt

  • Guest
Re: Creating an "invisible" widget
« Reply #2 on: October 20, 2013, 09:20:25 PM »
Well that isn't the answer I expected, but it's even better :)
Any idea how long before 3.0.3 is released?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Creating an "invisible" widget
« Reply #3 on: October 20, 2013, 09:22:05 PM »
Pro users have it now. It's currently at RC1, so... Soon™

hstefan

  • Guest
Re: Creating an "invisible" widget
« Reply #4 on: October 23, 2013, 06:37:44 AM »
I could surely use that feature on the game we're working, currently I'm using a button without a sprite. Although it works, it seems like a strange workaround to me.

Kermitt

  • Guest
Re: Creating an "invisible" widget
« Reply #5 on: October 29, 2013, 12:36:50 AM »
I've upgraded to 3.0.3 and the new invisible UIWidget works great.  In fact it was extremely easy to change my existing object to inherit from UIWidget, and alter it so the size is applied to the widget width and height instead of setting the collider size directly.  After doing that all the depths and mouse events are working correctly again.  Many thanks.