Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraSwitching3 : MonoBehaviour
- {
- private bool pipEnabled = false;
- // public GameObject pipCam;
- public Camera secondaryCamera;
- public float pipOriginX =0.75f;
- public float pipOriginY = 0.10f;
- public float pipWidth = 0.25f;
- public float pipHeight = 0.20f;
- public Vector3 primaryCameraOffest = new Vector3(0.0f,50.0f,150.0f);
- private Camera primaryCamera;
- private Rect pipdimension;
- private GameObject player;
- // Use this for initialization
- void Start ()
- {
- player = GameObject.FindGameObjectWithTag("Player");
- }
- // Update is called once per frame
- void Update ()
- {
- // offset primary camera
- transform.position = player.transform.position + primaryCameraOffest;
- //Debug.Log(transform.position);
- //Picture in Picture code
- if(Input.GetKeyDown(KeyCode.P))
- {
- Debug.Log("pip enabled");
- togglecam(pipEnabled);
- secondaryCamera.rect = new Rect(pipOriginX,pipOriginY,pipWidth,pipHeight);
- secondaryCamera.depth = 100;
- secondaryCamera.enabled = pipEnabled;
- }
- }
- void togglecam (bool pipEnabled)
- {
- Debug.Log("toggledcam");
- pipEnabled = !pipEnabled;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement