Skip to content

Instantly share code, notes, and snippets.

@gfodor
Created August 11, 2014 22:23
Show Gist options
  • Save gfodor/a1d7beffb2a7c09d5a4f to your computer and use it in GitHub Desktop.
Save gfodor/a1d7beffb2a7c09d5a4f to your computer and use it in GitHub Desktop.
diff --git a/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Game/ObjectPicker.cs b/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Game/ObjectPicker.cs
index e33b55a..8dda361 100755
--- a/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Game/ObjectPicker.cs
+++ b/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Game/ObjectPicker.cs
@@ -1,6 +1,7 @@
#if UNITY_STANDALONE || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
#define COHERENT_UNITY_STANDALONE
#endif
+using System;
using UnityEngine;
using System.Collections;
@@ -17,7 +18,9 @@ public class ObjectPicker : MonoBehaviour {
}
// Update is called once per frame
- void Update () {
+ void Update ()
+ {
+ Screen.lockCursor = true;
if (m_UISystem.HasFocusedView)
{
return;
@@ -67,8 +70,9 @@ public class ObjectPicker : MonoBehaviour {
// Activate input processing for the view below the mouse cursor
- RaycastHit hitInfo;
- if (Physics.Raycast(m_MainCamera.ScreenPointToRay(Input.mousePosition), out hitInfo))
+ RaycastHit hitInfo;
+
+ if (Physics.Raycast(m_MainCamera.ViewportPointToRay(new Vector2(0.5f, 0.5f)), out hitInfo))
{
//Debug.Log (hitInfo.collider.name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment