x


how to show cursor on specific time?

Hi

I am making a menu for my game. Before the menu appears in the game, I made an animation to the camera. How can I make the mouse cursor appear after the camera finishes its animation?

I forgot to say that I am showing a custom texture cursor by using this script:

var cursorImage : Texture; 

function Start() 
{ 
    Screen.showCursor = false; 
} 

function OnGUI() 
{ 
    var mousePos : Vector3 = Input.mousePosition; 
    var pos : Rect = Rect(mousePos.x, Screen.height - mousePos.y, cursorImage.width, cursorImage.height); 
    GUI.Label(pos,cursorImage); 
}

So what do I write instead of showCursor?

more ▼

asked Mar 28 '11 at 11:01 AM

Michael 20 gravatar image

Michael 20
32 14 15 16

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
function Start(){
    Screen.showCursor = false;
}

function Update(){
    if(!YourCamera.animation.isPlaying){
        Screen.showCursor = true;
    }
}

Just make sure the animation is set to ClampForever wrap mode.

more ▼

answered Mar 28 '11 at 11:09 AM

Sarper Soher gravatar image

Sarper Soher
1.6k 1 4 16

Or just Screen.showCursor = !YourCamera.animation.isPlaying; :)

Mar 28 '11 at 12:20 PM Statement ♦♦

Wouldn't ClampForever make isPlaying never to return false?

Mar 28 '11 at 12:21 PM Statement ♦♦
(comments are locked)
10|3000 characters needed characters left

CursorHide.js

Put this on your camera, and edit the animation name to your animation name.

function Start() 
{
    CustomCursor.showCursor = false;
    animation.Play("Intro");
    yield WaitForSeconds(animation["Intro"].length);
    CustomCursor.showCursor = true;
}

CustomCursor.js

var cursorImage : Texture; 
static var showCursor : boolean = true;

function Start() 
{ 
    Screen.showCursor = false; 
} 

function OnGUI() 
{ 
    if (!showCursor) 
        return;

    var mousePos : Vector3 = Input.mousePosition; 
    var pos : Rect = Rect(mousePos.x, Screen.height - mousePos.y, cursorImage.width, cursorImage.height); 
    GUI.Label(pos,cursorImage); 
}

Here's a textual step explaination of what goes on.

  1. Disable your custom cursor by setting its static showCursor variable to false.
  2. Start an animation called "Intro".
  3. Wait for the animation to finish by waiting for the length of the clip.
  4. Enable your custom cursor again so it can render.

I added a static variable called showCursor to your existing script and in OnGUI, if it is not true we exit the function so we don't render any gui.

more ▼

answered Mar 28 '11 at 12:26 PM

Statement gravatar image

Statement ♦♦
20.1k 35 70 175

I forgot to say that I am showing a custom texture cursor by using this script:

var cursorImage : Texture;

function Start() { Screen.showCursor = false; }

function OnGUI() { var mousePos : Vector3 = Input.mousePosition; var pos : Rect = Rect(mousePos.x,Screen.height - mousePos.y,cursorImage.width,cursorImage.height); GUI.Label(pos,cursorImage);

}

So what do I write instead of showCursor?

Mar 28 '11 at 12:44 PM Michael 20

Updated my code.

Mar 28 '11 at 01:02 PM Statement ♦♦

This error is appearing: Unknown identifier: 'CustomCursor'.

Mar 28 '11 at 01:19 PM Michael 20

Yeah, any idea why? It's because your cursor is in another script than CustomCursor.js. Just change CustomCursor to the name of your script that has the cursor.

Mar 28 '11 at 02:09 PM Statement ♦♦
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3772
x2991
x983
x385
x198

asked: Mar 28 '11 at 11:01 AM

Seen: 1229 times

Last Updated: Mar 28 '11 at 12:58 PM