I get this error:
Assets/PlayerSetup.cs(25,45): error CS0176: Static member `UnityEngine.Camera.main’ cannot be accessed with an instance reference, qualify it with a type name instead
Here is my script:
using UnityEngine;
using UnityEngine.Networking;
public class PlayerSetup : NetworkBehaviour {
[SerializeField]
Behaviour[] componentsToDisable;
Camera sceneCamera;
void Start ()
{
if (!isLocalPlayer)
{
for (int i = 0; i < componentsToDisable.Length; i++)
{
componentsToDisable*.enabled = false;*
-
}*
-
}*
-
else*
-
{*
-
sceneCamera = Camera.main;*
-
if (sceneCamera != null)*
-
{*
-
sceneCamera.main.gameObject.SetActive(false);*
-
}*
-
}*
- }*
- void OnDisable ()*
- {*
-
if (sceneCamera != null)*
-
{*
-
sceneCamera.gameObject.SetActive(false);*
-
}*
- }*
}