Пример #1
0
        /// <summary>
        /// Find the active button selection's index!
        /// </summary>
        /// <returns></returns>
        private int FindSelectedButton()
        {
            for (int index = 0;
                 index < mSelectBtn.Length;
                 ++index)
            {
                JCS_Button jcsbtn = mSelectBtn[index];

                if (jcsbtn == null || jcsbtn.ButtonSelection == null)
                {
                    continue;
                }

                if (jcsbtn.ButtonSelection.Active)
                {
                    return(index);
                }
            }

            // Selection was not active. Meaning the send choice
            // did not been called by last status.
            //
            // NOTE(jenchieh): We are appoarching to new status right now.
            return(-1);
        }
Пример #2
0
        /*******************************************/
        /*            Unity's function             */
        /*******************************************/
        private void Awake()
        {
            this.mEventTrigger = this.GetComponent <EventTrigger>();
            this.mButton       = this.GetComponent <Button>();
            this.mJCS_Button   = this.GetComponent <JCS_Button>();

            // Try find it.
            if (this.mText == null)
            {
                this.mText = this.GetComponentInChildren <Text>();
            }

            JCS_Utility.AddEventTriggerEvent(mEventTrigger,
                                             EventTriggerType.PointerEnter,
                                             OnPointerEnter);
            JCS_Utility.AddEventTriggerEvent(mEventTrigger,
                                             EventTriggerType.PointerExit,
                                             OnPointerExit);
            JCS_Utility.AddEventTriggerEvent(mEventTrigger,
                                             EventTriggerType.PointerDown,
                                             OnPointerDown);
            JCS_Utility.AddEventTriggerEvent(mEventTrigger,
                                             EventTriggerType.PointerUp,
                                             OnPointerUp);

            // Initialize the first color.
            if (IsButtonInteractable())
            {
                mText.color = mNormalColor;
            }
            else
            {
                mText.color = mDisabledColor;
            }
        }
Пример #3
0
        /*******************************************/
        /*              Self-Define                */
        /*******************************************/
        //----------------------
        // Public Functions

        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

        /// <summary>
        /// Callback if the button get focus.
        /// </summary>
        private void PointToButton(JCS_Button btn)
        {
            if (mDontPointIfButtonNotActive)
            {
                if (!btn.Interactable)
                {
                    return;
                }
            }

            mSimpleTrackAction.TargetPosition = btn.GetRectTransfom().localPosition + mPointerOffset;
        }
        private void Awake()
        {
            // try to get the component.
            if (mJCSButton == null)
            {
                this.mJCSButton = this.GetComponent <JCS_Button>();
            }

            if (mJCSButton != null)
            {
                mJCSButton.SetCallback(PauseGame);
            }
        }
Пример #5
0
        /* Functions */

        private void Awake()
        {
            if (mSoundPlayer == null)
            {
                mSoundPlayer = this.GetComponent <JCS_SoundPlayer>();
            }
            mRectTransform = this.GetComponent <RectTransform>();
            mEventTrigger  = this.GetComponent <EventTrigger>();

            if (mJCSButton == null)
            {
                mJCSButton = this.GetComponent <JCS_Button>();
            }
        }
        /// <summary>
        /// Callback if the button get focus.
        /// </summary>
        private void PointToButton(JCS_Button btn)
        {
            if (mDontPointIfButtonNotActive)
            {
                if (!btn.Interactable)
                {
                    return;
                }
            }

            Vector3 targetPoint =
                btn.GetRectTransfom().localPosition + // Target position.
                mPointerOffset;                       // Offset value.

            mSimpleTrackAction.TargetPosition = targetPoint;
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        /// <param name="act"></param>
        private void SelectBtnActive(int index, bool act)
        {
            JCS_Button selectBtn = mSelectBtn[index];

            if (selectBtn == null)
            {
                return;
            }

            selectBtn.gameObject.SetActive(act);

            if (selectBtn.ButtonSelection != null)
            {
                selectBtn.ButtonSelection.SetSkip(!act);
            }
        }
Пример #8
0
        /*******************************************/
        /*            Unity's function             */
        /*******************************************/
        private void Awake()
        {
            if (mDeactiveAtAwake)
            {
                // Deactive every at start
                this.Active = false;
            }

            if (mSelfAsButton)
            {
                if (this.mButton == null)
                {
                    this.mButton = this.GetComponent <JCS_Button>();
                }
            }

            // let the button know this is going to be control in the group.
            if (mButton != null)
            {
                mButton.ButtonSelection = this;
            }
        }
Пример #9
0
        /// <summary>
        /// Initalize all the button.
        /// </summary>
        private void InitBtnsSet()
        {
            if (mOkBtn != null)
            {
                mOkBtn.SetSystemCallback(OkBtnCallback);
            }

            if (mNoBtn != null)
            {
                mNoBtn.SetSystemCallback(NoBtnCallback);
            }

            if (mYesBtn != null)
            {
                mYesBtn.SetSystemCallback(YesBtnCallback);
            }

            if (mNextBtn != null)
            {
                mNextBtn.SetSystemCallback(NextBtnCallback);
            }

            if (mPreviousBtn != null)
            {
                mPreviousBtn.SetSystemCallback(PreviousBtnCallback);
            }

            if (mExitBtn != null)
            {
                mExitBtn.SetSystemCallback(ExitBtnCallback);
            }

            if (mAcceptBtn != null)
            {
                mAcceptBtn.SetSystemCallback(AcceptBtnCallback);
            }

            if (mDeclineBtn != null)
            {
                mDeclineBtn.SetSystemCallback(DeclineBtnCallback);
            }

            for (int index = 0;
                 index < mSelectBtn.Length;
                 ++index)
            {
                JCS_Button btn = mSelectBtn[index];

                if (btn == null)
                {
                    continue;
                }

                btn.SetSystemCallback(SelectionInt, index);

                if (mMakeHoverSelect)
                {
                    if (btn.ButtonSelection == null)
                    {
                        JCS_Debug.LogWarning(@"Cannot make hover select 
because button selection is not attach to all selections in the list...");
                    }
                    else
                    {
                        EventTrigger eventTrigger = btn.GetComponent <EventTrigger>();
                        if (eventTrigger == null)
                        {
                            eventTrigger = btn.gameObject.AddComponent <EventTrigger>();
                        }

                        JCS_Utility.AddEventTriggerEvent(
                            eventTrigger,
                            EventTriggerType.PointerEnter,
                            mButtonSelectionGroup.SelectSelection,
                            btn.ButtonSelection);
                    }
                }
            }
        }