Author Topic: UIWidget  (Read 42297 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIWidget
« Reply #30 on: October 10, 2014, 02:57:53 AM »
Target the camera.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
UIWidget onChange
« Reply #31 on: October 13, 2014, 11:04:02 AM »
My objective is to be notified when UIWidget's dimensions change. I've found UIWidget.onChange which is described as "Notification triggered when the widget's dimensions or position changes". In the code, onChange is raised in UpdateTransform() whose description is "Check to see if the widget has moved relative to the panel that manages it".

As I only want to know when the dimensions change, I'm not interested in being notified when the widget moves relative to the panel, so to eliminate those notifications, I've placed my 'faceCamera' script so that it rotates the panel rather than rotating the widget, thinking that this way, the widget won't move relative to the panel. Unfortunately, whether I rotate the widget underneath the panel, or rotate the panel directly, I still get all the widget onChange notifications of movement.

Am I misunderstanding something here? Shouldn't rotating the panel directly keep the widget from generating all these onChange (aka I moved relative to my panel) notifications? ... or is the "Check to see if the widget has moved relative to the panel that manages it" comment misleading, and any absolute widget movement raises onChange?
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIWidget
« Reply #32 on: October 14, 2014, 03:50:22 PM »
OnChange will be called if the widget gets moved or its size changes relative to the panel that manages it. Rotation changes may cause slight variation in the position changes, thus causing the inequality checks to go through. Not sure why you need to do that though. If you really only care about width and height changes, then why not just have a script that stores the previous width and height and compares them against the new ones?

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: UIWidget
« Reply #33 on: October 14, 2014, 05:32:16 PM »
The check for a change in width/height is the current filter I use to ignore 99.9% of the onChange calls right now.

My reading of the comments on the event and methods led me to believe that onChange should only be called when the widget moves relative to its panel which I believe you are confirming. From my testing, when I rotate the panel that manages the widget (without moving the widget relative to the panel), I'm getting an onChange event every frame - aka hundreds per second until the rotation completes.

My filtering works fine. It just seems like a waste of effort when I have to filter it every frame to catch the .001% of the time when I change the dimensions. Thought you should know about the observation. Thanks for the support as always.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: UIWidget
« Reply #34 on: October 17, 2014, 09:17:20 AM »
Just to clarify - do you mean

1. OnChange will be called if the widget gets moved relative to the panel that manages it, or its size changes relative to the panel that manages it, or
2. OnChange will be called if the widget moves at all or its size changes relative to the panel that manages it.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIWidget
« Reply #35 on: October 18, 2014, 09:06:14 AM »
Anything that involves visual movement relative to the panel that manages it. Scale, transform, width, height. Everything.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: UIWidget
« Reply #36 on: October 18, 2014, 11:15:30 AM »
Ahh! That did it. I was scaling my widget underneath the panel. Once I moved the scaler above the panel, onChange only fires now when I would expect it too. Thanks.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.