コード例 #1
0
 private void OnControllerCallback(InputManager.InputState inputState)
 {
     if (inputState.Buttons.HasFlag(InputManager.InputState.ActiveFunction.OpenMenu))
     {
         Load(menuScene);
     }
 }
コード例 #2
0
    private void OnControllerCallback(InputManager.InputState inputState)
    {
        if (inputState.Buttons.HasFlag(InputManager.InputState.ActiveFunction.SequenceRecord))
        {
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "");
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "Save sequence into top or bottom slot");
        }

        if (tooltips.buttonTwoText.Length == 0 && (inputState.Buttons & InputManager.InputState.ActiveFunction.SequencePlaybacks) > 0)
        {
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "Record a motion sequence");
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "Replay sequence saved into top or bottom slot");
        }
    }
コード例 #3
0
    private void OnControllerCallback(InputManager.InputState inputState)
    {
        if (inputState.Buttons.HasFlag(InputManager.InputState.ActiveFunction.SequenceRecord))
        {
            // Ensure that only one recording takes place at a time.
            foreach (RecordStruct s in recordingControllers)
            {
                if (s.controller == inputState.Controller)
                {
                    return;
                }
            }

            recordingControllers.Add(new RecordStruct()
            {
                controller = inputState.Controller, recording = new LinkedList <PlaybackState>()
            });
        }
        else if ((inputState.Buttons & InputManager.InputState.ActiveFunction.SequencePlaybacks) > 0)
        {
            bool isRecording = false;


            foreach (RecordStruct s in recordingControllers)
            {
                if (s.controller == inputState.Controller)
                {
                    isRecording = true;
                }
            }

            int offset = -1;

            if (!controllerPlaybackOffset.TryGetValue(inputState.Controller, out offset))
            {
                offset = nextOffset++;

                controllerPlaybackOffset.Add(inputState.Controller, offset);
            }

            int playbackIndex = 0;

            switch (inputState.Buttons & InputManager.InputState.ActiveFunction.SequencePlaybacks)
            {
            case InputManager.InputState.ActiveFunction.SequencePlayback0:
                playbackIndex = 0;
                break;

            case InputManager.InputState.ActiveFunction.SequencePlayback1:
                playbackIndex = 1;
                break;

            case InputManager.InputState.ActiveFunction.SequencePlayback2:
                playbackIndex = 2;
                break;

            case InputManager.InputState.ActiveFunction.SequencePlayback3:
                playbackIndex = 3;
                break;
            }

            if (isRecording)
            {
                RecordStruct recStruct = null;

                foreach (RecordStruct s in recordingControllers)
                {
                    if (s.controller == inputState.Controller)
                    {
                        recStruct = s;
                        break;
                    }
                }

                // Last frame is the frame that will destroy the controller clone, so it won't be seen
                recStruct.recording.AddLast(new PlaybackState(Vector3.zero, Quaternion.identity, 0));


                recordedPlaybacks.Remove(offset * NUM_SEQUENCES + playbackIndex);
                recordedPlaybacks.Add(offset * NUM_SEQUENCES + playbackIndex, recStruct.recording);

                recordingControllers.Remove(recStruct);
            }
            else
            {
                LinkedList <PlaybackState> recording;

                if (recordedPlaybacks.TryGetValue(offset * NUM_SEQUENCES + playbackIndex, out recording))
                {
                    GameObject controller = Instantiate(controllerTemplate);

                    controller.SetActive(true);

                    controller.transform.parent = null;

                    // Update() may not be called directly after cloning, to avoid odd starting positions, we place the controller at the first frame
                    controller.transform.position = recording.First.Value.position;
                    controller.transform.rotation = recording.First.Value.rotation;

                    InputManager.AddUserController(controller);

                    playingControllers.Add(new RecordStruct()
                    {
                        controller = controller, recording = recording, iterator = recording.GetEnumerator()
                    });
                }
            }
        }
        else
        {
            // Record changes to input state too.
            foreach (RecordStruct s in recordingControllers)
            {
                if (s.controller == inputState.Controller)
                {
                    // Add buttons to last recorded state (good enough approximation)
                    PlaybackState lastState = s.recording.Last.Value;

                    lastState.buttons |= inputState.Buttons;

                    s.recording.Last.Value = lastState;
                }
            }
        }
    }
コード例 #4
0
ファイル: InputAction.cs プロジェクト: Straskal/Arcade
 public InputAction(InputManager.InputState state)
 {
     inputState = state;
 }
コード例 #5
0
 public ModifiedPressedAction(InputManager.InputState state) : base(state)
 {
 }