Maybe you can help me figure out how to do the following: when I click on an object a Gui window pops up with an image when I click the Gui the Gui disappears and the player goes back to the game, my question is how can I pause the game (so the player does not move, but the mouse does so I can click on the Gui) while the gui is up then un-pause the game when the Gui is clicked. Have a great weekend.
Have a great weekend.
I used this to create my pause menu for games (also my apps). This guide already gives you the scripts and talks about the mouse cursor, which I hope brings up or helps with your mouse problem…
Hopes this helps!
@Halo500 I checked out the site you linked me too but I still can’t get it to work, everything else works, got the cursor to not show up, in its place I have a cross-hair that changes when you hover over an object that has interactions (the GUI with the texture) and when you click on the texture the texture is removed, the only thing that does not work is the pausing or stopping of the game when you first click on the object here is the the scripts I am using.
// mouseRollover.js
// this script change a mouse cursor on the object
//
var myCursor:Texture2D;
var cursorSizeX: int = 32; // set to width of your cursor texture
var cursorSizeY: int = 32; // set to height of your cursor texture
var condition = true;
var i=1;
function OnMouseEnter(){
condition = false;
Screen.showCursor = false;
}
function OnMouseExit(){
condition = true;
Screen.showCursor = true;
}
function OnGUI(){
if(!condition){
GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX/2 + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY/2 + cursorSizeY/2, cursorSizeX, cursorSizeY),myCursor);
}
}
var popupTexture : Texture2D;
private var paperPopup : PaperPopup;
function Start () {
paperPopup = FindObjectOfType(PaperPopup);
if (popupTexture == null) {
popupTexture = renderer.material.mainTexture;
}
//pause the game
Time.timeScale = 0;
}
function OnMouseDown () {
paperPopup.Show(this);
}
// Called when the cursor is actually being locked
function DidLockCursor () {
Debug.Log("Locking cursor");
// Disable the button
}
// Called when the cursor is being unlocked
// or by a script calling Screen.lockCursor = false;
function DidUnlockCursor () {
Debug.Log("Unlocking cursor");
// Show the button again
}
function OnMouseDown () {
// Lock the cursor
Screen.lockCursor = true;
}
private var wasLocked = false;
function Update () {
// In standalone player we have to provide our own key
// input for unlocking the cursor
if (Input.GetKeyDown ("escape"))
Screen.lockCursor = false;
// Did we lose cursor locking?
// eg. because the user pressed escape
// or because he switched to another application
// or because some script set Screen.lockCursor = false;
if (!Screen.lockCursor && wasLocked) {
wasLocked = false;
DidUnlockCursor();
}
// Did we gain cursor locking?
else if (Screen.lockCursor && !wasLocked) {
wasLocked = true;
DidLockCursor ();
}
}
var cursorImage : Texture2D;
function Start()
{
Screen.showCursor = false;
}
function OnGUI()
{
GUI.DrawTexture(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 32, 32), cursorImage);
}
for the life of me I can’t figure it out…