Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ToggleFullscreen : MonoBehaviour {
  5.     public Texture2D zoom_off;
  6.     public Texture2D zoom_on;
  7.     private Vector3 mp;
  8.     public float indent;
  9.     // Use this for initialization
  10.     void Start () {
  11.     }
  12.     // Update is called once per frame
  13.     void Update () {
  14.         switchTexture();
  15.         if (Input.GetMouseButtonUp(0)){
  16.             mp = Input.mousePosition;
  17.             if (guiTexture.HitTest(mp)){
  18.                 Screen.fullScreen = !Screen.fullScreen;
  19.                 Screen.SetResolution (Screen.currentResolution.width, Screen.currentResolution.height, true);
  20.             }
  21.         }
  22.  
  23.     }
  24.    
  25.     void switchTexture(){
  26.         if(Screen.fullScreen)
  27.             guiTexture.texture = zoom_off;
  28.         else
  29.             guiTexture.texture = zoom_on;
  30.         guiTexture.pixelInset = new Rect(-17.5f,-(Screen.height/2-indent),32f,32f);
  31.     }
  32.    
  33.    
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement