education_kids

viewport Unity3d camera

Mar 19th, 2019
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Viewtest : MonoBehaviour {
  5.  
  6.     public Camera cam;
  7.  
  8.     public float somenum = 0.1f;
  9.     public bool isExpanded = false;
  10.     // Use this for initialization
  11.     void Start () {
  12.         cam = this.GetComponent<Camera> ();
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.         if (Input.GetKeyDown (KeyCode.UpArrow)){
  18.             isExpanded = !isExpanded;
  19.             cam.rect = new Rect(1f * somenum++ * 0.01f,1f * somenum++ * 0.01f,1f * somenum++ * 0.01f,1f * somenum++ * 0.01f);
  20.         }
  21.         if (Input.GetKeyDown (KeyCode.DownArrow)){
  22.             isExpanded = !isExpanded;
  23.             cam.rect = new Rect(1f * somenum-- * 0.01f,1f * somenum-- * 0.01f,1f * somenum-- * 0.01f,1f * somenum-- * 0.01f);
  24.         }
  25.         if (Input.GetKeyDown (KeyCode.LeftArrow)){
  26.             isExpanded = !isExpanded;
  27.             cam.rect = new Rect(somenum++ * -0.01f,1f * somenum++ * 0.01f,1f * somenum++,1f * somenum++);
  28.         }
  29.         if (Input.GetKeyDown (KeyCode.RightArrow)){
  30.             isExpanded = !isExpanded;
  31.             cam.rect = new Rect(somenum-- * -0.01f,1f * somenum-- * 0.01f,1f * somenum--,1f * somenum--);
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment