Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vallcrist on January 19, 2014, 03:48:54 PM

Title: Widgets with alpha = 0 and colliders
Post by: vallcrist on January 19, 2014, 03:48:54 PM
Hello again. =)

Previously, when a sprite/widget had it's alpha value = 0, the collider was disabled automatically, has this changed, or am i doing something wrong?
Title: Re: Widgets with alpha = 0 and colliders
Post by: Shifty Geezer on January 19, 2014, 04:38:17 PM
That's not how it presently is. I've written my own code to disable colliders. Added to NGUITools.cs

  1.         public static void SetEnabled (GameObject t, bool on){
  2.                 // en/disables the BoxCollider of the control
  3.                 BoxCollider[] uielements;
  4.                 uielements = t.GetComponentsInChildren <BoxCollider>();
  5.                 foreach (BoxCollider bc in uielements) {
  6.                         bc.enabled = on;
  7.                 }
  8.         }
  9.        
  10.         public static void Enable (GameObject t){
  11.                 // enables the BoxCollider of the control and children, fades it in
  12.                 SetEnabled (t, true);
  13.                 TweenAlpha.Begin(t, 0.15f, 1f);
  14.         }
  15.  
  16.         public static void Disable (GameObject t){
  17.                 // disables the BoxCollider of the control and children, fades it out
  18.                 SetEnabled (t, false);
  19.                 TweenAlpha.Begin(t, 0.15f, 0f);
  20.         }
  21.  
Title: Re: Widgets with alpha = 0 and colliders
Post by: ArenMook on January 20, 2014, 12:02:17 AM
Was it ever like that? Thinking about it, auto-disabling the box collider on invisible widgets is a good idea, so I've gone ahead and done that for f2.