Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: xiaoshun on February 14, 2014, 12:11:55 AM

Title: Why OnEnable() of UIWidget calls it's Update()?
Post by: xiaoshun 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
Title: Re: Why OnEnable() of UIWidget calls it's Update()?
Post by: ArenMook 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().