Example #1
0
 public static void AddPoint(NxrUIPointer point)
 {
     if (!pointers.Contains(point))
     {
         pointers.Add(point);
     }
 }
Example #2
0
 public static void RemovePoint(NxrUIPointer point)
 {
     if (pointers.Contains(point))
     {
         pointers.Remove(point);
     }
 }
Example #3
0
 private void Awake()
 {
     mNxrUIPointer = GetComponent <NxrUIPointer>();
     if (mNxrUIPointer == null)
     {
         mNxrUIPointer = gameObject.AddComponent <NxrUIPointer>();
     }
 }
Example #4
0
        private void CastRayFromGamepad()
        {
            if (pointerData == null)
            {
                pointerData = new PointerEventData(eventSystem);
            }

            // Cast a ray into the scene
            pointerData.Reset();
            bool IsUICanvasObject = NxrControllerHelper.ControllerRaycastObject != null &&
                                    NxrControllerHelper.ControllerRaycastObject.GetComponent <NxrUICanvas>() != null;

            if (IsUICanvasObject)
            {
                for (int i = 0; i < pointers.Count; i++)
                {
                    NxrUIPointer pointer = pointers[i];
                    if (pointer.gameObject.activeInHierarchy && pointer.enabled && pointer.IsShow())
                    {
                        var raycastResult = new RaycastResult();
                        raycastResult.worldPosition       = pointer.transform.position;
                        raycastResult.worldNormal         = pointer.transform.forward;
                        pointerData.position              = new Vector2(0.5f * Screen.width, 0.5f * Screen.height);
                        pointerData.pointerCurrentRaycast = raycastResult;
                        eventSystem.RaycastAll(pointerData, m_RaycastResultCache);
                        pointerData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
                        if (m_RaycastResultCache.Count > 0)
                        {
                            HandlePointerExitAndEnter(pointerData, pointerData.pointerCurrentRaycast.gameObject);
                        }
                        else
                        {
                            HandlePointerExitAndEnter(pointerData, null);
                        }

                        m_RaycastResultCache.Clear();
                    }
                }
            }
            else
            {
                pointerData.pointerPress = NxrControllerHelper.ControllerRaycastObject;
                RaycastResult raycastResult = new RaycastResult();
                raycastResult.gameObject          = NxrControllerHelper.ControllerRaycastObject;
                pointerData.pointerCurrentRaycast = raycastResult;
                HandlePointerExitAndEnter(pointerData, NxrControllerHelper.ControllerRaycastObject);
            }

            if (pointerData.pointerCurrentRaycast.gameObject == null && eventSystem.currentSelectedGameObject != null)
            {
                Debug.LogError("Clear Seleted GameObject-Controller=>" + eventSystem.currentSelectedGameObject.name);
                eventSystem.SetSelectedGameObject(null);
            }
        }