UnityEngine.UI.GemToggleGroup.NotifyToggleOn C# (CSharp) Method

NotifyToggleOn() public method

public NotifyToggleOn ( GemToggle toggle ) : void
toggle GemToggle
return void
        public void NotifyToggleOn(GemToggle toggle)
        {
            //will disable all toggles expcept current toggle and last selected toggle
            for (var i = 0; i < m_Toggles.Count; i++) {

                if (m_Toggles [i] == toggle || m_Toggles [i].LastGemSelected) {
                    continue;
                }

                m_Toggles [i].isOn = false;

            }

            //Will change booleans associated with toggles to match current game state
            for (var i = 0; i < m_Toggles.Count; i++) {
                if (m_Toggles [i].LastGemSelected) {
                    gm.SetGemTwo (m_Toggles [i].AssociatedGem);
                    m_Toggles [i].LastGemSelected = false;
                }

                if (m_Toggles [i] == toggle) {
                    gm.SetGemOne (m_Toggles [i].AssociatedGem);
                    m_Toggles [i].LastGemSelected = true;
                }

            }
        }

Usage Example

コード例 #1
0
ファイル: GemToggle.cs プロジェクト: xiekaren/phobia-game
        private void SetToggleGroup(GemToggleGroup newGroup, bool setMemberValue)
        {
            GemToggleGroup oldGroup = m_Group;

            // Sometimes IsActive returns false in OnDisable so don't check for it.
            // Rather remove the toggle too oftem than too little.
            if (m_Group != null)
            {
                m_Group.UnregisterToggle(this);
            }

            // At runtime the group variable should be set but not when calling this method from OnEnable or OnDisable.
            // That's why we use the setMemberValue parameter.
            if (setMemberValue)
            {
                m_Group = newGroup;
            }

            // Only register to the new group if this Toggle is active.
            if (m_Group != null && IsActive())
            {
                m_Group.RegisterToggle(this);
            }

            // If we are in a new group, and this toggle is on, notify group.
            // Note: Don't refer to m_Group here as it's not guaranteed to have been set.
            if (newGroup != null && newGroup != oldGroup && isOn && IsActive())
            {
                m_Group.NotifyToggleOn(this);
            }
        }