Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- // Simple script to make the game behave as a screensaver (quit when there's any input, hide the cursor)
- // For extra points, make sure to set the Player Settings to skip the Resolution Dialog, and use Capture Display on OSX
- public class Screensaver : MonoBehaviour {
- void Awake() {
- _st = Time.time;
- _lastMousePos = Input.mousePosition;
- Screen.showCursor = false;
- }
- float _st;
- Vector3 _lastMousePos;
- void Update () {
- if (Time.time - _st > 3) {
- if (Input.anyKeyDown || (int)_lastMousePos.x != (int)Input.mousePosition.x || (int)_lastMousePos.y != (int)Input.mousePosition.y) {
- Application.Quit();
- }
- }
- _lastMousePos = Input.mousePosition;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement