Exemplo n.º 1
0
 // get the click event and remove the panel from view
 public void OnPointerClick(PointerEventData eventData)
 {
     PanelControl.RemovePanel();
     PanelControl.active = false;
 }
Exemplo n.º 2
0
        /// <summary>
        /// move camera with keyboard or with screen edge
        /// </summary>
        private void Move()
        {
            // if user attemps a camera movement, close the panel
            if (Input.GetKey(zoomInKey) || Input.GetKey(zoomOutKey) || Input.GetKey(panningKey) ||
                Input.GetKey(rotateLeftKey) || Input.GetKey(rotateRightKey) || Input.GetKey(mouseRotationKey) ||
                System.Math.Abs(Input.GetAxis(horizontalAxis)) > 0 ||
                System.Math.Abs(Input.GetAxis(verticalAxis)) > 0 ||
                System.Math.Abs(Input.GetAxis(zoomingAxis)) > 0)
            {
                PanelControl.RemovePanel();
            }

            if (useKeyboardInput)
            {
                Vector3 desiredMove = new Vector3(KeyboardInput.x, 0, KeyboardInput.y);

                desiredMove *= keyboardMovementSpeed;
                desiredMove *= Time.deltaTime;
                desiredMove  = Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, 0f)) * desiredMove;
                desiredMove  = m_Transform.InverseTransformDirection(desiredMove);

                m_Transform.Translate(desiredMove, Space.Self);
            }

            if (useScreenEdgeInput)
            {
                Vector3 desiredMove = new Vector3();

                Rect leftRect  = new Rect(0, 0, screenEdgeBorder, Screen.height);
                Rect rightRect = new Rect(Screen.width - screenEdgeBorder, 0, screenEdgeBorder, Screen.height);
                Rect upRect    = new Rect(0, Screen.height - screenEdgeBorder, Screen.width, screenEdgeBorder);
                Rect downRect  = new Rect(0, 0, Screen.width, screenEdgeBorder);

                desiredMove.x = leftRect.Contains(MouseInput) ? -1 : rightRect.Contains(MouseInput) ? 1 : 0;
                desiredMove.z = upRect.Contains(MouseInput) ? 1 : downRect.Contains(MouseInput) ? -1 : 0;


                if (leftRect.Contains(MouseInput) || rightRect.Contains(MouseInput) ||
                    upRect.Contains(MouseInput) || downRect.Contains(MouseInput))
                {
                    PanelControl.RemovePanel();
                }

                desiredMove *= screenEdgeMovementSpeed;
                desiredMove *= Time.deltaTime;
                desiredMove  = Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, 0f)) * desiredMove;
                desiredMove  = m_Transform.InverseTransformDirection(desiredMove);

                m_Transform.Translate(desiredMove, Space.Self);
            }

            if (usePanning && Input.GetKey(panningKey) && MouseAxis != Vector2.zero)
            {
                Vector3 desiredMove = new Vector3(-MouseAxis.x, 0, -MouseAxis.y);

                desiredMove *= panningSpeed;
                desiredMove *= Time.deltaTime;
                desiredMove  = Quaternion.Euler(new Vector3(0f, transform.eulerAngles.y, 0f)) * desiredMove;
                desiredMove  = m_Transform.InverseTransformDirection(desiredMove);

                m_Transform.Translate(desiredMove, Space.Self);
            }
        }