Exemplo n.º 1
0
    private void Awake()
    {
        selfDropDown = this.GetComponent <Dropdown>();
        Template     = selfDropDown.GetComponentInChildren <ScrollRect>(true).gameObject;

        ViveInput.AddPressUp(HandRole.RightHand, ControllerButton.Trigger, EmptyClick);
        UIEvent.Get(this.gameObject, ButtonKey.Left).OnHover += (go, bHover) =>
        {
            if (bHover == false)
            {
                return;
            }

            if (Template.GetComponent <CanvasRaycastTarget>() == null)
            {
                Template.gameObject.AddComponent <CanvasRaycastTarget>();
            }
            ;
        };
        for (int i = 0; i < selfDropDown.GetComponentsInChildren <Toggle>().Length; i++)
        {
            int      j          = i;
            Toggle[] allToggles = selfDropDown.GetComponentsInChildren <Toggle>();
            UIEvent.Get(allToggles[j].gameObject, ButtonKey.Left).onClick_ += (go, eventData) =>
            {
                if (PlateformData.GetCurrentPlatform() == PlatformType.zSpace)
                {
                    selfDropDown.OnSelect(eventData);
                }
            };
        }
    }
Exemplo n.º 2
0
 public void OnSceneLoaded()
 {
     ViveInput.AddPressDown(HandRole.RightHand, triggerButton, RightDownHandler);
     ViveInput.AddPressDown(HandRole.LeftHand, triggerButton, LeftDownHandler);
     ViveInput.AddPressUp(HandRole.RightHand, triggerButton, RightUpHandler);
     ViveInput.AddPressUp(HandRole.LeftHand, triggerButton, LeftUpHandler);
 }
Exemplo n.º 3
0
    void AddListener()
    {
        //监听右手 右键
        ViveInput.AddPress(HandRole.RightHand, ControllerButton.Pad, onRightRightPress);
        ViveInput.AddPressDown(HandRole.RightHand, ControllerButton.Pad, onRightRightPressDown);
        ViveInput.AddPressUp(HandRole.RightHand, ControllerButton.Pad, onRightRightPressUp);
        //监听右手 左键持续按下
        ViveInput.AddPress(HandRole.RightHand, ControllerButton.Trigger, OnRightLeftPress);
        ViveInput.AddPressDown(HandRole.RightHand, ControllerButton.Trigger, OnRightLeftPressDown);
        ViveInput.AddPressUp(HandRole.RightHand, ControllerButton.Trigger, OnRightLeftPressUp);

        ViveInput.AddPressDown(HandRole.RightHand, ControllerButton.Grip, OnLeftRest);
    }
Exemplo n.º 4
0
        void Init()
        {
            ViveInput.AddPressUp(HandRole.RightHand, ControllerButton.Pad, () => {
                float x = ViveInput.GetAxis(HandRole.RightHand, ControllerAxis.PadX);
                float y = ViveInput.GetAxis(HandRole.RightHand, ControllerAxis.PadY);

                float angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg;

                if (Mathf.Abs(angle) < 45f)
                {
                    //right
                    //+ inner
                    Ratio      += m_ratioDeltaAmount;
                    InnerRadius = OuterRadius * Ratio;
                }
                else if (Mathf.Abs(angle) > 135f)
                {
                    //left
                    //- inner
                    Ratio      -= m_ratioDeltaAmount;
                    InnerRadius = OuterRadius * Ratio;
                }
                else if (angle > 45f && angle < 135f)
                {
                    //up
                    //+ outer
                    OuterRadius += m_radiusDeltaAmount;
                    InnerRadius  = OuterRadius * Ratio;
                }
                else if (angle > -135f && angle < -45f)
                {
                    //down
                    //- outer
                    OuterRadius -= m_radiusDeltaAmount;
                    InnerRadius  = OuterRadius * Ratio;
                }
                HapticManager.Instance.TriggerHaptic(HandRole.RightHand, 1000);
            });

            ViveInput.AddPressUp(HandRole.LeftHand, ControllerButton.Pad, () => {
                float x = ViveInput.GetAxis(HandRole.LeftHand, ControllerAxis.PadX);
                float y = ViveInput.GetAxis(HandRole.LeftHand, ControllerAxis.PadY);

                float angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg;

                if (Mathf.Abs(angle) < 45f)
                {
                    //right
                    PerformRedo();
                }
                else if (Mathf.Abs(angle) > 135f)
                {
                    //left
                    //undo
                    PerformUndo();
                }
                else if (angle > 45f && angle < 135f)
                {
                    //up
                    //MeshGenerator.Instance.CreateMesh();
                }
                else if (angle > -135f && angle < -45f)
                {
                    //down
                    //MeshIOManager.Instance.ExportMesh();
                }
                HapticManager.Instance.TriggerHaptic(HandRole.LeftHand, 1000);
            });

            ViveInput.AddPressUp(HandRole.RightHand, ControllerButton.Menu, () => {
                //ToolState = (DeformTools.ToolState)(((int)ToolState + 1) % 5);
            });
        }