• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Michael 20 · Mar 28, 2011 at 11:01 AM · animationcameramousemenucursor

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Statement · Mar 28, 2011 at 12:20 PM 0
Share

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

avatar image Statement · Mar 28, 2011 at 12:21 PM 0
Share

Wouldn't ClampForever make isPlaying never to return false?

avatar image
0

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.

  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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Michael 20 · Mar 28, 2011 at 12:44 PM 0
Share

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?

avatar image Statement · Mar 28, 2011 at 01:02 PM 0
Share

Updated my code.

avatar image Michael 20 · Mar 28, 2011 at 01:19 PM 0
Share

This error is appearing: $$anonymous$$ identifier: 'CustomCursor'.

avatar image Statement · Mar 28, 2011 at 02:09 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Camera Animation On Click Help? 1 Answer

Make camera slightly follow cursor at menu. 0 Answers

Screen.lockCursor messes my rotation 1 Answer

Script that makes the mouse cursor invisible. 3 Answers

orbit mouse camera animation movement script 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges