I’m getting a error that says Assets/Script/Menu/BackToMenu.cs(4,23): error CS8025: Parsing error
while using this script:
using UnityEngine;
using System.Collections;
public var CameraMain : Camera ;
public var CameraChooseLevel : Camera ;
public var CameraControls : Camera ;
public var CameraCredits : Camera ;
void OnMouseDown()
{
CameraMain.camera.enabled = true;
CameraChooseLevel.camera.enabled = false;
CameraControls.camera.enabled = false;
CameraCredits.camera.enabled = false;
}
}
Help please thanks
You must declare name of class and use CSharp language:
using UnityEngine;
using System.Collections;
//Declare name of class
public class myClassName : MonoBehaviour {
public Camera CameraMain;
public Camera CameraChooseLevel;
public Camera CameraControls;
public Camera CameraCredits;
void OnMouseDown() {
CameraMain.camera.enabled = true;
CameraChooseLevel.camera.enabled = false;
CameraControls.camera.enabled = false;
CameraCredits.camera.enabled = false;
}
}
And check all cameras variable: must not be null. I hope that it will help you.
Your property declarations are not in C#. Change them to this syntax:
scope type name;
The scope should be “public”, as I assume you are assigning these properties via the inspector since i see no code that assigns them. The type should be “Camera”, which is the type of component you’re looking for. The name should be whatever you wish to call your variable.
All in all, your property declarations should look like this:
public Camera CameraMain;
public Camera CameraChooseLevel;
public Camera CameraControls;
public Camera CameraCredits;