Author Topic: AnchorUpdate OnEnable and Unity Editor  (Read 6139 times)

bdominguez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
AnchorUpdate OnEnable and Unity Editor
« on: May 12, 2014, 06:54:24 AM »
Why you always use "OnUpdate" behaviour in Unity Editor despite of setting "OnEnable"?

UIRect.cs line 410 ( NGUI 3.5.8 )

Quote
#if !UNITY_EDITOR
         if (updateAnchors == AnchorUpdate.OnUpdate || mUpdateAnchors)
#endif

It's really confussing and I can't test anything correctly in editor.

Example:

- You set a Widget to "OnEnable" because later you want to move it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: AnchorUpdate OnEnable and Unity Editor
« Reply #1 on: May 12, 2014, 04:43:03 PM »
Hmm? That if statement is "if not UnityEditor". Update Anchors should only be executed if the condition is set to "OnUpdate", and not "OnEnable". It behaves differently in the editor because changes must be reflected while you are not playing the game. Although it's probably best if that statement reads:
  1. #if UNITY_EDITOR
  2.                         if (updateAnchors == AnchorUpdate.OnUpdate || mUpdateAnchors || !Application.isPlaying)
  3. #else
  4.                         if (updateAnchors == AnchorUpdate.OnUpdate || mUpdateAnchors)
  5. #endif

bdominguez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: AnchorUpdate OnEnable and Unity Editor
« Reply #2 on: May 13, 2014, 01:08:03 AM »
Hmm? That if statement is "if not UnityEditor". Update Anchors should only be executed if the condition is set to "OnUpdate", and not "OnEnable". It behaves differently in the editor because changes must be reflected while you are not playing the game. Although it's probably best if that statement reads:
  1. #if UNITY_EDITOR
  2.                         if (updateAnchors == AnchorUpdate.OnUpdate || mUpdateAnchors || !Application.isPlaying)
  3. #else
  4.                         if (updateAnchors == AnchorUpdate.OnUpdate || mUpdateAnchors)
  5. #endif

That's my problem.

So are you going to change that in next version? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: AnchorUpdate OnEnable and Unity Editor
« Reply #3 on: May 13, 2014, 08:43:36 AM »
Yup, already done.