- Home /
Struggling with my pause menu and main menu
So i've just finished my game project and now I want to implement a main menu and pause menu. I decided to start with the pause menu. So I've got a pause menu code here that I thought would work but it's throwing up some errors and I'm not sure why.
Basically what I've got is a Game Object called Capsule that has a Look Object and Main Camera. I'm scripting in C# but my Mouse look script is in JS because I downloaded it as an asset.
Now I've written this pause script (following a tutorial) and attached it to the Capsule, but it gives me the errors "The type or namespace name "FPSMouseLook" could not be found. Are you missing a using directive or an assembly reference?
Help would be much appreciated!
using UnityEngine;
using System.Collections;
public class pause : MonoBehaviour {
public bool isPause, paused;
// Use this for initialization
void Start () {
paused = false;
Screen.lockCursor = true;
Time.timeScale = 1;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.Escape)) {
paused = togglePause ();
}
}
bool togglePause()
{
if(Time.timeScale == 0){
GameObject.Find("Capsule").GetComponent<FPSMouseLook>().enabled = true;
Screen.lockCursor = true;
Time.timeScale = 1;
return(false);
}
else{
GameObject.Find("Capsule").GetComponent<FPSMouseLook>().enabled = false;
Screen.lockCursor = false;
Time.timeScale = 0;
return(true);
}
}
}
Do you have the component FPS$$anonymous$$ouseLook assigned to the Capsule, or did that come from the tut code and you don't have that?
I have the FPS$$anonymous$$ouseLook attached to my Capsule.
Answer by William_Goodspeed · May 10, 2014 at 11:08 PM
Okay I don't have a solution to why this problem was happening but I did find a fix for it.
I replaced the FPSMouseLook script which was Javascript with the standard MouseLook c# version and the script then ran fine. So my suspicion is that there was an issue in referencing a Javascript from a C# script.
Yes that is a common issue; search for many posts/solutions on Unity JS calling C# and vice versa; sorry didn't notice you mentioned that in problem description.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Menu, Game mode Array String to change settings? 1 Answer
Player movement isn't working 1 Answer
Menu Selection using 360 Controller 0 Answers