Advertisement
Guest User

#screensaverjam script to make a proper screensaver

a guest
Jan 24th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. // Simple script to make the game behave as a screensaver (quit when there's any input, hide the cursor)
  5. // For extra points, make sure to set the Player Settings to skip the Resolution Dialog, and use Capture Display on OSX
  6. public class Screensaver : MonoBehaviour {
  7.     void Awake() {
  8.         _st = Time.time;
  9.         _lastMousePos = Input.mousePosition;
  10.         Screen.showCursor = false;
  11.     }
  12.    
  13.     float _st;
  14.     Vector3 _lastMousePos;
  15.     void Update () {
  16.         if (Time.time - _st > 3) {
  17.             if (Input.anyKeyDown || (int)_lastMousePos.x != (int)Input.mousePosition.x || (int)_lastMousePos.y != (int)Input.mousePosition.y) {
  18.                 Application.Quit();
  19.             }
  20.         }
  21.         _lastMousePos = Input.mousePosition;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement