diff --git a/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Board.prefab b/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Board.prefab index 6fee757..40eae04 100644 Binary files a/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Board.prefab and b/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Board.prefab differ diff --git a/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Plane.prefab b/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Plane.prefab index d89b17e..fc0b476 100644 Binary files a/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Plane.prefab and b/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Plane.prefab differ diff --git a/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Unity Plane.prefab b/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Unity Plane.prefab index 5721fbf..7edf16c 100644 Binary files a/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Unity Plane.prefab and b/Assets/uDesktopDuplication/Examples/Prefabs/Monitor Unity Plane.prefab differ diff --git a/Assets/uDesktopDuplication/Examples/Scenes/Meta Data.unity b/Assets/uDesktopDuplication/Examples/Scenes/Meta Data.unity index 986584f..dea210a 100644 Binary files a/Assets/uDesktopDuplication/Examples/Scenes/Meta Data.unity and b/Assets/uDesktopDuplication/Examples/Scenes/Meta Data.unity differ diff --git a/Assets/uDesktopDuplication/Examples/Scenes/Shaders.unity b/Assets/uDesktopDuplication/Examples/Scenes/Shaders.unity index d76cc0d..e334ac8 100644 Binary files a/Assets/uDesktopDuplication/Examples/Scenes/Shaders.unity and b/Assets/uDesktopDuplication/Examples/Scenes/Shaders.unity differ diff --git a/Assets/uDesktopDuplication/Examples/Scenes/Toggle Monitors.unity b/Assets/uDesktopDuplication/Examples/Scenes/Toggle Monitors.unity index 00ca42c..8064600 100644 Binary files a/Assets/uDesktopDuplication/Examples/Scenes/Toggle Monitors.unity and b/Assets/uDesktopDuplication/Examples/Scenes/Toggle Monitors.unity differ diff --git a/Assets/uDesktopDuplication/Examples/Scenes/Zoom.unity b/Assets/uDesktopDuplication/Examples/Scenes/Zoom.unity index 6c55ada..58d5dda 100644 Binary files a/Assets/uDesktopDuplication/Examples/Scenes/Zoom.unity and b/Assets/uDesktopDuplication/Examples/Scenes/Zoom.unity differ diff --git a/Assets/uDesktopDuplication/Examples/Scripts/GazePointAnalyzer.cs b/Assets/uDesktopDuplication/Examples/Scripts/GazePointAnalyzer.cs index 1f632fe..397a1f7 100644 --- a/Assets/uDesktopDuplication/Examples/Scripts/GazePointAnalyzer.cs +++ b/Assets/uDesktopDuplication/Examples/Scripts/GazePointAnalyzer.cs @@ -15,6 +15,11 @@ public class GazePointAnalyzer : MonoBehaviour { get { return GetWorldPositionFromCoord((int)averageCoord_.x, (int)averageCoord_.y); } } + + public Vector3 cursorPos + { + get { return GetWorldPositionFromCoord(uddTexture_.monitor.cursorX, uddTexture_.monitor.cursorY); } + } private Vector2 preCursorCoord_ = Vector2.zero; [Header("Filters")] @@ -26,6 +31,7 @@ public class GazePointAnalyzer : MonoBehaviour [Header("Debug")] public bool drawAveragePos; + public bool drawCursorPos; public bool drawMoveRects; public bool drawDirtyRects; @@ -142,6 +148,7 @@ public class GazePointAnalyzer : MonoBehaviour void DebugDraw() { if (drawAveragePos) DrawAveragePos(); + if (drawCursorPos) DrawCursorPos(); if (drawDirtyRects) DrawDirtyRects(); if (drawMoveRects) DrawMoveRects(); } @@ -164,6 +171,11 @@ public class GazePointAnalyzer : MonoBehaviour Debug.DrawLine(transform.position, averagePos, Color.yellow); } + void DrawCursorPos() + { + Debug.DrawLine(transform.position, cursorPos, Color.grey); + } + void DrawMoveRects() { foreach (var rect in uddTexture_.monitor.moveRects) { diff --git a/Assets/uDesktopDuplication/Examples/Scripts/Loupe.cs b/Assets/uDesktopDuplication/Examples/Scripts/Loupe.cs index 541b074..933deaa 100644 --- a/Assets/uDesktopDuplication/Examples/Scripts/Loupe.cs +++ b/Assets/uDesktopDuplication/Examples/Scripts/Loupe.cs @@ -1,18 +1,15 @@ using UnityEngine; -[RequireComponent(typeof(uDesktopDuplication.Texture)), - RequireComponent(typeof(uDesktopDuplication.Cursor))] +[RequireComponent(typeof(uDesktopDuplication.Texture))] public class Loupe : MonoBehaviour { private uDesktopDuplication.Texture uddTexture_; - private uDesktopDuplication.Cursor uddCursor_; public float zoom = 3f; public float aspect = 1f; void Start() { uddTexture_ = GetComponent(); - uddCursor_ = GetComponent(); uddTexture_.useClip = true; } @@ -31,10 +28,10 @@ public class Loupe : MonoBehaviour var monitor = uddTexture_.monitor; var x = monitor.isCursorVisible ? - uddCursor_.coord.x : + (float)monitor.cursorX / monitor.width : (float)monitor.systemCursorX / monitor.width; var y = monitor.isCursorVisible ? - uddCursor_.coord.y : + (float)monitor.cursorY / monitor.height : (float)monitor.systemCursorY / monitor.height; var w = 1f / zoom; var h = w / aspect * monitor.aspect; diff --git a/Assets/uDesktopDuplication/Scripts/Cursor.cs b/Assets/uDesktopDuplication/Scripts/Cursor.cs deleted file mode 100644 index 60e636b..0000000 --- a/Assets/uDesktopDuplication/Scripts/Cursor.cs +++ /dev/null @@ -1,47 +0,0 @@ -using UnityEngine; - -namespace uDesktopDuplication -{ - -[AddComponentMenu("uDesktopDuplication/Cursor"), RequireComponent(typeof(Texture))] -public class Cursor : MonoBehaviour -{ - [SerializeField] Vector2 modelScale = Vector2.one; - - public Vector3 worldPosition { get; set; } - public Vector2 coord { get; set; } - - private Texture uddTexture_; - private Monitor monitor { get { return uddTexture_.monitor; } } - - void Start() - { - uddTexture_ = GetComponent(); - } - - void Update() - { - if (monitor.isCursorVisible) { - UpdatePosition(); - } - UpdateCoords(); - } - - void UpdatePosition() - { - var x = (1f * monitor.cursorX / monitor.width - 0.5f) * modelScale.x; - var y = (1f * monitor.cursorY / monitor.height - 0.5f) * modelScale.y; - var iy = uddTexture_.invertY ? -1 : +1; - var localPos = transform.right * x + iy * transform.up * y; - worldPosition = transform.TransformPoint(localPos); - } - - void UpdateCoords() - { - var x = monitor.isCursorVisible ? (float)monitor.cursorX / monitor.width : -9999f; - var y = monitor.isCursorVisible ? (float)monitor.cursorY / monitor.height : -9999f; - coord = new Vector2(x, y); - } -} - -} \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Scripts/Cursor.cs.meta b/Assets/uDesktopDuplication/Scripts/Cursor.cs.meta deleted file mode 100644 index a343690..0000000 --- a/Assets/uDesktopDuplication/Scripts/Cursor.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d2d9e4ca459ecb44da8815bafe9655c5 -timeCreated: 1477635630 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 89616e59e1cccb346bd4e959257990ca, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/uDesktopDuplication/Scripts/Texture.cs b/Assets/uDesktopDuplication/Scripts/Texture.cs index b5ea645..e4057f2 100644 --- a/Assets/uDesktopDuplication/Scripts/Texture.cs +++ b/Assets/uDesktopDuplication/Scripts/Texture.cs @@ -3,7 +3,7 @@ namespace uDesktopDuplication { -[AddComponentMenu("uDesktopDuplication/Texture"), RequireComponent(typeof(Cursor))] +[AddComponentMenu("uDesktopDuplication/Texture")] public class Texture : MonoBehaviour { private Monitor monitor_; @@ -109,11 +109,6 @@ public class Texture : MonoBehaviour private set; } - void Awake() - { - AddCursorIfNotAttached(); - } - void OnEnable() { if (monitor == null) { @@ -143,14 +138,6 @@ public class Texture : MonoBehaviour } } - void AddCursorIfNotAttached() - { - if (!GetComponent()) - { - gameObject.AddComponent(); - } - } - void Reinitialize() { // Monitor instance is released here when initialized. diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader index f2f7751..848f72d 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader @@ -5,7 +5,6 @@ Properties { _Color ("Color", Color) = (1, 1, 1, 1) _MainTex ("Texture", 2D) = "white" {} - _CursorTex ("Cursor Texture", 2D) = "white" {} [KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0 [Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0 [PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30 diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader index 069e16a..608aab3 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader @@ -6,7 +6,6 @@ Properties _Color ("Color", Color) = (1, 1, 1, 1) _MainTex ("Texture", 2D) = "white" {} _Mask ("Mask", Range(0, 1)) = 0.1 - _CursorTex ("Cursor Texture", 2D) = "white" {} [KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0 [Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0 [PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30 diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Displacement.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Displacement.shader index d73ab95..3f67fcb 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Displacement.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Displacement.shader @@ -5,7 +5,6 @@ Properties { _Color ("Color", Color) = (1, 1, 1, 1) _MainTex ("Texture", 2D) = "white" {} - _CursorTex ("Cursor Texture", 2D) = "white" {} [KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0 [Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0 [PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30 diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader index 11a8449..3d7ef63 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader @@ -5,7 +5,6 @@ Properties { _Color ("Color", Color) = (1, 1, 1, 1) _MainTex ("Texture", 2D) = "white" {} - _CursorTex ("Cursor Texture", 2D) = "white" {} [KeywordEnum(Y, Z)] _Forward("Mesh Forward Direction", Int) = 0 [Toggle(BEND_ON)] _Bend("Use Bend", Int) = 0 [PowerSlider(10.0)] _Radius("Bend Radius", Range(1, 100)) = 30