/
CursorControl.cs
51 lines (43 loc) · 1.07 KB
/
CursorControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using UnityEngine;
using System.Collections;
/// <summary>
/// This script is attached to the player and it controls
/// whether the cursor is locked or unlocked.
///
/// This script accesses the MultiplayerScript
///
/// All code is taken from Gamer To Game Developer Series 1
/// http://www.gamertogamedeveloper.com
/// No credit is taken myself
/// </summary>
public class CursorControl : MonoBehaviour {
// Variables start__________________________
private GameObject multiplayerManager;
private MultiplayerScript multiScript;
// Variables end____________________________
// Use this for initialization
void Start ()
{
if(networkView.isMine == true)
{
multiplayerManager = GameObject.Find("MultiplayerManager");
multiScript = multiplayerManager.GetComponent<MultiplayerScript>();
}
else
{
enabled = false;
}
}
// Update is called once per frame
void Update ()
{
if(multiScript.showDisconnectWindow == false)
{
Screen.lockCursor = true;
}
if(multiScript.showDisconnectWindow == true)
{
Screen.lockCursor = false;
}
}
}