Ejemplo n.º 1
0
        public void ResetToInteractbaleDefault()
        {
            input.VRActions = new string[] { "NONE", "ACTION", "PICKUP_DROP" };
                        #if Int_Oculus || (Int_SteamVR && !Int_SteamVR2)
            input.triggerKey       = 1;
            input.triggerKeyOculus = 1;
            input.padTop           = 0;
            input.padTopOculus     = 0;
            input.padLeft          = 0;
            input.padLeftOculus    = 0;
            input.padRight         = 0;
            input.padRightOculus   = 0;
            input.padBottom        = 0;
            input.padBottomOculus  = 0;
            input.padCentre        = 0;
            input.padCentreOculus  = 0;
            input.padTouch         = 0;
            input.padTouchOculus   = 0;
            input.gripKey          = 2;
            input.gripKeyOculus    = 2;
            input.menuKey          = 0;
            input.menuKeyOculus    = 0;
            input.AXKey            = 0;
            input.AXKeyOculus      = 0;
                        #endif

                        #if Int_SteamVR2
            if (input.isSteamVR())
            {
                SteamVR_Action_Boolean actionAction     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("ACTION");
                SteamVR_Action_Boolean pickupDropAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PICKUP_DROP");
                input.booleanActions.Clear();
                input.booleanActions.Add(actionAction);
                input.booleanActions.Add(pickupDropAction);

                input.triggerPressure = SteamVR_Input.GetAction <SteamVR_Action_Single>("TriggerPressure");
                input.touchPosition   = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("TouchPosition");
                input.padTouched      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadTouched");
                input.padPressed      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadPressed");

                input.handType = input.LeftHand ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand;
                SteamVR_Behaviour_Pose poseComp = input.GetComponent <SteamVR_Behaviour_Pose>();
                if (poseComp == null)
                {
                    poseComp             = input.gameObject.AddComponent <SteamVR_Behaviour_Pose>();
                    poseComp.inputSource = input.handType;
                }
            }
                        #endif

            EditorUtility.SetDirty(input);
            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
        }
Ejemplo n.º 2
0
 private void OnBackActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue)
 {
     if (isBack.GetStateDown(hand.handType))
     {
         Debug.Log("Back down");
         moveVertical -= 1f;
     }
     if (isBack.GetStateUp(hand.handType))
     {
         Debug.Log("Forward up");
         moveVertical += 1f;
     }
 }
Ejemplo n.º 3
0
    public void TriggerDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        Debug.Log("Trigger is down");

        pressingGrab = true;

        /*
         * if (grabbingSomething && objectInHand != null)
         * {
         *  objectInHand.GetComponent<Transform>().parent = null;
         * }
         */
    }
Ejemplo n.º 4
0
 private void OnRightActionChange(SteamVR_Action_Boolean actionIn, SteamVR_Input_Sources inputSource, bool newValue)
 {
     if (isRight.GetStateDown(hand.handType))
     {
         Debug.Log("Right down");
         moveHorizontal += 1f;
     }
     if (isRight.GetStateUp(hand.handType))
     {
         Debug.Log("Right up");
         moveHorizontal -= 1f;
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        pose      = GetComponent <SteamVR_Behaviour_Pose>();
        rightHand = pose.inputSource;
        //tr = transform.parent.transform;

        RTrigger = SteamVR_Actions.default_RTrigger;
        LTrigger = SteamVR_Actions.default_LTrigger;

        lineEnableHandler = true;

        CreateLine();
    }
Ejemplo n.º 6
0
    // Called when the trigger on the controller is pushed down.
    protected virtual void OnTriggerUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        if (GetControllerState(fromSource).Holding != null)
        {
            var gun = GetControllerState(fromSource).Holding.PhysicsBody.GetComponent <IGun>();
            if (gun != null)
            {
                gun.TriggerUp();
            }
        }

        StopInteracting(fromSource);  // Always stop interacting with interactable objects when releasing the trigger button.
    }
Ejemplo n.º 7
0
    public void ButtonDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        if (interactable.attachedToHand == null)
        {
            return;
        }

        if (interactable.attachedToHand.handType != fromSource)
        {
            return;                                                     // if not the same hand, don't do anything
        }
        Delete();
    }
Ejemplo n.º 8
0
    private void XR_SetNextPrimaryFireMode(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        if (fromSource != parentHand.otherHand.handType)
        {
            return;
        }
        if (parentHand.otherHand.currentAttachedObject != offHandHoldArea)
        {
            return;
        }

        SetNextPrimaryFireMode();
    }
Ejemplo n.º 9
0
    //this is for when you press release the grip on the controller

    public void GripUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        if (singleLine)
        {
            draw = false;
        }
        if (multipleLine)
        {
            StartCoroutine(currentObj.GetComponent <TrailObject>().TimeUntilDestroy());
            currentObj.transform.parent = null;
            currentObj = null;
        }
    }
Ejemplo n.º 10
0
    // Start is called before the first frame update
    void Start()
    {
        tr = GetComponent <Transform>();

        pose    = GetComponent <SteamVR_Behaviour_Pose>();
        hand    = pose.inputSource;
        trigger = SteamVR_Actions.default_InteractUI;
        haptic  = SteamVR_Actions.default_Haptic;

        GameObject sel = GameObject.FindWithTag("Button");

        CreateLine();
    }
Ejemplo n.º 11
0
 //this is for when you press down the trigger on the controller
 public void TriggerDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
 {
     if (singleLine)
     {
         multipleLine = true;
         singleLine   = false;
     }
     else if (multipleLine)
     {
         singleLine   = true;
         multipleLine = false;
     }
 }
Ejemplo n.º 12
0
    public void GrabDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        if (pluckedObject != null)
        {
            return;
        }

        if (selection != null)
        {
            selection.Grab(transform);
            SetGrabbing(selection);
        }
    }
    private void CreateSetupAction(
        ref SteamVRBooleanAction action,
        SteamVR_Action_Boolean usedAction,
        UnityAction <SteamVR_Behaviour_Boolean, SteamVR_Input_Sources, bool> pressDown,
        UnityAction <SteamVR_Behaviour_Boolean, SteamVR_Input_Sources, bool> pressUp)
    {
        action = gameObject.AddComponent <SteamVRBooleanAction>();

        StartCoroutine(SetupAction(action,
                                   usedAction,
                                   pressDown,
                                   pressUp));
    }
Ejemplo n.º 14
0
 private void OnMenuBtnActionDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
 {
     if (canvas.enabled)
     {
         canvas.enabled = false;
         // transform.position = canvas.worldCamera.transform.position + canvas.worldCamera.transform.forward * distance;
     }
     else
     {
         canvas.enabled = true;
     }
     UpdatePointerState();
 }
Ejemplo n.º 15
0
 private void StopSpray(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
 {
     ClickCounter += 1;
     if (isCanOn)
     {
         NetworkDrawScript[] scripts = FindObjectsOfType <NetworkDrawScript>();
         foreach (NetworkDrawScript nds in scripts)
         {
             nds.StoptNetworkDrawRPC();
         }
         IsSpray = false;
     }
 }
Ejemplo n.º 16
0
        public void Setup(Transform parent)
        {
            m_radialItems    = new Dictionary <InventorySlot, RadialItem>();
            m_retrievedIcons = new Dictionary <InventorySlot, Sprite>();

            hackyInput[InputAction.SelectMelee]        = false;
            hackyInput[InputAction.SelectConsumable]   = false;
            hackyInput[InputAction.SelectHackingTool]  = false;
            hackyInput[InputAction.SelectResourcePack] = false;
            hackyInput[InputAction.SelectStandard]     = false;
            hackyInput[InputAction.SelectSpecial]      = false;
            hackyInput[InputAction.SelectTool]         = false;

            m_weaponRadialAction = SteamVR_Input.GetBooleanAction("WeaponRadialMenu");

            m_radialMenu = new GameObject("WeaponRadial").AddComponent <RadialMenu>();
            m_radialMenu.Setup(VR_Input.InteractionHand.MainHand);
            m_radialMenu.transform.SetParent(parent);

            m_radialMenu.AddRadialItem("Melee", WantToSelectMelee, out RadialItem melee);
            m_radialMenu.AddRadialItem("Secondary", WantToSelectSecondary, out RadialItem secondary);
            m_radialMenu.AddRadialItem("Tool", WantToSelectTool, out RadialItem tool);
            m_radialMenu.AddRadialItem("Pack", WantToSelectPack, out RadialItem pack);
            m_radialMenu.AddRadialItem("HackingTool", WantToSelectHackingTool, out RadialItem hackingTool);
            m_radialMenu.AddRadialItem("Consumable", WantToSelectConsumable, out RadialItem consumable);
            m_radialMenu.AddRadialItem("Primary", WantToSelectPrimary, out RadialItem primary);
            m_radialMenu.OnMenuClosedWithoutItem += MenuClosedQuick;

            melee.SetIcon(VRAssets.MeleeFallback, 1.5f);
            primary.SetIcon(VRAssets.PrimaryFallback);
            secondary.SetIcon(VRAssets.SecondaryFallback);
            tool.SetIcon(VRAssets.ToolFallback);
            consumable.SetIcon(VRAssets.ThrowableFallback);
            pack.SetIcon(VRAssets.PackFallback);
            hackingTool.SetIcon(VRAssets.HackingToolFallback);

            pack.Active       = false;
            consumable.Active = false;

            m_radialItems.Add(InventorySlot.GearMelee, melee);
            m_radialItems.Add(InventorySlot.GearStandard, primary);
            m_radialItems.Add(InventorySlot.GearSpecial, secondary);
            m_radialItems.Add(InventorySlot.GearClass, tool);
            m_radialItems.Add(InventorySlot.Consumable, consumable);
            m_radialItems.Add(InventorySlot.ResourcePack, pack);
            m_radialItems.Add(InventorySlot.HackingTool, hackingTool);

            InventoryAmmoEvents.OnInventoryAmmoUpdate    += AmmoUpdate;
            BackpackEvents.OnNewItemStatus               += ItemStatusChanged;
            VRConfig.configWeaponInfoText.SettingChanged += ToggleInfoText;
        }
    // activate/deactivate pointer when the associated button is pressed
    void ActivatePointer(SteamVR_Action_Boolean action, SteamVR_Input_Sources source)
    {
        if (simulationStatus == true)
        {
            // update pointer status mode
            pointerIsActive = !pointerIsActive;

            // set the laser pointer on the source hand
            SetPointerToHand(GameObject.Find(source.ToString()));

            // activate/deactivate laser pointer on the source hand
            measureLaserPointer.gameObject.SetActive(pointerIsActive);
        }
    }
Ejemplo n.º 18
0
        protected void MeasureButtonPressTime(Hand hand, SteamVR_Action_Boolean buttonAction)
        {
            if (WasButtonPressed(hand, buttonAction))
            {
                startTime = Time.time;
            }

            if (WasButtonReleased(hand, buttonAction))
            {
                duration = Time.time - startTime;
//                Debug.Log("Buttonpress duration: " + duration);
//                Debug.Log("deltaTime: " + Time.deltaTime);
            }
        }
Ejemplo n.º 19
0
 void Awake()
 {
     watchRadialMenu = SteamVR_Input.GetBooleanAction("WatchRadialMenu");
     toggleWatchMode = SteamVR_Input.GetBooleanAction("ToggleWatchMode");
     Current         = this;
     ItemEquippableEvents.OnPlayerWieldItem                 += ItemSwitched;
     InventoryAmmoEvents.OnInventoryAmmoUpdate              += AmmoUpdate;
     Controllers.HandednessSwitched                         += SetHandedness;
     VRConfig.configWatchScaling.SettingChanged             += WatchScaleChanged;
     VRConfig.configUseNumbersForAmmoDisplay.SettingChanged += AmmoDisplayChanged;
     VRConfig.configWatchColor.SettingChanged               += WatchColorChanged;
     VRConfig.configWatchInfoText.SettingChanged            += WatchRadialInfoTextChanged;
     ChatMsgEvents.OnChatMsgReceived                        += ChatMsgReceived;
 }
    private void OnTriggerPressedOrReleased(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState)
    {
        Debug.Log("Trigger was pressed or released");
        if (gameInOn == false)
        {
            screenController.StartGame();
            gameInOn = true;
        }

        else
        {
            Debug.Log("something else");
        }
    }
Ejemplo n.º 21
0
    void emitVRActionBooleanChange(SteamVR_Action_Boolean action, bool value)
    {
        if (ClientManager.instance.state != BaseNetworking.componentState.RUNNING || ClientManager.instance.workerClient == null)
        {
            return;
        }
        Debug.Log("sending boolean of " + action.GetShortName() + "=" + value);

        VRActionBoolMessage message = new VRActionBoolMessage();

        message.actionName = action.GetShortName();
        message.value      = value;
        ClientManager.instance.workerClient.sendMessage(message);
    }
Ejemplo n.º 22
0
    // Start is called before the first frame update
    void Start()
    {
        trigger = SteamVR_Actions.default_Trigger;
        pose    = GetComponent <SteamVR_Behaviour_Pose>();
        hand    = pose.inputSource;

        CreateLineRenderer();

        tr = GetComponent <Transform>();

        audioSource             = GetComponent <AudioSource>();
        audioSource.loop        = false;
        audioSource.playOnAwake = false;
    }
Ejemplo n.º 23
0
 /// <summary>
 /// Toggles the active state of the location panel.
 /// </summary>
 /// <param name="fromAction">Action that triggered the behavior.</param>
 /// <param name="fromSource">Source of the action.</param>
 public void TooltipActive(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
 {
     Debug.Log("Activating tooltip");
     if (active)
     {
         LocationPanel.SetActive(false);
         active = false;
     }
     else
     {
         LocationPanel.SetActive(true);
         active = true;
     }
 }
Ejemplo n.º 24
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(2.0f));

        pose     = GetComponent <SteamVR_Behaviour_Pose>();
        hand     = SteamVR_Input_Sources.LeftHand;
        teleport = SteamVR_Actions.default_Teleport;

        pointerPrefab = Resources.Load <GameObject>("Pointer");
        pointer       = Instantiate <GameObject>(pointerPrefab, this.transform);
        tr            = GetComponent <Transform>();

        CreateLine();
    }
Ejemplo n.º 25
0
    private void DialogInteract(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    {
        // If we have the spell plane open, end the conversation
        if (spellPlane.isSpellPlaneActive)
        {
            lineRenderer.enabled = false;
            if (activeDialogManager != null)
            {
                activeDialogManager.EndDialogEarly();
            }
            return;
        }

        // -- Next dialog line
        if (activeDialogManager != null)
        {
            activeDialogManager.DisplayNextSentence();
        }

        // Raycast forward from the hand
        // If we collide with something that we can chat with, then start that conversation
        if (Physics.Raycast(hand.transform.position, hand.transform.forward, out RaycastHit hit, raycastDistance, startDialogRaycastLayerMask))
        {
            if (hit.collider.TryGetComponent(out BaseDialog dialog))
            {
                // If we aren't already in a conversation with this character, then start a new convo
                if (dialog.dialogManager != activeDialogManager || !activeDialogManager.isDialogActive)
                {
                    // Raycast to the collision point
                    lineRenderer.SetPosition(0, hand.transform.position);
                    lineRenderer.SetPosition(1, hit.point);
                    lineRendererAnimator.SetTrigger("fire");

                    // -- Phase out of the old dialog
                    //  WIP
                    if (activeDialogManager != null)
                    {
                        activeDialogManager.EndDialogEarly();
                    }

                    // -- Start a new convo
                    activeDialogManager = dialog.dialogManager;
                    otherDialogInteractor.activeDialogManager = dialog.dialogManager;
                    dialog.StartDialog();

                    return;
                }
            }
        }
Ejemplo n.º 26
0
 protected void TriggerLoop(Hand hand, SteamVR_Action_Boolean triggerAction)
 {
     if (WasButtonPressed(hand, triggerAction))
     {
         if (hand.hoveringInteractable != null)
         {
             tmpSoundblob = hand.hoveringInteractable.gameObject;
             tmpSoundblob.GetComponent <AudioSource>().loop = !tmpSoundblob.GetComponent <AudioSource>().loop;
         }
         else
         {
             return;
         }
     }
 }
Ejemplo n.º 27
0
        public static bool GetActionUp(InputAction action)
        {
            if (!Initialized)
            {
                return(false);
            }

            SteamVR_Action_Boolean boolActionMapping = GetBoolActionMapping(action);

            if (IsIRLCrouchValid(action))
            {
                return(boolActionMapping != null && !boolActionMapping.GetStateDown(SteamVR_Input_Sources.Any) || !boolActionMapping.GetState(SteamVR_Input_Sources.Any) && (boolActionMapping.GetStateUp(SteamVR_Input_Sources.Any) || (HMD.Hmd.transform.localPosition.y + VRConfig.configFloorOffset.Value > VRConfig.configCrouchHeight.Value / 100f)));
            }
            return(boolActionMapping != null && boolActionMapping.GetStateUp(SteamVR_Input_Sources.Any));
        }
 public void modeSwitchDown(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
 {
     if (currentModeIsOverView == false)
     {
         GameObject spawner = GameObject.Find("Spawner");
         spawner.GetComponent <Spawn_nodes>().reset("overview");
         currentModeIsOverView = true;
     }
     else
     {
         GameObject spawner = GameObject.Find("Spawner");
         spawner.GetComponent <Spawn_nodes>().reset("standard");
         currentModeIsOverView = false;
     }
 }
Ejemplo n.º 29
0
    private void PrimaryFireStateUpdate(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState)
    {
        // Can't shoot the gun when we're in the middle of force grabbing
        if (grappler.isGrappleProjectileDeployed)
        {
            return;
        }
        if (IsTransitioningBetweenFireModes())
        {
            return;
        }

        // Pass the fire action to the active "Blaster Module"
        //fireModes[primaryFireMode].OnStateUpdate(fromAction, fromSource, newState);
    }
Ejemplo n.º 30
0
        public static bool GetAction(InputAction action)
        {
            if (!VRInput.Initialized)
            {
                return(false);
            }

            SteamVR_Action_Boolean boolActionMapping = VRInput.instance.GetBoolActionMapping(action);

            if (IsIRLCrouchValid(action))
            {
                return((boolActionMapping != null && boolActionMapping.GetState(SteamVR_Input_Sources.Any)) || HMD.hmd.transform.localPosition.y < VRInput.IRLCrouchBorder);
            }
            return(boolActionMapping != null && boolActionMapping.GetState(SteamVR_Input_Sources.Any));
        }