예제 #1
0
 public virtual void MakeSelected()
 {
     if (!GameGlobals.PropertiesPanelOpen)
     {
         GameGlobals.SetPropertiesOpen(true);
     }
 }
예제 #2
0
    /// <summary>
    /// Update location marker state.
    /// </summary>
    private void _UpdateLocationMarker()
    {
        if (Input.touchCount == 2)
        {
            return;
        }

        if (Input.touchCount == 1 || Input.GetMouseButtonDown(1))
        {
            // Single tap -- place new location or select existing location.

            Vector2 pos = new Vector2();
            if (Input.touchCount == 1)
            {
                Touch t = Input.GetTouch(0);
                pos = t.position;
                if (t.phase != TouchPhase.Began ||
                    UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject(t.fingerId))
                {
                    return;
                }
            }
            else
            {
                if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }
                pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            }

            if (GameGlobals.PropertiesPanelOpen)
            {
                GameGlobals.SetPropertiesOpen(false);
                return;
            }

            Vector2    guiPosition = new Vector2(pos.x, Screen.height - pos.y);
            Camera     cam         = Camera.main;
            RaycastHit hitInfo;

            if (m_selectedRect.Contains(guiPosition) || m_hideAllRect.Contains(guiPosition))
            {
                // do nothing, the button will handle it
            }
            else if (Physics.Raycast(cam.ScreenPointToRay(pos), out hitInfo, 10, 1 << _PrefabObjLayer))
            {
                // Found a prefab, select it (so long as it isn't disappearing)!
                GameObject tapped = hitInfo.collider.transform.root.gameObject;
                //Debug.Log(tapped.name + " tapped!");
                m_selectedPrefab = tapped.GetComponent <ARSelectable>();
                m_selectedPrefab.MakeSelected();

                //if (!tapped.GetComponent<Animation>().isPlaying)
                //{
                //    m_selectedPrefab = tapped.GetComponent<PrefabObject>();
                //}
            }
            else
            {
                // Place a new point at that location, clear selection
                m_selectedPrefab = null;
                GameGlobals.ChangeSelected(Enums.SelectionType.NONE);

                StartCoroutine(_WaitForDepthAndFindPlane(pos));

                // Because we may wait a small amount of time, this is a good place to play a small
                // animation so the user knows that their input was received.
                RectTransform touchEffectRectTransform = (RectTransform)Instantiate(m_prefabTouchEffect);
                touchEffectRectTransform.transform.SetParent(m_canvas.transform, false);
                Vector2 normalizedPosition = pos;
                normalizedPosition.x /= Screen.width;
                normalizedPosition.y /= Screen.height;
                touchEffectRectTransform.anchorMin = touchEffectRectTransform.anchorMax = normalizedPosition;
            }
        }
    }
예제 #3
0
 private void onSunClick()
 {
     GameGlobals.ChangeSelected(Enums.SelectionType.DIRECTIONAL_LIGHT);
     GameGlobals.SetPropertiesOpen(true);
     ARDirectionalLight._Sun.MakeSelected();
 }