Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CameraSwitching3 : MonoBehaviour
  6. {
  7.  
  8.     private bool pipEnabled = false;
  9.     //  public GameObject pipCam;
  10.     public Camera secondaryCamera;
  11.     public float pipOriginX =0.75f;
  12.     public float pipOriginY = 0.10f;
  13.     public float pipWidth = 0.25f;
  14.     public float pipHeight = 0.20f;
  15.  
  16.     public Vector3 primaryCameraOffest = new Vector3(0.0f,50.0f,150.0f);
  17.     private Camera primaryCamera;
  18.     private Rect pipdimension;
  19.     private GameObject player;
  20.  
  21.     // Use this for initialization
  22.     void Start ()
  23.     {
  24.         player = GameObject.FindGameObjectWithTag("Player");   
  25.     }
  26.    
  27.     // Update is called once per frame
  28.     void Update ()
  29.     {
  30.         // offset primary camera
  31.         transform.position = player.transform.position + primaryCameraOffest;
  32.         //Debug.Log(transform.position);
  33.         //Picture in Picture code
  34.         if(Input.GetKeyDown(KeyCode.P))
  35.         {
  36.             Debug.Log("pip enabled");
  37.             togglecam(pipEnabled);
  38.             secondaryCamera.rect = new Rect(pipOriginX,pipOriginY,pipWidth,pipHeight);
  39.             secondaryCamera.depth = 100;
  40.             secondaryCamera.enabled = pipEnabled;
  41.         }
  42.     }
  43.  
  44.     void togglecam (bool pipEnabled)
  45.     {
  46.         Debug.Log("toggledcam");
  47.         pipEnabled = !pipEnabled;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement