I am fixing a bug that my game has. The bug is that when the game is paused, some scripts are disabled (specifically camera orbiting ones), but if you click on a brick(programmed to disable the same scripts when being dragged), the camera orbit disabling scripts are enabled even though it is in pause mode because of an OnMouseUp function.
When trying to fix the bug with a boolean in the pause menu script(C#), and I need to change that boolean from the camera orbit script(js). But I get the following similar errors:
Assets/disableMouseOrbit.js(13,71): BCE0005: Unknown identifier: ‘PauseMenu’.
and
Assets/disableMouseOrbit.js(22,41): BCE0005: Unknown identifier: ‘PauseMenu’.
Here are my scripts (sorry if they are messy):
Pause Menu:
using UnityEngine;
using System.Collections;
public class pauseMenu : MonoBehaviour {
public bool paused = false;
bool isButtonVisible = true;
Rect buttonRectangle = new Rect(100, 100, 100, 50);
public MouseOrbit mouseOrbitScript;
public PartMenu partMenu2;
void Start()
{
mouseOrbitScript = Camera.main.GetComponent<MouseOrbit>();
}
void Update () {
if(Input.GetKeyUp(KeyCode.Escape) && paused == false)
{
paused = true;
isButtonVisible = false;
Time.timeScale = 0;
mouseOrbitScript.enabled = false;
GetComponent<PartMenu>().enabled = false;
}
else if(Input.GetKeyUp(KeyCode.Escape) && paused == true) {
paused = false;
mouseOrbitScript.enabled = true;
isButtonVisible = true;
Time.timeScale = 1;
GetComponent<PartMenu>().enabled = true;
}
}
void OnGUI ()
{
if ( isButtonVisible ) {
if ( GUI.Button(buttonRectangle, "Turn Me Off") ) {
isButtonVisible = false;
}
}
}
}
Disable Camera Orbit:
var mouseOrbitScript : MouseOrbit;
var pauseMenuScript : GameObject;
function Start()
{
mouseOrbitScript = Camera.main.GetComponent(MouseOrbit);
GetComponent(Rigidbody).transform.rigidbody.isKinematic = true;
}
function OnMouseOver ()
{
if(Input.GetKeyDown(KeyCode.Mouse0)&&pauseMenuScript.GetComponent(PauseMenu).paused == false)
{
mouseOrbitScript.enabled = false;
GetComponent(Rigidbody).transform.rigidbody.isKinematic = false;
}
}
function OnMouseUp()
{
if(pauseMenuScript.GetComponent(PauseMenu).paused == false){
mouseOrbitScript.enabled = true;
GetComponent(Rigidbody).transform.rigidbody.isKinematic = true;
}
}
There may still be bits of code that were from previous attempts to fix the bug, please point them out if you see any.
I changed the name and class declaration, but still no luck
– ashjack