- Home /
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?
Answer by SarperS · Mar 28, 2011 at 11:09 AM
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.
Or just Screen.showCursor = !YourCamera.animation.isPlaying; :)
Wouldn't ClampForever make isPlaying never to return false?
Answer by Statement · Mar 28, 2011 at 12:26 PM
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.
- Disable your custom cursor by setting its static showCursor variable to false.
- Start an animation called "Intro".
- Wait for the animation to finish by waiting for the length of the clip.
- 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.
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 ins$$anonymous$$d of showCursor?
This error is appearing: $$anonymous$$ identifier: 'CustomCursor'.
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613115259im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make Camera face cursor 0 Answers
Camera Animation On Click Help? 1 Answer
Fps Rigidbody controller with mouse cursor? 0 Answers