- Home /
Need help with errors BCE0019, BCE005 and Bce0034
I was working on a pause menu script and two kinds of errors popped up.
Assets/Scripts/Pause Menu.js(22,28): BCE0019 'enabled' is not a member of 'UnityEditor.MonoScript'. Assets/Scripts/Pause Menu.js(23,19): BCE0019 'enabled' is not a member of 'UnityEditor.MonoScript'. Assets/Scripts/Pause Menu.js(24,9): BCE0019 'enabled' is not a member of 'UnityEditor.MonoScript'. Assets/Scripts/Pause Menu.js(25,16): BCE0019 'enabled' is not a member of 'UnityEditor.MonoScript'. and more...
Assets/Scripts/Pause Menu.js(24,9): BCE005: Unknown identifier: 'CharacterMoter'
The whole script is:
#pragma strict
var PauseGUI : GUIText;
var paused : boolean = false;
private var FPSInputController : MonoScript;
private var MouseLook : MonoScript;
private var CharacterMotor : MonoScript;
private var Player : MonoScript;
function Start ()
{
CharacterMotor = GetComponent(MonoScript);
Player = GetComponent(MonoScript);
MouseLook = GetComponent(MonoScript);
FPSInputController = GetComponent(MonoScript);
paused = false;
Time.timeScale = 1;
PauseGUI.enabled = false;
FPSInputController.enabled = true;
MouseLook.enabled = true;
CharacterMoter.enabled = true;
Player.enabled = true;
}
function Update ()
{
if (Input.GetKeyDown("p") && paused == false)
{
paused = true;
Time.timeScale = 0;
PauseGUI.enabled = true;
FPSInputController.enabled = false;
MouseLook.enabled = false;;
CharacterMoter.enabled = false;;
Player.enabled = false;
}
else if (Input.GetKeyDown("p") && paused == true)
{
paused = false;
Time.timeScale = 1;
PauseGUI.enabled = false;
FPSInputController.enabled = true;
MouseLook.enabled = true;
CharacterMoter.enabled = true;
Player.enabled = true;
}
}
Thanks in advance!
Wow, I have never seen GetComponent used like that. Does $$anonymous$$onoScript work for a component? If it does, then how do you know which $$anonymous$$onoScript you have stored a reference to?
All your variable names are the names of classes (which could lead to issues/conflicts), this is why the standard convention for variable names is to use camelCase.
I would use GetComponent using the name of the class (class as a component) :
character$$anonymous$$otor = GetComponent(Character$$anonymous$$otor);
player = GetComponent(PlayerScript);
mouseLook = GetComponent($$anonymous$$ouseLook);
fpsInputController = GetComponent(FPSInputController);
@alucardj - $$anonymous$$onoScript is derived from TextAsset. It is an editor only class and used to store the text of a script. It cannot be used as he is attempting. I believe the OP is just confused about how to declare and initialize the variables.
Answer by Mr.Hal · May 10, 2014 at 12:33 AM
What you want to do is make
private var FPSInputController : MonoScript;
private var MouseLook : MonoScript;
private var CharacterMotor : MonoScript;
private var Player : MonoScript;
to
private var FPSInputController : FPSInputController;
private var MouseLook : MouseLook;
private var CharacterMotor : CharacterMotor;
private var Player : PlayerScript;
You also need to get the components like how agoalucardj said in the question comments. You can't use GetComponent or enabled on Monoscripts but you can on MonoBehaviour because Monoscripts are inherited from TextAssets, and are not inherited from Components. And for some strange reason this doesn't work, remove "private" from your "var"s and assign the scripts in the inspector and avoid getcomponent completly.
I would also rewrite your update function, Pretty inefficient. but your start function seems fine though.
function Update ()
{
if (Input.GetKeyDown("p"))
{
paused != paused;
if(paused){
Time.timeScale = 0;
PauseGUI.enabled = true;
FPSInputController.enabled = false;
MouseLook.enabled = false;;
CharacterMoter.enabled = false;;
Player.enabled = false;}
else{
Time.timeScale = 1;
PauseGUI.enabled = false;
FPSInputController.enabled = true;
MouseLook.enabled = true;
CharacterMoter.enabled = true;
Player.enabled = true;}
}
}
Oh and you have a misspelling for Character$$anonymous$$otor...
Thanks for your help but there is a new error now...
Assets/scripts/Pause $$anonymous$$enu.js(27,12): BCE0034 : Expressions in statements must only be executed for their side-effects
Your answer
Follow this Question
Related Questions
Material on mesh 0 Answers
InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread 2 Answers
GUI Skin Not Working With Static Bool 2 Answers
Pause Game 1 Answer