I’m trying to create a pause menu for my game, and I have most things working correctly, except the camera still looks around with the mouse movement. I searched on here and found something about using
However, it says in the console that “error CS1061: Type UnityEngine.Component' does not contain a definition for enabled’ and no extension method enabled' of type UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)” I’m completely lost since nothing seems to be working that I find online.
Any help would be appreciated, if you need to see my entire code I can post it, but this is the only error I’m getting. Thanks.
I suspect that Unity doesn’t know which type MouseLook is - the string version of GetComponent doesn’t give any clue about type to the compiler. You can try this:
If you get some kind of “Unknown type” error, use the ancestor type MonoBehaviour instead of MouseLook (MouseLook is C#, and your script is JS - C# and JS can’t see each other unless one of them is already compiled):
I can’t even count how often something like this has been asked
Well that’s why i don’t think that UnityScript is the best choice for beginners. It looks simpler but in the end you stump into the same problems.
GetComponent() always returns a reference of type Component. Even the “typeof” version will only return a Component because the compiler can’t tell what object will be returned by this fucntion. Only the generic version will return the “correct” type.
There are several ways to solve this.
Use the generic version of GetComponent.<MouseLook>() this will return a reference of the type you’ve given.
Cast it implicit into the correct type by assigning the returned reference to a variable of the correct type.