コード例 #1
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            //modifying this for only gazing and not clicking and holding with fingers

            //if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0 && !hasDown)
            if (state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0 && !hasDown)
            {
                hasDown    = true;
                clickTimer = 0;
            }
            //else if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value < 1)
            else if (state.GetState(InteractableStates.InteractableStateEnum.Focus).Value < 1)
            {
                hasDown = false;
            }

            if (hasDown && clickTimer < HoldTime)
            {
                clickTimer += Time.deltaTime;

                if (clickTimer >= HoldTime)
                {
                    uEvent.Invoke();
                }
            }
        }
コード例 #2
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0 && !hasDown)
            {
                hasDown    = true;
                clickTimer = 0;
            }
            else if (state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value < 1)
            {
                hasDown = false;
            }

            Debug.Log(HoldTime);

            if (hasDown && clickTimer < HoldTime)
            {
                clickTimer += Time.deltaTime;

                if (clickTimer >= HoldTime)
                {
                    Debug.Log("Hold!!");
                    uEvent.Invoke();
                }
            }
        }
        /// <inheritdoc />
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hadDown = hasDown;

            hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;


            if (hasDown != hadDown)
            {
                if (hasDown)
                {
                    isNear = state.GetState(InteractableStates.InteractableStateEnum.PhysicalTouch).Value > 0;
                    if (IsFilterValid())
                    {
                        uEvent.Invoke();
                    }
                }
                else
                {
                    if (IsFilterValid())
                    {
                        OnRelease.Invoke();
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Called on update, check to see if the state has changed sense the last call
 /// </summary>
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
     if (state.CurrentState() != lastState)
     {
         // the state has changed, do something new
         lastState = state.CurrentState();
     }
 }
コード例 #5
0
        /// <summary>
        /// Creates the default States ScriptableObject configured for Interactable
        /// </summary>
        /// <returns>Default Interactable States asset</returns>
        public static States GetDefaultInteractableStates()
        {
            States             result = ScriptableObject.CreateInstance <States>();
            InteractableStates allInteractableStates = new InteractableStates();

            result.StateModelType = typeof(InteractableStates);
            result.StateList      = allInteractableStates.GetDefaultStates();
            result.DefaultIndex   = 0;
            return(result);
        }
コード例 #6
0
 /// <summary>
 /// A state has changed
 /// </summary>
 public override void OnStateChange(InteractableStates state, Interactable source)
 {
     base.OnStateChange(state, source);
     if (Events.Count > 0)
     {
         if (Events[0].Receiver != null)
         {
             Events[0].Receiver.OnUpdate(state, source);
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// .A state has changed
        /// </summary>
        public override void OnStateChange(InteractableStates state, Interactable source)
        {
            base.OnStateChange(state, source);

            for (int i = 0; i < Events.Count; i++)
            {
                if (Events[i].Receiver != null)
                {
                    Events[i].Receiver.OnUpdate(state, source);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// click happened
        /// </summary>
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            base.OnClick(state, source, pointer);

            if (Events.Count > 0)
            {
                if (Events[0].Receiver != null)
                {
                    Events[0].Receiver.OnClick(state, source, pointer);
                }
            }
        }
コード例 #9
0
ファイル: States.cs プロジェクト: julenka/mrtk-tips
        public static States GetDefaultInteractableStates()
        {
            States result = CreateInstance <States>();

            InteractableStates allInteractableStates = new InteractableStates();

            result.StateType    = Type.GetType(typeof(InteractableStates).AssemblyQualifiedName);
            result.StateOptions = InteractableTypeFinder.Find(candidateStateTypes, TypeRestriction.AllowBase);
            result.StateList    = allInteractableStates.GetDefaultStates();
            result.DefaultIndex = 0;
            return(result);
        }
コード例 #10
0
        /// <summary>
        /// voice command happened
        /// </summary>
        public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
        {
            base.OnVoiceCommand(state, source, command, index, length);

            if (Events.Count > 0)
            {
                if (Events[0].Receiver != null)
                {
                    Events[0].Receiver.OnVoiceCommand(state, source, command, index, length);
                }
            }
        }
コード例 #11
0
        /// <inheritdoc />
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            int currentIndex = source.GetDimensionIndex();

            if (currentIndex % 2 == 0)
            {
                OnDeselect.Invoke();
            }
            else
            {
                uEvent.Invoke();
            }
        }
コード例 #12
0
 /// <inheritdoc />
 public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     if (source.ButtonMode == SelectionModes.Toggle)
     {
         if (source.IsToggled)
         {
             OnSelect.Invoke();
         }
         else
         {
             OnDeselect.Invoke();
         }
     }
 }
コード例 #13
0
        /// <summary>
        /// click happened
        /// </summary>
        public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
        {
            base.OnClick(state, source);
            if (Host != null)
            {
                if (showClicked != null)
                {
                    Host.StopCoroutine(showClicked);
                    showClicked = null;
                }

                showClicked = Host.StartCoroutine(ClickTimer(clickTime));
            }

            clickCount++;
            SetOutput();
        }
コード例 #14
0
        /// <summary>
        /// Called on update, check to see if the state has changed sense the last call
        /// </summary>
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            if (state.CurrentState() != lastState)
            {
                // the state has changed, do something new

                /*
                 * bool hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;
                 *
                 * bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;
                 *
                 * bool isDisabled = state.GetState(InteractableStates.InteractableStateEnum.Disabled).Value > 0;
                 *
                 * bool hasInteractive = state.GetState(InteractableStates.InteractableStateEnum.Interactive).Value > 0;
                 *
                 * bool hasObservation = state.GetState(InteractableStates.InteractableStateEnum.Observation).Value > 0;
                 *
                 * bool hasObservationTargeted = state.GetState(InteractableStates.InteractableStateEnum.ObservationTargeted).Value > 0;
                 *
                 * bool isTargeted = state.GetState(InteractableStates.InteractableStateEnum.Targeted).Value > 0;
                 *
                 * bool isToggled = state.GetState(InteractableStates.InteractableStateEnum.Toggled).Value > 0;
                 *
                 * bool isVisited = state.GetState(InteractableStates.InteractableStateEnum.Visited).Value > 0;
                 *
                 * bool isDefault = state.GetState(InteractableStates.InteractableStateEnum.Default).Value > 0;
                 *
                 * bool hasGesture = state.GetState(InteractableStates.InteractableStateEnum.Gesture).Value > 0;
                 *
                 * bool hasGestureMax = state.GetState(InteractableStates.InteractableStateEnum.GestureMax).Value > 0;
                 *
                 * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.Collision).Value > 0;
                 *
                 * bool hasCustom = state.GetState(InteractableStates.InteractableStateEnum.Custom).Value > 0;
                 *
                 * or:
                 *
                 * bool hasFocus = source.HasFocus;
                 * bool hasPress = source.HasPress;
                 */

                lastState = state.CurrentState();
                SetOutput();
            }
        }
コード例 #15
0
        /// <summary>
        /// voice command called
        /// </summary>
        public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
        {
            base.OnVoiceCommand(state, source, command, index, length);
            lastVoiceCommand = command;

            if (Host != null)
            {
                if (showVoice != null)
                {
                    Host.StopCoroutine(showVoice);
                    showVoice = null;
                }

                showVoice = Host.StartCoroutine(VoiceTimer(clickTime));
            }

            SetOutput();
        }
コード例 #16
0
        /// <inheritdoc />
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;

            if (hadFocus != hasFocus)
            {
                if (hasFocus)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnFocusOff.Invoke();
                }
            }

            hadFocus = hasFocus;
        }
コード例 #17
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hadTouch = state.GetState(InteractableStates.InteractableStateEnum.PhysicalTouch).Value > 0;

            if (this.hadTouch != hadTouch)
            {
                if (hadTouch)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnTouchEnd.Invoke();
                }
            }

            this.hadTouch = hadTouch;
        }
コード例 #18
0
        /// <inheritdoc />
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hasGrab = state.GetState(InteractableStates.InteractableStateEnum.Grab).Value > 0;

            if (hadGrab != hasGrab)
            {
                if (hasGrab)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnRelease.Invoke();
                }
            }

            hadGrab = hasGrab;
        }
コード例 #19
0
        public InteractableStates SetupLogic()
        {
            StateType = Type.GetType(AssemblyQualifiedName);
            InteractableStates stateLogic    = (InteractableStates)Activator.CreateInstance(StateType, StateList[DefaultIndex]);
            List <State>       stateListCopy = new List <State>();

            for (int i = 0; i < StateList.Count; i++)
            {
                State state = new State();
                state.ActiveIndex = StateList[i].ActiveIndex;
                state.Bit         = StateList[i].Bit;
                state.Index       = StateList[i].Index;
                state.Name        = StateList[i].Name;
                state.Value       = StateList[i].Value;
                stateListCopy.Add(state);
            }
            stateLogic.ImportStates(stateListCopy);

            return(stateLogic);
        }
コード例 #20
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool changed = state.CurrentState() != lastState;

            bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;

            if (hadFocus != hasFocus && changed)
            {
                if (hasFocus)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnFocusOff.Invoke();
                }
            }

            hadFocus  = hasFocus;
            lastState = state.CurrentState();
        }
コード例 #21
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool hasFocus = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;

            float focusTime = source.gameObject.GetComponent <ButtonFocusTime>().GetFocusTime();

            //if button is focused for focusTime seconds, change button's focus state to be false
            if (hasFocus && focusTimer < focusTime)
            {
                focusTimer += Time.deltaTime;

                if (focusTimer >= focusTime)
                {
                    source.SetState(InteractableStates.InteractableStateEnum.Focus, false);
                }
            }
            else
            {
                focusTimer = 0;
            }


            bool changed = state.CurrentState() != lastState;

            if (hadFocus != hasFocus && changed)
            {
                if (hasFocus)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnFocusOff.Invoke();
                }
            }

            hadFocus  = hasFocus;
            lastState = state.CurrentState();
        }
コード例 #22
0
        public override void OnUpdate(InteractableStates state, Interactable source)
        {
            bool changed = state.CurrentState() != lastState;

            bool hadDown = hasDown;

            hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;

            if (changed && hasDown != hadDown)
            {
                if (hasDown)
                {
                    uEvent.Invoke();
                }
                else
                {
                    OnRelease.Invoke();
                }
            }

            lastState = state.CurrentState();
        }
コード例 #23
0
        /// <summary>
        /// a state has changed
        /// </summary>
        public virtual void OnStateChange(InteractableStates state, Interactable source)
        {
            // the state has changed, do something new

            /*
             * bool hasDown = state.GetState(InteractableStates.InteractableStateEnum.Pressed).Value > 0;
             *
             * bool focused = state.GetState(InteractableStates.InteractableStateEnum.Focus).Value > 0;
             *
             * bool isDisabled = state.GetState(InteractableStates.InteractableStateEnum.Disabled).Value > 0;
             *
             * bool hasInteractive = state.GetState(InteractableStates.InteractableStateEnum.Interactive).Value > 0;
             *
             * bool hasObservation = state.GetState(InteractableStates.InteractableStateEnum.Observation).Value > 0;
             *
             * bool hasObservationTargeted = state.GetState(InteractableStates.InteractableStateEnum.ObservationTargeted).Value > 0;
             *
             * bool isTargeted = state.GetState(InteractableStates.InteractableStateEnum.Targeted).Value > 0;
             *
             * bool isToggled = state.GetState(InteractableStates.InteractableStateEnum.Toggled).Value > 0;
             *
             * bool isVisited = state.GetState(InteractableStates.InteractableStateEnum.Visited).Value > 0;
             *
             * bool isDefault = state.GetState(InteractableStates.InteractableStateEnum.Default).Value > 0;
             *
             * bool hasGesture = state.GetState(InteractableStates.InteractableStateEnum.Gesture).Value > 0;
             *
             * bool hasGestureMax = state.GetState(InteractableStates.InteractableStateEnum.GestureMax).Value > 0;
             *
             * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.Collision).Value > 0;
             *
             * bool hasCollistion = state.GetState(InteractableStates.InteractableStateEnum.VoiceCommand).Value > 0;
             *
             * bool hasCustom = state.GetState(InteractableStates.InteractableStateEnum.Custom).Value > 0;
             */
        }
コード例 #24
0
 /// <inheritdoc />
 public virtual void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
 {
     // Voice Command Happened
 }
コード例 #25
0
ファイル: Interactable.cs プロジェクト: icyAce/MapsSDK-Unity
 /// <summary>
 /// starts the StateManager
 /// </summary>
 protected virtual void SetupStates()
 {
     StateManager = States.SetupLogic();
 }
コード例 #26
0
 /// <inheritdoc />
 public virtual void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     // Click Happened
 }
 /// <inheritdoc />
 public override void OnUpdate(InteractableStates state, Interactable source)
 {
     // using onClick
 }
コード例 #28
0
 /// <summary>
 /// voice command called
 /// </summary>
 public override void OnVoiceCommand(InteractableStates state, Interactable source, string command, int index = 0, int length = 1)
 {
     base.OnVoiceCommand(state, source, command, index, length);
     PlayAudio(source);
 }
コード例 #29
0
 /// <summary>
 /// click happened
 /// </summary>
 public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     base.OnClick(state, source);
     PlayAudio(source);
 }
 /// <inheritdoc />
 public override void OnClick(InteractableStates state, Interactable source, IMixedRealityPointer pointer = null)
 {
     uEvent.Invoke();
 }