예제 #1
0
    private bool CamStyle2D = false;                                                                                    // Use to know if a 2D camera is used

    void Start()
    {
        anim               = GetComponent <Animator>();                                                         // Access to the Animator Component
        obj_Pivot_Cam      = GameObject.Find("Pivot_Cam");                                                      // Find object named Pivot_Cam on the hierarchy
        cameraSmoothFollow = obj_Pivot_Cam.GetComponent <CameraSmoothFollow>();                                 // Access to the CameraSmoothFollow Component from obj_Pivot_Cam

        AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);                                      // know what animation is active

        if (stateInfo.fullPathHash == MoveStateHash)
        {
            cameraSmoothFollow.Player_Change_Camera(8);                                                                                         // if MoveStateHash is set at default layer state
        }
        else
        {
            cameraSmoothFollow.Player_Change_Camera(1);                                                                                         // if IdleStateHash_1 is set at default layer state
        }
        LastView = CamView;

        GameObject tmp = GameObject.Find("PauseAndView");                                                                               // Find Gameobject Text_Camera

        if (tmp != null)
        {
            Transform[] children = tmp.GetComponentsInChildren <Transform>(true);

            foreach (Transform child in children)
            {
                if (child.name == "Text_Camera")
                {
                    Txt = child.GetComponent <Text>();                                                                                  // Access the component UI.Text
                    tmp = GameObject.Find("PauseAndView");
                }
            }

            if (tmp != null)
            {
                Transform[] children2 = tmp.GetComponentsInChildren <Transform>(true);

                foreach (Transform child in children2)
                {
                    if (child.name == "btn_Mobile_Pause")
                    {
                        Txt.transform.SetParent(child);                                                         // Make the gameObject child of btn_Mobile_Pause gameObject
                        Txt.gameObject.SetActive(true);                                                         // Set active this gamObject
                    }
                }
            }
        }



        if (cameraSmoothFollow.Return_CamStyle())
        {
            CamStyle2D = true;                                                                                                  // Cam 2D is used
        }
    }
예제 #2
0
    public void Selected_Cam()                                                                                                                                  // This function is used by the gameObject btn_Cam on the hierarchy to change the camera with a button on screen
    {
        AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);

        if (!CamStyle2D)
        {
            if (b_ChangeViewEnable && !CameraMultiBall && stateInfo.fullPathHash != MoveStateHash)
            {
                b_ChangeViewEnable = false;
                CamView++;                                                                                                                                                              // Choose the next camera
                if (CamView == 5)
                {
                    CamView = 1;
                }
                cameraSmoothFollow.Player_Change_Camera(CamView);                                                                               // Change the position of the camera
                if (Txt)
                {
                    Txt.text = CamView.ToString();                                                                                              // Change Text on screen
                }
            }
        }
    }