static public int Finish(IntPtr l)
 {
     try {
         ActiveAnimation self = (ActiveAnimation)checkSelf(l);
         self.Finish();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#2
0
    /// <summary>
    /// Fade out or fade in the active sprite and notify the OnChange event listener.
    /// </summary>

    void Set(bool state)
    {
        if (!mStarted)
        {
            mIsActive    = state;
            startsActive = state;
            if (activeSprite != null)
            {
                activeSprite.alpha = state ? 1f : 0f;
            }
        }
        else if (mIsActive != state)
        {
            // Uncheck all other toggles
            if (group != 0 && state)
            {
                for (int i = 0, imax = list.size; i < imax;)
                {
                    UIToggle cb = list[i];
                    if (cb != this && cb.group == group)
                    {
                        cb.Set(false);
                    }

                    if (list.size != imax)
                    {
                        imax = list.size;
                        i    = 0;
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            // Remember the state
            mIsActive = state;

            // Tween the color of the active sprite
            if (activeSprite != null)
            {
                if (instantTween)
                {
                    activeSprite.alpha = mIsActive ? 1f : 0f;
                }
                else
                {
                    TweenAlpha.Begin(activeSprite.gameObject, 0.15f, mIsActive ? 1f : 0f);
                }
            }

            current = this;

            if (EventDelegate.IsValid(onChange))
            {
                EventDelegate.Execute(onChange);
            }
            else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
            {
                // Legacy functionality support (for backwards compatibility)
                eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
            }
            current = null;

            // Play the checkmark animation
            if (activeAnimation != null)
            {
                ActiveAnimation aa = ActiveAnimation.Play(activeAnimation, state ? Direction.Forward : Direction.Reverse);
                if (instantTween)
                {
                    aa.Finish();
                }
            }
        }
    }
示例#3
0
    /// <summary>
    /// Fade out or fade in the active sprite and notify the OnChange event listener.
    /// If setting the initial value, call Start() first.
    /// </summary>

    public void Set(bool state, bool notify = true)
    {
        if (validator != null && !validator(state))
        {
            return;
        }

        if (!mStarted)
        {
            mIsActive    = state;
            startsActive = state;
            if (activeSprite != null)
            {
                activeSprite.alpha = invertSpriteState ? (state ? 0f : 1f) : (state ? 1f : 0f);
            }
        }
        else if (mIsActive != state)
        {
            // Uncheck all other toggles
            if (group != 0 && state)
            {
                for (int i = 0, imax = list.size; i < imax;)
                {
                    UIToggle cb = list[i];
                    if (cb != this && cb.group == group)
                    {
                        cb.Set(false);
                    }

                    if (list.size != imax)
                    {
                        imax = list.size;
                        i    = 0;
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            // Remember the state
            mIsActive = state;

            // Tween the color of the active sprite
            if (activeSprite != null)
            {
                if (instantTween || !NGUITools.GetActive(this))
                {
                    activeSprite.alpha = invertSpriteState ? (mIsActive ? 0f : 1f) : (mIsActive ? 1f : 0f);
                }
                else
                {
                    TweenAlpha.Begin(activeSprite.gameObject, 0.15f, invertSpriteState ? (mIsActive ? 0f : 1f) : (mIsActive ? 1f : 0f));
                }
            }

            if (notify && current == null)
            {
                UIToggle tog = current;
                current = this;

                if (EventDelegate.IsValid(onChange))
                {
                    EventDelegate.Execute(onChange);
                }
                else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
                {
                    // Legacy functionality support (for backwards compatibility)
                    eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
                }
                current = tog;
            }

            // Play the checkmark animation
            if (animator != null)
            {
                ActiveAnimation aa = ActiveAnimation.Play(animator, null,
                                                          state ? Direction.Forward : Direction.Reverse,
                                                          EnableCondition.IgnoreDisabledState,
                                                          DisableCondition.DoNotDisable);
                if (aa != null && (instantTween || !NGUITools.GetActive(this)))
                {
                    aa.Finish();
                }
            }
            else if (activeAnimation != null)
            {
                ActiveAnimation aa = ActiveAnimation.Play(activeAnimation, null,
                                                          state ? Direction.Forward : Direction.Reverse,
                                                          EnableCondition.IgnoreDisabledState,
                                                          DisableCondition.DoNotDisable);
                if (aa != null && (instantTween || !NGUITools.GetActive(this)))
                {
                    aa.Finish();
                }
            }
            else if (tween != null)
            {
                bool isActive = NGUITools.GetActive(this);

                if (tween.tweenGroup != 0)
                {
                    UITweener[] tws = tween.GetComponentsInChildren <UITweener>(true);

                    for (int i = 0, imax = tws.Length; i < imax; ++i)
                    {
                        UITweener t = tws[i];

                        if (t.tweenGroup == tween.tweenGroup)
                        {
                            t.Play(state);
                            if (instantTween || !isActive)
                            {
                                t.tweenFactor = state ? 1f : 0f;
                            }
                        }
                    }
                }
                else
                {
                    tween.Play(state);
                    if (instantTween || !isActive)
                    {
                        tween.tweenFactor = state ? 1f : 0f;
                    }
                }
            }
        }
    }
示例#4
0
 private void Set(bool state)
 {
     if (!mStarted)
     {
         mIsActive    = state;
         startsActive = state;
         if (activeSprite != null)
         {
             activeSprite.alpha = ((!state) ? 0f : 1f);
         }
     }
     else if (mIsActive != state)
     {
         if (group != 0 && state)
         {
             int num  = 0;
             int size = list.size;
             while (num < size)
             {
                 UIToggle uIToggle = list[num];
                 if (uIToggle != this && uIToggle.group == group)
                 {
                     uIToggle.Set(state: false);
                 }
                 if (list.size != size)
                 {
                     size = list.size;
                     num  = 0;
                 }
                 else
                 {
                     num++;
                 }
             }
         }
         mIsActive = state;
         if (activeSprite != null)
         {
             if (instantTween || !NGUITools.GetActive(this))
             {
                 activeSprite.alpha = ((!mIsActive) ? 0f : 1f);
             }
             else
             {
                 TweenAlpha.Begin(activeSprite.gameObject, 0.15f, (!mIsActive) ? 0f : 1f);
             }
         }
         if (current == null)
         {
             UIToggle uIToggle2 = current;
             current = this;
             if (EventDelegate.IsValid(onChange))
             {
                 EventDelegate.Execute(onChange);
             }
             else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
             {
                 eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
             }
             current = uIToggle2;
         }
         if (this.activeAnimation != null)
         {
             ActiveAnimation activeAnimation = ActiveAnimation.Play(this.activeAnimation, null, state ? Direction.Forward : Direction.Reverse, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
             if (activeAnimation != null && (instantTween || !NGUITools.GetActive(this)))
             {
                 activeAnimation.Finish();
             }
         }
     }
 }
示例#5
0
 public void Set(bool state)
 {
     if (this.validator != null && !this.validator(state))
     {
         return;
     }
     if (!this.mStarted)
     {
         this.mIsActive    = state;
         this.startsActive = state;
         if (this.activeSprite != null)
         {
             this.activeSprite.alpha = ((!state) ? 0f : 1f);
         }
     }
     else if (this.mIsActive != state)
     {
         if (this.group != 0 && state)
         {
             int i    = 0;
             int size = UIToggle.list.size;
             while (i < size)
             {
                 UIToggle uitoggle = UIToggle.list[i];
                 if (uitoggle != this && uitoggle.group == this.group)
                 {
                     uitoggle.Set(false);
                 }
                 if (UIToggle.list.size != size)
                 {
                     size = UIToggle.list.size;
                     i    = 0;
                 }
                 else
                 {
                     i++;
                 }
             }
         }
         this.mIsActive = state;
         if (this.activeSprite != null)
         {
             if (this.instantTween || !NGUITools.GetActive(this))
             {
                 this.activeSprite.alpha = ((!this.mIsActive) ? 0f : 1f);
             }
             else
             {
                 TweenAlpha.Begin(this.activeSprite.gameObject, 0.15f, (!this.mIsActive) ? 0f : 1f);
             }
         }
         if (UIToggle.current == null)
         {
             UIToggle uitoggle2 = UIToggle.current;
             UIToggle.current = this;
             if (EventDelegate.IsValid(this.onChange))
             {
                 EventDelegate.Execute(this.onChange);
             }
             else if (this.eventReceiver != null && !string.IsNullOrEmpty(this.functionName))
             {
                 this.eventReceiver.SendMessage(this.functionName, this.mIsActive, SendMessageOptions.DontRequireReceiver);
             }
             UIToggle.current = uitoggle2;
         }
         if (this.animator != null)
         {
             ActiveAnimation activeAnimation = ActiveAnimation.Play(this.animator, null, (!state) ? Direction.Reverse : Direction.Forward, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
             if (activeAnimation != null && (this.instantTween || !NGUITools.GetActive(this)))
             {
                 activeAnimation.Finish();
             }
         }
         else if (this.activeAnimation != null)
         {
             ActiveAnimation activeAnimation2 = ActiveAnimation.Play(this.activeAnimation, null, (!state) ? Direction.Reverse : Direction.Forward, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
             if (activeAnimation2 != null && (this.instantTween || !NGUITools.GetActive(this)))
             {
                 activeAnimation2.Finish();
             }
         }
     }
 }
示例#6
0
    /// <summary>
    /// Fade out or fade in the active sprite and notify the OnChange event listener.
    /// </summary>

    public void Set(bool state)
    {
        if (validator != null && !validator(state))
        {
            return;
        }

        if (!mStarted)
        {
            mIsActive    = state;
            startsActive = state;
            if (activeSprite != null)
            {
                activeSprite.alpha = state ? 1f : 0f;
            }
        }
        else if (mIsActive != state)
        {
            // Uncheck all other toggles
            if (group != "" && state)
            {
                for (int i = 0, imax = list.size; i < imax;)
                {
                    UIToggle cb = list[i];
                    if (cb != this && cb.group == group)
                    {
                        cb.Set(false);
                    }

                    if (list.size != imax)
                    {
                        imax = list.size;
                        i    = 0;
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            // Remember the state
            mIsActive = state;

            // Tween the color of the active sprite
            if (activeSprite != null)
            {
                if (instantTween || !NGUITools.GetActive(this))
                {
                    activeSprite.alpha = mIsActive ? 1f : 0f;
                }
                else
                {
                    TweenAlpha.Begin(activeSprite.gameObject, 0.15f, mIsActive ? 1f : 0f);
                }
            }
            _onChange.Invoke(this, state);

            // Play the checkmark animation
            if (animator != null)
            {
                ActiveAnimation aa = ActiveAnimation.Play(animator, null,
                                                          state ? Direction.Forward : Direction.Reverse,
                                                          EnableCondition.IgnoreDisabledState,
                                                          DisableCondition.DoNotDisable);
                if (aa != null && (instantTween || !NGUITools.GetActive(this)))
                {
                    aa.Finish();
                }
            }
            else if (activeAnimation != null)
            {
                ActiveAnimation aa = ActiveAnimation.Play(activeAnimation, null,
                                                          state ? Direction.Forward : Direction.Reverse,
                                                          EnableCondition.IgnoreDisabledState,
                                                          DisableCondition.DoNotDisable);
                if (aa != null && (instantTween || !NGUITools.GetActive(this)))
                {
                    aa.Finish();
                }
            }
            else if (tween != null)
            {
                bool isActive = NGUITools.GetActive(this);

                if (tween.tweenGroup != 0)
                {
                    UITweener[] tws = tween.GetComponentsInChildren <UITweener>();

                    for (int i = 0, imax = tws.Length; i < imax; ++i)
                    {
                        UITweener t = tws[i];

                        if (t.tweenGroup == tween.tweenGroup)
                        {
                            t.Play(state);
                            if (instantTween || !isActive)
                            {
                                t.tweenFactor = state ? 1f : 0f;
                            }
                        }
                    }
                }
                else
                {
                    tween.Play(state);
                    if (instantTween || !isActive)
                    {
                        tween.tweenFactor = state ? 1f : 0f;
                    }
                }
            }
        }
    }
示例#7
0
 // Token: 0x06000327 RID: 807 RVA: 0x0001EF58 File Offset: 0x0001D158
 public void Set(bool state, bool notify = true)
 {
     if (this.validator != null && !this.validator(state))
     {
         return;
     }
     if (!this.mStarted)
     {
         this.mIsActive    = state;
         this.startsActive = state;
         if (this.activeSprite != null)
         {
             this.activeSprite.alpha = (this.invertSpriteState ? (state ? 0f : 1f) : (state ? 1f : 0f));
             return;
         }
     }
     else if (this.mIsActive != state)
     {
         if (this.group != 0 && state)
         {
             int i    = 0;
             int size = UIToggle.list.size;
             while (i < size)
             {
                 UIToggle uitoggle = UIToggle.list.buffer[i];
                 if (uitoggle != this && uitoggle.group == this.group)
                 {
                     uitoggle.Set(false, true);
                 }
                 if (UIToggle.list.size != size)
                 {
                     size = UIToggle.list.size;
                     i    = 0;
                 }
                 else
                 {
                     i++;
                 }
             }
         }
         this.mIsActive = state;
         if (this.activeSprite != null)
         {
             if (this.instantTween || !NGUITools.GetActive(this))
             {
                 this.activeSprite.alpha = (this.invertSpriteState ? (this.mIsActive ? 0f : 1f) : (this.mIsActive ? 1f : 0f));
             }
             else
             {
                 TweenAlpha.Begin(this.activeSprite.gameObject, 0.15f, this.invertSpriteState ? (this.mIsActive ? 0f : 1f) : (this.mIsActive ? 1f : 0f), 0f);
             }
         }
         if (notify && UIToggle.current == null)
         {
             UIToggle uitoggle2 = UIToggle.current;
             UIToggle.current = this;
             if (EventDelegate.IsValid(this.onChange))
             {
                 EventDelegate.Execute(this.onChange);
             }
             else if (this.eventReceiver != null && !string.IsNullOrEmpty(this.functionName))
             {
                 this.eventReceiver.SendMessage(this.functionName, this.mIsActive, SendMessageOptions.DontRequireReceiver);
             }
             UIToggle.current = uitoggle2;
         }
         if (this.animator != null)
         {
             ActiveAnimation activeAnimation = ActiveAnimation.Play(this.animator, null, state ? AnimationOrTween.Direction.Forward : AnimationOrTween.Direction.Reverse, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
             if (activeAnimation != null && (this.instantTween || !NGUITools.GetActive(this)))
             {
                 activeAnimation.Finish();
                 return;
             }
         }
         else if (this.activeAnimation != null)
         {
             ActiveAnimation activeAnimation2 = ActiveAnimation.Play(this.activeAnimation, null, state ? AnimationOrTween.Direction.Forward : AnimationOrTween.Direction.Reverse, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
             if (activeAnimation2 != null && (this.instantTween || !NGUITools.GetActive(this)))
             {
                 activeAnimation2.Finish();
                 return;
             }
         }
         else if (this.tween != null)
         {
             bool active = NGUITools.GetActive(this);
             if (this.tween.tweenGroup != 0)
             {
                 UITweener[] componentsInChildren = this.tween.GetComponentsInChildren <UITweener>(true);
                 int         j   = 0;
                 int         num = componentsInChildren.Length;
                 while (j < num)
                 {
                     UITweener uitweener = componentsInChildren[j];
                     if (uitweener.tweenGroup == this.tween.tweenGroup)
                     {
                         uitweener.Play(state);
                         if (this.instantTween || !active)
                         {
                             uitweener.tweenFactor = (state ? 1f : 0f);
                         }
                     }
                     j++;
                 }
                 return;
             }
             this.tween.Play(state);
             if (this.instantTween || !active)
             {
                 this.tween.tweenFactor = (state ? 1f : 0f);
             }
         }
     }
 }
示例#8
0
 private void Set(bool state)
 {
     if (!this.mStarted)
     {
         this.mIsActive    = state;
         this.startsActive = state;
         if (this.activeSprite != null)
         {
             this.activeSprite.alpha = ((!state) ? 0f : 1f);
         }
         if (this.activeSprite2 != null)
         {
             this.activeSprite2.alpha = ((!state) ? 0f : 1f);
         }
     }
     else if (this.mIsActive != state)
     {
         if (this.group != 0 && state)
         {
             int i    = 0;
             int size = UIToggle.list.size;
             while (i < size)
             {
                 UIToggle uIToggle = UIToggle.list[i];
                 if (uIToggle != this && uIToggle.group == this.group)
                 {
                     uIToggle.Set(false);
                 }
                 if (UIToggle.list.size != size)
                 {
                     size = UIToggle.list.size;
                     i    = 0;
                 }
                 else
                 {
                     i++;
                 }
             }
         }
         this.mIsActive = state;
         if (this.activeSprite != null)
         {
             if (this.instantTween)
             {
                 this.activeSprite.alpha = ((!this.mIsActive) ? 0f : 1f);
             }
             else
             {
                 TweenAlpha.Begin(this.activeSprite.gameObject, 0.15f, (!this.mIsActive) ? 0f : 1f);
             }
         }
         if (this.activeSprite2 != null)
         {
             if (this.instantTween)
             {
                 this.activeSprite2.alpha = ((!this.mIsActive) ? 0f : 1f);
             }
             else
             {
                 TweenAlpha.Begin(this.activeSprite2.gameObject, 0.15f, (!this.mIsActive) ? 0f : 1f);
             }
         }
         if (UIToggle.current == null)
         {
             UIToggle.current = this;
             if (EventDelegate.IsValid(this.onChange))
             {
                 EventDelegate.Execute(this.onChange);
             }
             else if (this.eventReceiver != null && !string.IsNullOrEmpty(this.functionName))
             {
                 this.eventReceiver.SendMessage(this.functionName, this.mIsActive, SendMessageOptions.DontRequireReceiver);
             }
             UIToggle.current = null;
         }
         if (this.activeAnimation != null)
         {
             ActiveAnimation activeAnimation = ActiveAnimation.Play(this.activeAnimation, (!state) ? Direction.Reverse : Direction.Forward);
             if (this.instantTween)
             {
                 activeAnimation.Finish();
             }
         }
     }
 }
示例#9
0
    public void SetEx(bool state)
    {
        if (validator != null && !validator(state))
        {
            return;
        }



        if (!mStarted)
        {
            mIsActive    = state;
            startsActive = state;
            if (activeSprite != null)
            {
                activeSprite.alpha = state ? 1f : 0f;
            }
        }
        else if (mIsActive != state)
        {
            // Uncheck all other toggles
            if (group != 0 && state)
            {
                for (int i = 0, imax = list.size; i < imax;)
                {
                    UIToggle cb = list[i];
                    if (cb != this && cb.group == group)
                    {
                        cb.Set(false);
                    }

                    if (list.size != imax)
                    {
                        imax = list.size;
                        i    = 0;
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            // Remember the state
            mIsActive = state;

            if (aa)
            {
                if (aa.isPlaying)
                {
                    aa.Finish();
                }
            }

            // Tween the color of the active sprite
            if (activeSprite != null)
            {
                activeSprite.alpha = mIsActive ? 1f : 0f;

                if (mIsActive)
                {
                    activeSprite.transform.localScale = new Vector3(1, 1, 1);
                }
                else
                {
                    activeSprite.transform.localScale = new Vector3(0.01f, 0.01f, 1);
                }
            }

            if (EventDelegate.IsValid(onChange))
            {
                EventDelegate.Execute(onChange);
            }
            else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
            {
                // Legacy functionality support (for backwards compatibility)
                eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
            }
//            if (current == null)
//            {
//                 UIToggle tog = current;
//                 current = this;
//
//                 if (EventDelegate.IsValid(onChange))
//                 {
//                     EventDelegate.Execute(onChange);
//                 }
//                 else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
//                 {
//                     // Legacy functionality support (for backwards compatibility)
//                     eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
//                 }
//                 current = tog;
//            }
        }
    }
示例#10
0
 public void Set(bool state)
 {
     //IL_0156: Unknown result type (might be due to invalid IL or missing references)
     //IL_017a: Expected O, but got Unknown
     if (validator == null || validator(state))
     {
         if (!mStarted)
         {
             mIsActive    = state;
             startsActive = state;
             if (activeSprite != null)
             {
                 activeSprite.alpha = ((!state) ? 0f : 1f);
             }
         }
         else if (mIsActive != state)
         {
             if (group != 0 && state)
             {
                 int num  = 0;
                 int size = list.size;
                 while (num < size)
                 {
                     UIToggle uIToggle = list[num];
                     if (uIToggle != this && uIToggle.group == group)
                     {
                         uIToggle.Set(false);
                     }
                     if (list.size != size)
                     {
                         size = list.size;
                         num  = 0;
                     }
                     else
                     {
                         num++;
                     }
                 }
             }
             mIsActive = state;
             if (activeSprite != null)
             {
                 if (instantTween || !NGUITools.GetActive(this))
                 {
                     activeSprite.alpha = ((!mIsActive) ? 0f : 1f);
                 }
                 else
                 {
                     TweenAlpha.Begin(activeSprite.get_gameObject(), 0.15f, (!mIsActive) ? 0f : 1f);
                 }
             }
             if (current == null)
             {
                 UIToggle uIToggle2 = current;
                 current = this;
                 if (EventDelegate.IsValid(onChange))
                 {
                     EventDelegate.Execute(onChange);
                 }
                 else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
                 {
                     eventReceiver.SendMessage(functionName, (object)mIsActive, 1);
                 }
                 current = uIToggle2;
             }
             if (animator != null)
             {
                 ActiveAnimation activeAnimation = ActiveAnimation.Play(animator, null, state ? Direction.Forward : Direction.Reverse, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
                 if (activeAnimation != null && (instantTween || !NGUITools.GetActive(this)))
                 {
                     activeAnimation.Finish();
                 }
             }
             else if (this.activeAnimation != null)
             {
                 ActiveAnimation activeAnimation2 = ActiveAnimation.Play(this.activeAnimation, null, state ? Direction.Forward : Direction.Reverse, EnableCondition.IgnoreDisabledState, DisableCondition.DoNotDisable);
                 if (activeAnimation2 != null && (instantTween || !NGUITools.GetActive(this)))
                 {
                     activeAnimation2.Finish();
                 }
             }
         }
     }
 }
示例#11
0
 private void Set(bool state)
 {
     if (!mStarted)
     {
         mIsActive    = state;
         startsActive = state;
         if (activeSprite != null)
         {
             activeSprite.alpha = (state ? 1f : 0f);
         }
     }
     else
     {
         if (mIsActive == state)
         {
             return;
         }
         if (group != 0 && state)
         {
             int num  = 0;
             int size = list.size;
             while (num < size)
             {
                 UIToggle uIToggle = list[num];
                 if (uIToggle != this && uIToggle.group == group)
                 {
                     uIToggle.Set(state: false);
                 }
                 if (list.size != size)
                 {
                     size = list.size;
                     num  = 0;
                 }
                 else
                 {
                     num++;
                 }
             }
         }
         mIsActive = state;
         if (activeSprite != null)
         {
             if (instantTween)
             {
                 activeSprite.alpha = (mIsActive ? 1f : 0f);
             }
             else
             {
                 TweenAlpha.Begin(activeSprite.gameObject, 0.15f, mIsActive ? 1f : 0f);
             }
         }
         if (current == null)
         {
             current = this;
             if (EventDelegate.IsValid(onChange))
             {
                 EventDelegate.Execute(onChange);
             }
             else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
             {
                 eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
             }
             current = null;
         }
         if (this.activeAnimation != null)
         {
             ActiveAnimation activeAnimation = ActiveAnimation.Play(this.activeAnimation, state ? Direction.Forward : Direction.Reverse);
             if (instantTween)
             {
                 activeAnimation.Finish();
             }
         }
     }
 }
示例#12
0
    //[ss] mergeme end
    /// <summary>
    /// Fade out or fade in the active sprite and notify the OnChange event listener.
    /// </summary>

    public void Set(bool state)
    {
        if (validator != null && !validator(state))
        {
            return;
        }

        if (!mStarted)
        {
            mIsActive    = state;
            startsActive = state;
            if (activeSprite != null)
            {
                activeSprite.alpha = state ? 1f : 0f;
            }
        }
        else if (mIsActive != state)
        {
            // Uncheck all other toggles
            if (group != 0 && state)
            {
                for (int i = 0, imax = list.size; i < imax;)
                {
                    UIToggle cb = list[i];
                    if (cb != this && cb.group == group)
                    {
                        cb.Set(false);
                    }

                    if (list.size != imax)
                    {
                        imax = list.size;
                        i    = 0;
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            // Remember the state
            mIsActive = state;

            // Tween the color of the active sprite
            if (activeSprite != null)
            {
                if (instantTween || !NGUITools.GetActive(this))
                {
                    //[ss] mergeme begin
                    activeSprite.gameObject.SetActive(mIsActive);
                    //[ss] hack to activate/deactivate sprite
                    //activeSprite.alpha = mIsActive ? 1f : 0f;
                    //[ss] mergeme end
                }
                else
                {
                    TweenAlpha.Begin(activeSprite.gameObject, 0.15f, mIsActive ? 1f : 0f);
                }
            }

            if (current == null)
            {
                UIToggle tog = current;
                current = this;

                if (EventDelegate.IsValid(onChange))
                {
                    EventDelegate.Execute(onChange);
                }
                else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
                {
                    // Legacy functionality support (for backwards compatibility)
                    eventReceiver.SendMessage(functionName, mIsActive, SendMessageOptions.DontRequireReceiver);
                }
                current = tog;
            }

            // Play the checkmark animation
            if (activeAnimation != null)
            {
                ActiveAnimation aa = ActiveAnimation.Play(activeAnimation, null,
                                                          state ? Direction.Forward : Direction.Reverse,
                                                          EnableCondition.IgnoreDisabledState,
                                                          DisableCondition.DoNotDisable);
                if (aa != null && (instantTween || !NGUITools.GetActive(this)))
                {
                    aa.Finish();
                }
            }
        }
    }