Ejemplo n.º 1
0
    /// <summary>
    /// Return the first active toggle within the specified group.
    /// </summary>

    static public UITabLabelColor GetActiveToggleLabel(int group)
    {
        for (int i = 0; i < list.size; ++i)
        {
            UITabLabelColor toggle = list[i];
            if (toggle != null && toggle.group == group && toggle.mIsActive)
            {
                return(toggle);
            }
        }
        return(null);
    }
Ejemplo n.º 2
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.color = state ? activeColor : normalColor;
		}
		else if (mIsActive != state)
		{
			// Uncheck all other toggles
			if (group != 0 && state)
			{
				for (int i = 0, imax = list.size; i < imax; )
				{
					UITabLabelColor 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 (!NGUITools.GetActive(this))
				{
					activeSprite.color = mIsActive ? activeColor : normalColor;
				}
				else
				{
					TweenColor.Begin(activeSprite.gameObject, 0.15f, mIsActive ? activeColor : normalColor);
				}
			}

			if (current == null)
			{
				UITabLabelColor 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;
			}
		}
	}
Ejemplo n.º 3
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.color = state ? activeColor : normalColor;
            }
        }
        else if (mIsActive != state)
        {
            // Uncheck all other toggles
            if (group != 0 && state)
            {
                for (int i = 0, imax = list.size; i < imax;)
                {
                    UITabLabelColor 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 (!NGUITools.GetActive(this))
                {
                    activeSprite.color = mIsActive ? activeColor : normalColor;
                }
                else
                {
                    TweenColor.Begin(activeSprite.gameObject, 0.15f, mIsActive ? activeColor : normalColor);
                }
            }

            if (current == null)
            {
                UITabLabelColor 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;
            }
        }
    }