Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            var position = Input.mousePosition;

            position.z = Distance;

            var worldPosition = Camera.main.ScreenToWorldPoint(position);

            if (Input.GetButtonDown(TriggerName))
            {
                var rotation = Camera.main.transform.rotation;
                if (AlignToViewsphere)
                {
                    Debug.LogWarning(gameObject.name + " - PieMenu_MouseControl::Update(): AlignToViewsphere Not Implemented.");
                }

                Menu.Show(worldPosition, Camera.main.transform.forward);
            }

            if (Input.GetButtonUp(TriggerName))
            {
                Menu.Hide();
            }

            if (Menu.Visible)
            {
                Menu.UpdateCursor(worldPosition);
            }
        }
Ejemplo n.º 2
0
        // Update is called once per frame
        void Update()
        {
            if (Menu.Visible)
            {
                // Find position and direction in local space
                var position  = Menu.transform.InverseTransformPoint(TrackedController.transform.position);
                var direction = Menu.transform.InverseTransformVector(TrackedController.transform.forward);

                // Find 'elevation' of position over interaction plane, then find how many multiples of direction to zero it.
                var steps = Mathf.Abs(position.z / direction.z);


                // Find ray intersect
                var intersect = Vector3.ProjectOnPlane(position, Vector3.forward) + Vector3.ProjectOnPlane(direction * steps, Vector3.forward);


                Menu.UpdateCursor(Menu.transform.TransformPoint(intersect));
            }
        }