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 MaT227 · Sep 18, 2013 at 08:18 AM · guiinputupdateevent

Input versus Event

Hi,

I am wondering what's the core difference between Input and Event.

In which case should I use Input or Event ? What are their advantage or failing ?

I know that this could lead to a wide discussion but I need some clarifications because I can't find in the documentation any good explanation.

Thanks a lot.

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 Fattie · Sep 18, 2013 at 09:14 AM 2
Share

There's a lot to be said for "just don't use Event." But then there's a lot to be said for "Just don't use GUI."

avatar image syclamoth · Sep 18, 2013 at 09:15 AM 0
Share

Agreed. UnityGUI is pretty stinky.

1 Reply

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

Answer by syclamoth · Sep 18, 2013 at 08:23 AM

Brodaly, 'Event' is used for GUI scripting, and 'Input' is used for game-world controller handling. There is no real discussion about where to use one or the other- they are generally used for fundamentally different things and while there is some overlap in functionality, it rarely comes up in practice.

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 MaT227 · Sep 18, 2013 at 08:28 AM 0
Share

Can you give me some examples of using Event in a GUI scripting context ?

avatar image syclamoth · Sep 18, 2013 at 08:47 AM 2
Share

I initially thought this stuff was well documented in the online scripting reference, but upon closer inspection it seems that either I was wrong, or that the documentation has gotten worse since I last looked it up. In any case, a simple example would be using Event.current.mousePosition inside of OnGUI in order to find the GUI-space position of the cursor for that event (as opposed to Input.mousePosition, which uses screen coordinates).

The main difference you must keep in $$anonymous$$d, is that the Input class is essentially a set of static functions for querying the state of controller input for a given frame, and the Event class is used in GUI code to deter$$anonymous$$e what to do in a given pass.

Events are created one at a time, and each event is passed into OnGUI exactly once- you must check Event.current.type to find out exactly what kind of event it is before using it.

avatar image Fattie · Sep 18, 2013 at 09:14 AM 0
Share

An excellent answer.

avatar image Bunny83 · Sep 18, 2013 at 09:22 AM 3
Share

Here's my GUI crash course

avatar image MaT227 · Sep 18, 2013 at 09:26 AM 0
Share

Thanks for your answer @syclamoth.

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why am I losing some inputs on Update function? 0 Answers

Emulate RightArrow GUI Event 0 Answers

How do you get Unity to return a user input? 1 Answer

Update - Delaying until next frame? 0 Answers

TextField not clear after focusing it through a Key 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