コード例 #1
0
        /* Functions */

        private void Start()
        {
            // Only need it for the UI.
            if (GetObjectType() == JCS_UnityObjectType.UI ||
                GetObjectType() == JCS_UnityObjectType.TEXT)
            {
                // Get panel root, in order to calculate the correct distance
                // base on the resolution.
                mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();

                if (mAutoAddEvent)
                {
                    // Event trigger is the must if we need to add the
                    // event to event trigger system.
                    {
                        this.mEventTrigger = this.GetComponent <EventTrigger>();
                        if (this.mEventTrigger == null)
                        {
                            this.mEventTrigger = this.gameObject.AddComponent <EventTrigger>();
                        }
                    }

                    JCS_Util.AddEventTriggerEvent(mEventTrigger, mActiveEventTriggerType, JCS_OnMouseOver);
                    JCS_Util.AddEventTriggerEvent(mEventTrigger, mDeactiveEventTriggerType, JCS_OnMouseExit);
                }
            }

            Vector3 currentScale = this.transform.localScale;

            // record down the scale.
            mRecordScale = currentScale;
            mTargetScale = currentScale;

            SetTargetScale();
        }
コード例 #2
0
        /* Functions */

        private void Awake()
        {
            this.mRectTransform = this.GetComponent <RectTransform>();

            if (mPanelRoot == null)
            {
                mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
            }

            this.mIsUnityDefinedUI = IsUnityDefinedUI();

            // Rely on "Script Execution Order"
            {
                /* Check 'jpr' null for spawn GUI objects. */
                if (mPanelRoot != null)
                {
                    FitPerfectSize(
                        mPanelRoot.PanelDeltaWidthRatio,
                        mPanelRoot.PanelDeltaHeightRatio);
                }

                if (!mIsUnityDefinedUI)
                {
                    // since we add this script assuming we are
                    // int the fit perfect size mode
                    // see "JCS_PanelRoot" -> mFitScreenSize variables
                    AddPanelChild();
                }
            }
        }
コード例 #3
0
        //----------------------
        // Protected Variables

        //========================================
        //      setter / getter
        //------------------------------

        //========================================
        //      Unity's function
        //------------------------------
        private void Awake()
        {
            this.mRectTransform = this.GetComponent <RectTransform>();

            // Rely on "Script Execution Order"
            {
                JCS_PanelRoot jpr = this.GetComponentInParent <JCS_PanelRoot>();

                // get all the same class object on this game object.
                JCS_PanelChild[] tempPanelChild = null;
                tempPanelChild = this.GetComponents <JCS_PanelChild>();

                // only do it once.
                if (/* Check 'jpr' null for spawn GUI objects. */
                    jpr != null &&
                    /* Regular checks. */
                    tempPanelChild.Length == 1 &&
                    tempPanelChild[0] == this)
                {
                    FitPerfectSize(
                        jpr.PanelDeltaWidthRatio,
                        jpr.PanelDeltaHeightRatio);
                }

                // since we add this script assuming we are
                // int the fit perfect size mode
                // see "JCS_PanelRoot" -> mFitScreenSize variables
                AddPanelChild();
            }
        }
コード例 #4
0
        /* Functions */

        private void Awake()
        {
            this.mTweenerHandler = this.GetComponent <JCS_TweenerHandler>();
            if (mSoundPlayer == null)
            {
                this.mSoundPlayer = this.GetComponent <JCS_SoundPlayer>();
            }

            this.mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
        }
コード例 #5
0
        /* Functions */

        private void Start()
        {
            // Only need it for the UI.
            if (GetObjectType() == JCS_UnityObjectType.UI ||
                GetObjectType() == JCS_UnityObjectType.TEXT)
            {
                // Get panel root, in order to calculate the
                // correct distance base on the resolution.
                mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
            }
        }
コード例 #6
0
        private void Start()
        {
            this.mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();

            if (mPanelRoot != null)
            {
                // Adjust the offset base on the screen size.
                mPointerOffset.x /= mPanelRoot.PanelDeltaWidthRatio;
                mPointerOffset.y /= mPanelRoot.PanelDeltaHeightRatio;
            }
        }
コード例 #7
0
        private void Start()
        {
            this.mStartingPosition = this.mTransformTweener.LocalPosition;

            // NOTE(jenchieh): Make compatible to resizable screen.
            {
                this.mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
                if (mPanelRoot != null)
                {
                    mTargetPosition.x /= mPanelRoot.PanelDeltaWidthRatio;
                    mTargetPosition.y /= mPanelRoot.PanelDeltaHeightRatio;
                }
            }
        }
コード例 #8
0
        private void Start()
        {
            // Set the canvas to be our root.
            this.transform.SetParent(JCS_Canvas.instance.transform);

            // Add panel root without losing the original size.
            {
                Vector2 originalSize = mRectTransform.sizeDelta;

                this.mPanelRoot = this.gameObject.AddComponent <JCS_PanelRoot>();

                mRectTransform.sizeDelta = originalSize;
            }

            SetToScreenEdge();
        }
コード例 #9
0
        /// <summary>
        /// Return the screen size according to the GUI mode.
        /// </summary>
        /// <returns>
        /// Return a Vector2 with screen width and height.
        /// </returns>
        private Vector2 GetScreenSize()
        {
            float screenWidth  = 0.0f;
            float screenHeight = 0.0f;

            JCS_ScreenSettings ss  = JCS_ScreenSettings.instance;
            JCS_Camera         cam = JCS_Camera.main;

            JCS_PanelRoot panelRoot = mPanelHolder.slidePanels[0].GetComponent <JCS_PanelRoot>();

            if (panelRoot == null)
            {
                panelRoot = mPanelHolder.slidePanels[0].GetComponentInParent <JCS_PanelRoot>();
            }

            switch (mUnityGUIType)
            {
            case JCS_UnityGUIType.uGUI_2D:
            {
                if (panelRoot != null)
                {
                    screenWidth  = ss.STARTING_SCREEN_SIZE.width;
                    screenHeight = ss.STARTING_SCREEN_SIZE.height;
                }
                else
                {
                    screenWidth  = ss.STANDARD_SCREEN_SIZE.width;
                    screenHeight = ss.STANDARD_SCREEN_SIZE.height;
                }
            }
            break;

            case JCS_UnityGUIType.nGUI_3D:
            {
                screenWidth  = cam.CamRectSize.x;
                screenHeight = cam.CamRectSize.y;
            }
            break;
            }

            return(new Vector2(screenWidth, screenHeight));
        }
コード例 #10
0
        /* Functions */

        private void Awake()
        {
            this.mRectTransform = this.GetComponent <RectTransform>();

            if (mPanelRoot == null)
            {
                mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
            }

            if (IsResponsive())
            {
                mApplyToChildren = JCS_UIUtil.IsAchorPresets(mRectTransform, JCS_AnchorPresetsType.CENTER_MIDDLE);
            }
            else
            {
                mApplyToChildren = !JCS_UIUtil.IsUnityDefinedUI(mRectTransform);
            }

            // Rely on "Script Execution Order"
            {
                /* Check 'jpr' null for spawn GUI objects. */
                if (mPanelRoot != null)
                {
                    FitPerfectSize(
                        mPanelRoot.PanelDeltaWidthRatio,
                        mPanelRoot.PanelDeltaHeightRatio);
                }

                if (mApplyToChildren)
                {
                    // since we add this script assuming we are  int the fit
                    // perfect size mode
                    //
                    // see "JCS_PanelRoot" -> mFitScreenSize variables
                    AddPanelChild();
                }
            }
        }
コード例 #11
0
        /* Functions */

        private void Start()
        {
            // NOTE: Record down all the starting values.
            for (int index = 0; index < mTweenInfos.Count; ++index)
            {
                JCS_TweenInfo ti = mTweenInfos[index];
                switch (ti.transformTweener.TweenType)
                {
                case JCS_TransformType.POSITION:
                    ti.startingValue = ti.transformTweener.LocalPosition;
                    break;

                case JCS_TransformType.ROTATION:
                    ti.startingValue = ti.transformTweener.LocalEulerAngles;
                    break;

                case JCS_TransformType.SCALE:
                    ti.startingValue = ti.transformTweener.LocalScale;
                    break;
                }
            }

            // NOTE: Make compatible to resizable screen.
            {
                this.mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
                if (mPanelRoot != null)
                {
                    for (int index = 0; index < mTweenInfos.Count; ++index)
                    {
                        JCS_TweenInfo tt = mTweenInfos[index];
                        tt.targetValue.x /= mPanelRoot.PanelDeltaWidthRatio;
                        tt.targetValue.y /= mPanelRoot.PanelDeltaHeightRatio;
                    }
                }
            }
        }
コード例 #12
0
        //----------------------
        // Protected Variables

        //========================================
        //      setter / getter
        //------------------------------

        //========================================
        //      Unity's function
        //------------------------------
        private void Awake()
        {
            this.mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();
        }
コード例 #13
0
ファイル: JCS_SlideEffect.cs プロジェクト: tuita520/JCSUnity
        private void Start()
        {
            // Only need it for the UI.
            if (GetObjectType() == JCS_UnityObjectType.UI ||
                GetObjectType() == JCS_UnityObjectType.TEXT)
            {
                // Get panel root, in order to calculate the
                // correct distance base on the resolution.
                mPanelRoot = this.GetComponentInParent <JCS_PanelRoot>();

                if (mAutoAddEvent)
                {
                    // Event trigger is the must if we need to add the
                    // event to event trigger system.
                    {
                        this.mEventTrigger = this.GetComponent <EventTrigger>();
                        if (this.mEventTrigger == null)
                        {
                            this.mEventTrigger = this.gameObject.AddComponent <EventTrigger>();
                        }
                    }

                    JCS_Utility.AddEventTriggerEvent(mEventTrigger, mActiveEventTriggerType, JCS_OnMouseOver);
                    JCS_Utility.AddEventTriggerEvent(mEventTrigger, mDeactiveEventTriggerType, JCS_OnMouseExit);
                }
            }

            Vector3 newPos = this.transform.localPosition;

            // record the original position
            this.mRecordPosition = newPos;
            this.mTargetPosition = newPos;

            switch (mAxis)
            {
            case JCS_Axis.AXIS_X:
            {
                // mPanelRoot will be null is the object isn't
                // UI game object.
                if (mPanelRoot != null)
                {
                    mDistance /= mPanelRoot.PanelDeltaWidthRatio;
                }

                newPos.x += mDistance;
            }
            break;

            case JCS_Axis.AXIS_Y:
            {
                // mPanelRoot will be null is the object isn't
                // UI game object.
                if (mPanelRoot != null)
                {
                    mDistance /= mPanelRoot.PanelDeltaHeightRatio;
                }

                newPos.y += mDistance;
            }
            break;

            case JCS_Axis.AXIS_Z:
            {
                newPos.z += mDistance;
            }
            break;
            }

            this.mTowardPosition = newPos;
        }