Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 RahulOfTheRamanEffect · Mar 26, 2018 at 12:16 PM · uiinputeventsystemmultitouch

Prevent multiple UI elements receiving input from different pointers?

Hey there!

I've recently realized that independent Unity UI components can receive simultaneous inputs from different pointers.

- Eg: 2 separate ScrollRects can be scrolled simultaneously by 1 finger each (on touchscreens).

This can lead to some very undesirable behavior in the application that I'm currently building.

Is there a way to ensure only 1 element can be, at any given time, deemed as the target for input events in the Unity UI system?

- i.e., if the user has got a finger down on a ScrollRect, make sure only that ScrollRect receives all inputs until it is "released" by the user?

My app utilizes multitouch gestures such as pinch, so setting Input.multiTouchEnabled = false is not a feasible workaround to this problem.

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
Best Answer

Answer by RahulOfTheRamanEffect · Mar 27, 2018 at 08:17 PM

Answering my own question here:

I went through the code for the Standalone Input Module (thank you, Unity, for making it open source) and found out that it would not restrict the receiver of multiple simultaneous executions for touches. So I wrote up my own custom Standalone Input Module that would allow you to choose whether or not you would like to allow multiple simultaneous receivers.

I've attached the code here, if anyone would like to use it in their projects.

How to use:
Just replace the current Standalone Input Module on your EventSystem GameObject with this script.

customStandaloneInputModule
You can set "allowMultipleSimultaneousReceivers" to true, if you want the default behaviour (multiple objects can be activated by multiple touches), or to false, if you want only one object to receive all inputs at any given time.

Cheers! :)


customstandaloneinputmodule.png (31.4 kB)
customstandaloneinputmodule.zip (4.1 kB)
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
avatar image
0

Answer by simona_exient · Feb 11 at 02:07 PM

Note that you may hit situations where 'totalTouchPointerCount' (in your provided .cs example) will become invalid - e.g. on newer iPhones after resuming the app. So you may also want something like:

 private void OnApplicationFocus(bool hasFocus)
 {
   if (hasFocus)
   {
     totalTouchPointerCount = 0;
     m_CurrentTouchFocusedGameObject = null;
   }
 }
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

139 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 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 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 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 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 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 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 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

Can I change the input "submit" and "cancel" button of an eventsystem from a script? 0 Answers

EventSystem not detecting all UI elements 1 Answer

How do I detect when UI events are triggered on *any object*? 1 Answer

How to solve event triggers blocking scrollview inputs in an inventory/menu? 2 Answers

TextMeshPro Dropdown navigation gamepad problem 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