- Home /
Question by
Alokdo · Aug 27, 2016 at 06:51 AM ·
scripting problemscripting beginnerscript errorscriptingproblemscripterror
Activate/Deactivate Scripts form another Script
Hi, i got this error message in Unity:
Assets/Scripts/Res_levels/Pause.js(22,50): BCE0019: 'Enabled' is not a member of 'UnityEngine.Component'.
And this is my code:
#pragma strict
var isPaused : boolean = false;
var player : GameObject;
var playerCamera : GameObject;
var playerMouseLook : Component;
var playerCameraMouseLook : Component;
function Start () {
playerMouseLook = player.GetComponent("MouseLook");
playerCameraMouseLook = playerCamera.GetComponent("MouseLook");
}
function Update () {
if (Input.GetKeyDown(KeyCode.Escape)) {
if (isPaused == false){
playerMouseLook.Enabled = false;
playerCameraMouseLook.Enabled = false;
}
else {
playerMouseLook.enabled = true;
playerCameraMouseLook.enabled = true;
}
}
}
Somebody knows what's happening? (Sorry for bad english)
Comment
Try with a small "e": player$$anonymous$$ouseLook.enabled = false;
Answer by alexander11 · Aug 28, 2016 at 02:46 AM
Ok replace line 15 to line 25 with this(i have not test it however you'll get the concept).
function Update ()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
playerMouseLook.enabled = !playerMouseLook.enabled;
playerCameraMouseLook.enabled = !playerCameraMouseLook.enabled;
}
}