Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Zytronic_Touch · Jul 26, 2017 at 07:04 AM · multitouchmultiple-monitors

Issue with Multi Touch Screens.

I am currently working on a project which is using three touch sensors with two displays. I am having an issue with mapping the touches to the correct display.

This diagram shows the desired mapping:alt text

So to do this I am using this:

 void Update () {
         Debug.Log(Input.touchCount);
         for (int i = 0; i < Input.touches.Length; i++)
         {
             Touch touch = Input.GetTouch(i);
             if (touch.phase == TouchPhase.Began)
             {
                 Ray ray = Camera.main.ScreenPointToRay(touch.position);
                 Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow);
             }
         }
     }

The issue is that every touch to any sensor is showing on Display1. I believe this is down to: Camera.main.ScreenPointToRay(touch.position);

But I cant find a way to detect which screen is being touched to use the correct camera. Is there a way around this issue?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Naethyn · Jan 18, 2018 at 11:02 PM

Did you figure this out?

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 Zytronic_Touch · Jan 19, 2018 at 12:10 PM

This works for the unity editor, it needs to be changed to work with the player for whatever OS you are using. It returns a Vector3 where the z index is the displayID.

 public static Vector3 DebugRelativeMouseAt()
     {
         var mouseOverWindow = EditorWindow.mouseOverWindow;
         System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
         Type type = assembly.GetType("UnityEditor.GameView");
 
         int displayID = 0;
         if (type.IsInstanceOfType(mouseOverWindow))
         {
             var displayField = type.GetField("m_TargetDisplay", BindingFlags.NonPublic | BindingFlags.Instance);
             displayID = (int)displayField.GetValue(mouseOverWindow);
         }
 
         var pos = Input.mousePosition;
         pos[2] = displayID;
         return pos;
     }
 

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 hantouan · Jan 26, 2018 at 11:42 AM

I have a similar issue with my app. I m using 4 different cameras to display on 4 touchscreens. On each touchscreen i have a canvas and I need to use touch event to pan/zoom the content on each canvas. However I always get the touch on every single canvas, and only on the actual canvas touched.

I haven't found any solution yet.,

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 joshstiemsma · Sep 13, 2018 at 03:24 PM

wow im in the same exact boat! two touch monitors and it seams like i can hit buttons on the canvas of the second screen but my touch.position is always on the first screen

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

70 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

Related Questions

Multi-Display - Multi Touch Screen Issues 0 Answers

Two view and Two function for the Mouse Cursor 1 Answer

how to Screen.SetResolution() for 2nd monitor/multiple monitor 0 Answers

Android multiple display 0 Answers

Windows 7 Multitouch limits 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