Created
September 16, 2020 10:32
-
-
Save karljj1/6f351907bada39bf9bed193c7cdba10f to your computer and use it in GitHub Desktop.
Emulate multiple display input using GameViews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector3 RelativeMouseAt() | |
{ | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment