Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

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

Script that makes the mouse cursor invisible. 3 Answers

orbit mouse camera animation movement script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges