- Home /
Game is Paused Menu shows up
Hi,
first, i already spend lots of time looking up previously ask questions. I even found many good answers. But unfortunately i am not able to achive exactly what i want.
What i want (for now):
When u click the mousebutton the game stops (i dont care about anything, but the mouselook. i dont want to look around navigating through the menu) and the menu shows up. Within the menu u can choose between different objekts u can choose materials for. When u cilick the mousebutton again everything disappears.
Now, all of that can be realy basic (normal gui buttons are enough). How i aready mentioned i already tried alot to achive that, and the whole part with the buttons and the menu works just fine. The biggest Problem i have is the game pause. I realy dont get, why its not working.
So here is the code i already put together.
var isGamePaused : boolean = false;
var material1 : Material;
var material2 : Material;
var material3 : Material;
var material4 : Material;
function Update()
{
if(Input.GetKeyDown(KeyCode.Mouse0)){
if(!isGamePaused){
isGamePaused = true;
GameObject.Find("First Person Controller").GetComponent("MouseLook").enabled = false;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = false;
}
}
if(Input.GetKeyDown(KeyCode.Mouse0)){
if (isGamePaused){
isGamePaused = false;
GameObject.Find("First Person Controller").GetComponent("MouseLook").enabled = true;
GameObject.Find("Main Camera").GetComponent("MouseLook").enabled = true;
}
}
}
function OnGUI ()
{
if(isGamePaused)
{
if (GUI.Button(Rect (0,0, 100,50), "Boden"))
{
if(GameObject.Find("3d_daten__3d_Boden").renderer.sharedMaterial == material1)
GameObject.Find("3d_daten__3d_Boden").renderer.sharedMaterial = material2;
else
GameObject.Find("3d_daten__3d_Boden").renderer.sharedMaterial = material1;
}
if (GUI.Button(Rect (100,0, 100,50), "Profile"))
{
if(GameObject.Find("3d_daten__3d_Profile").renderer.sharedMaterial == material3)
GameObject.Find("3d_daten__3d_Profile").renderer.sharedMaterial = material4;
else
GameObject.Find("3d_daten__3d_Profile").renderer.sharedMaterial = material3;
}
}
}
Thanks in advance.
Stephan