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 Bezzy · Sep 25, 2012 at 02:05 PM · inputmousetouchonguicrossplatform

"Phantom" mouse cursor/touch on iOS but not Android?

Hi!

I'm having trouble with the iOS port of our game - we're making it for iOS, Android and also Web. We started off with Web, and I tried to make sure we were dealing with inputs responsibly: I'm dealing with inputs in the OnGUI scope (as this means we won't "skip" any clicks if the frame rate drops suddenly), looking at Event.current to deal with mouse button clicks one at a time.

We also deal with touch controls in this scope, and this mostly works fine on Android (multi touch works fine). Within our in internal GUI system we generate more "generic" click events based on either touches or mouse buttons (pressed down or released), so that touches and mouse button clicks are abstracted into the same format and (mostly) dealt with generically.

However, on iOS, touches in the OnGUI scope seem to only respond to the FIRST touch. Multiple touches seem to "average out" the position of the touch, rather than being proper touches. Buttons we've created register as "hovered over" even when the touch is released (and our code explicitly performs a "hover off" on "release" if it's on the mobile platforms).

(Still on iOS) When we move the touch generation code into Update() instead of OnGUI(), we DO get multi-touch response, but the On GUI aspect still filters through (I'm going to try TOTALLY turning off touch generation from OnGUI in iOS, next).

So in general, it seems like if you're using OnGUI on iOS, you're getting a "fake" mouse cursor which takes the average position of all touches, and the cursor is "left behind" in the last known position, but you can't actually get access to the true touches anywhere other than the Update() loop. And this is not the case on Android!

So I guess my question is: What is going on with the fake mouse use in OnGUI? What's the rationale? If it's meant to be an ease of use thing, why does it only occur on iOS and not android?

And most importantly, how can I turn off this "fake" mouse cursor?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bezzy · Sep 25, 2012 at 02:20 PM

Ooh,

According to everyone's favourite unity forum curmudgeon, OnGUI is implicitly not for multitouch. I shall just shift my input code into Update for mobile stuff, and have to live with the lost touches. sigh. [Edit] Yep. that worked! Luckily our frame rate is pretty high so we're not missing much. Ideally, I guess you wanna cache touches yourself incase TouchPhase.Began gets skipped? Kinda generate your own version of begin/end touch based on whether the touches are active this frame vs. last?

Weird that getting touches from OnGUI DOES work on android, though?

Comment
Add comment · 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

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

9 People are following this question.

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

Related Questions

Switch Between Touch And Mouse Controls 0 Answers

Convert Touch input to Mouse input C#? 1 Answer

Simulate touch with mouse 6 Answers

Can I fake the mouse/touch position relative to the real mouse/touch position? 0 Answers

Handle Mouse/Touch pan, zoom and click 0 Answers


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