private void ActionChanged(SteamVR_Action_In action)
 {
     if (onChange != null)
     {
         onChange.Invoke((SteamVR_Action_Vector3)action);
     }
 }
Exemple #2
0
        /// <summary>
        /// Updates the states of all the non visual actions (boolean, single, vector2, vector3) for a given input source (left hand / right hand / any)
        /// </summary>
        /// <param name="inputSource"></param>
        public static void UpdateNonVisualActions(SteamVR_Input_Sources inputSource)
        {
            if (initialized == false)
            {
                return;
            }

            for (int actionSetIndex = 0; actionSetIndex < actionSets.Length; actionSetIndex++)
            {
                SteamVR_ActionSet set = actionSets[actionSetIndex];

                if (set.IsActive())
                {
                    for (int actionIndex = 0; actionIndex < set.nonVisualInActions.Length; actionIndex++)
                    {
                        SteamVR_Action_In actionIn = set.nonVisualInActions[actionIndex] as SteamVR_Action_In;

                        if (actionIn != null)
                        {
                            actionIn.UpdateValue(inputSource);
                        }
                    }
                }
            }
        }
        protected virtual void ActionUpdated(SteamVR_Action_In action)
        {
            SteamVR_Action_Boolean booleanAction = (SteamVR_Action_Boolean)action;

            if (onChange != null && booleanAction.GetChanged(inputSource))
            {
                onChange.Invoke(booleanAction);
            }

            if (onPressDown != null && booleanAction.GetStateDown(inputSource))
            {
                onPressDown.Invoke(booleanAction);
            }

            if (onPress != null && booleanAction.GetState(inputSource))
            {
                onPress.Invoke(booleanAction);
            }

            if (onPressUp != null && booleanAction.GetStateUp(inputSource))
            {
                onPressUp.Invoke(booleanAction);
            }

            if (onUpdate != null)
            {
                onUpdate.Invoke(booleanAction);
            }
        }