I was hoping someone could check over my code here, tell me if I’m going about this the wrong way. If so, what would be a better way to tackle this. I’m fairly new to coding and am trying to use the search functions, but I’m at a point where I believe I’ve looked at this code too much and am having issues.
Assets/Instructionsmenu.js(8,46): BCE0005: Unknown identifier: ‘isPaused’.
Assets/Instructionsmenu.js(26,16): BCE0005: Unknown identifier: ‘guiSkin’.
Assets/Instructionsmenu.js(29,97): BCE0005: Unknown identifier: ‘nativeVerticalResolution’.
Assets/Instructionsmenu.js(29,139): BCE0005: Unknown identifier: ‘nativeVerticalResolution’.
Assets/Instructionsmenu.js(32,8): BCE0005: Unknown identifier: ‘isPaused’.
function Update()
{
if(Input.GetKeyDown("Instructions") && !isPaused)
{
print("Paused");
Time.timeScale = 0.0;
isPaused = true;
}
else if(Input.GetKeyDown("Instructions") && isPaused)
{
print("Unpaused");
Time.timeScale = 1.0;
isPaused = false;
}
}
function OnGUI ()
{
// Set up gui skin
GUI.skin = guiSkin;
// Our GUI is laid out for a 1920 x 1200 pixel display (16:10 aspect). The next line makes sure it rescales nicely to other resolutions.
GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (Screen.height / nativeVerticalResolution, Screen.height / nativeVerticalResolution, 1));
if(isPaused)
{
//RenderSettings.fogDensity = 1;
if(GUI.Button (Rect((Screen.width)/2, 480, 140,70), "W to walk forward", "button2"))
{
print("W to walk forward");
}
if(GUI.Button (Rect((Screen.width)/2,560,140,70), "S to walk backwards", "button2"))
{
print("S to walk backward");
}
if(GUI.Button (Rect((Screen.width)/2,560,140,70), "D to walk to the right", "button2"))
{
print("D to walk to the right");
}
if(GUI.Button (Rect((Screen.width)/2,560,140,70), "A to walk to the left", "button2"))
{
print("A to walk to the left");
}
if(GUI.Button (Rect((Screen.width)/2,560,140,70), "Left Mouse button to Fire Rifle", "button2"))
{
print("Left Mouse button to Fire Rifle");
}
if(GUI.Button (Rect((Screen.width)/2,640,340,70), "Back to the game", "button2"))
{
print("Back to the game");
Time.timeScale = 1.0;
isPaused = false;
}
}
}
@script AddComponentMenu ("GUI/Pause GUI")