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
1
Question by Noise crime · Jun 05, 2010 at 09:12 AM · inputtimeinteraction

Does Unity provide a means to determine the time since the last user interaction?

Title says it all.

I've looked through the docs, but haven't found a function or property that tells you the time since the last user interaction, ( including any/all of mouse movement, mouse clicks, keyboard etc). Does something exist, or do you have to track this yourself?

Comment
Add comment · Show 2
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 Cyclops · Jun 06, 2010 at 02:47 PM 0
Share

@Noisecrime, maybe it would help if you explained what you want to do with the information - what's the goal? There may be other, easier ways to achieve it than tracking mouse-clicks.

avatar image Noise crime · Jun 06, 2010 at 07:40 PM 0
Share

Its a simple time-out script, i.e when no-one has interacted for a set amount of time, the applications switches to an 'attract' loop. Polling in update will work fine, I just thought it was odd not to find a built in property for it, since it would easily hook into UNity's own code when checking for mouse/keyboard/joystick input.

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by qJake · Jun 05, 2010 at 09:20 AM

No, you need to track it yourself, but it should be pretty easy with Input.anyKey and Input.mousePosition.

http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html

http://unity3d.com/support/documentation/ScriptReference/Input-anyKey.html

You could wrap those into a simple component script that tracked these two values inside of Update(), and you could fire off an event when either/both changed, or you could set a flag (bool) for when there was input or not.

Comment
Add comment · Show 8 · 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 Noise crime · Jun 05, 2010 at 10:17 AM 0
Share

Actually thinking about it mouse movement is pretty irrelevant as you have to click to begin dragging ;) Its straightforward enough to roll my own, trouble is I have several guitextures and colliders that all re-act to mousedown/up events, plus some generic mouseinput checks in update, so that means routing a callback to some centralised object to track input and update the timer. Was just hoping i'd missed something in the docs, since obviously Unity could easily track this itself. thx

avatar image Noise crime · Jun 05, 2010 at 10:20 AM 0
Share

Doh, of course as you say a single component script checking for input.Get$$anonymous$$ouseButton() and input.anykey in update() should work just as well and would be much cleaner.

avatar image qJake · Jun 05, 2010 at 10:21 AM 0
Share

Lots of things that Unity "could" do are not actually included with the editor. I'm not sure why, but my guess is that they want you to code it yourself, but only if you need it. $$anonymous$$eep It Simple, Stupid. :P - http://en.wikipedia.org/wiki/$$anonymous$$eep_it_simple_stupid

avatar image Noise crime · Jun 05, 2010 at 10:32 AM 0
Share

Only problem of course is i'm polling mouse input every frame now, but thats not too bad in this case. Whilst I can understand you wouldn't want to put the kitchen sink into Unity, this is pretty basic functionality that should be simple to have, since Unity itself is obviously detecting interaction and routing it to scripts.

avatar image qJake · Jun 06, 2010 at 08:20 PM 1
Share

@Noisecrime Lots of things in Unity that you would expect to be there "because it would be easy", are not included for the reason I said earlier, and that was because they didn't want to include something unless it was really needed by a lot of people, and couldn't be easily scripted. This property can be very easily scripted with little to no performance impact (if done correctly), so there was no need to add it into Unity, since you can just code it yourself. You'll find lots of "do-it-yourself" scenarios like this one when using Unity. :P

Show more comments
avatar image
0

Answer by Ricardo · Jun 05, 2010 at 09:23 AM

There's nothing documented on the Input class to this effect. Moreover, there is no general OnMouseMove, only OnMouseOver for objects with colliders.

Comment
Add comment · Show 5 · 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 qJake · Jun 05, 2010 at 09:35 AM 1
Share

That doesn't mean you can't track Input.mousePosition every frame.

avatar image Ricardo · Jun 05, 2010 at 10:58 AM 0
Share

Correct. But as his question was oriented towards if Unity provides it, that's what I focused on.

avatar image qJake · Jun 05, 2010 at 09:45 PM 0
Share

Unfortunately for a lot of these types of questions you have to "guess" at what they really want to hear, even if they don't tell it to you. It's one of the caveats of Stack Overflow sites. :P

avatar image Ricardo · Jun 06, 2010 at 10:21 AM 1
Share

Oh, I could guess. :-) I also think that users should be digging into things a bit more themselves, and see it as an antidote for the "everything prepackaged for all possible options" mentality we've been seeing so much of.

avatar image Tethys · Feb 21, 2013 at 03:51 PM 0
Share

At Ricardo - That is Unitys strongest $$anonymous$$arketing point that they try to illustrate in their marketing materials. One shouldn't be surprised to see so many people expecting it. I didn't have to guess at what he wanted either. Taking your guys own advise, if one just thought about the question for a moment I am sure one would figure out what the gentleman was asking. I knew right away, but it was because I was looking for the same thing. ;)

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

1 Person is following this question.

avatar image

Related Questions

interacting with a raycast 1 Answer

How can I use multiple GetButtonDown keys simultaneously? 2 Answers

Hold down button for in trigger 1 Answer

how to make a highlight gui ?? 1 Answer

Check for any input 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