Author Topic: Why OnEnable() of UIWidget calls it's Update()?  (Read 2138 times)

xiaoshun

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Why OnEnable() of UIWidget calls it's Update()?
« on: February 14, 2014, 12:11:55 AM »
Below is the OnEnable method of UIWidget.

        protected override void OnEnable ()
   {
      base.OnEnable();
      RemoveFromPanel();

      // Prior to NGUI 2.7.0 width and height was specified as transform's local scale
      if (mWidth == 100 && mHeight == 100 && cachedTransform.localScale.magnitude > 8f)
      {
         UpgradeFrom265();
         cachedTransform.localScale = Vector3.one;
#if UNITY_EDITOR
         UnityEditor.EditorUtility.SetDirty(this);
#endif
      }
      Update();
   }

you can see it calls Update() at last. Why? It's a bit awkward.
My NGUI version is 3.3.6

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Why OnEnable() of UIWidget calls it's Update()?
« Reply #1 on: February 14, 2014, 05:11:47 AM »
UIWidget has no OnEnable function in the latest version. It has OnInit where this logic occurs, but OnInit only happens after Start().