Ejemplo n.º 1
0
 private void OnEnable()
 {
     if (ForestVR.Enabled)
     {
         VRControllerDisplayManager.AutoShowAction(this._action, true, this._texture.texture as Texture2D, ActionIcon.SideIconTypes.None, null, null, false);
     }
 }
Ejemplo n.º 2
0
        private static string GetMappingPrefixVR(Controller controllerSource)
        {
            VRControllerDisplayManager.VRControllerType activeControllerType = VRControllerDisplayManager.GetActiveControllerType();
            if (activeControllerType == VRControllerDisplayManager.VRControllerType.Vive)
            {
                return("VIVE_");
            }
            if (activeControllerType == VRControllerDisplayManager.VRControllerType.OculusTouch)
            {
                return("OCTOUCH_");
            }
            string[] matchStrings = new string[]
            {
                "Oculus Touch.*",
                "Oculus Controller"
            };
            string[] matchStrings2 = new string[]
            {
                "Open VR Controller.*"
            };
            string name = controllerSource.name;

            if (InputMappingIcons.GetMappingPrefix(name, matchStrings))
            {
                return("OCTOUCH_");
            }
            if (InputMappingIcons.GetMappingPrefix(name, matchStrings2))
            {
                return("VIVE_");
            }
            return(null);
        }
Ejemplo n.º 3
0
 private void OnDisable()
 {
     if (ForestVR.Enabled)
     {
         VRControllerDisplayManager.AutoShowAction(this._action, false, null, ActionIcon.SideIconTypes.None, null, null, false);
     }
 }
Ejemplo n.º 4
0
    public static void AutoAddTextLine(string newLine, Hand.HandType handType)
    {
        VRControllerDisplayManager controllerDisplay = VRControllerDisplayManager.GetControllerDisplay(handType);

        if (controllerDisplay == null)
        {
            return;
        }
        controllerDisplay.AddTextLine(newLine);
    }
Ejemplo n.º 5
0
        public static ActionIcon RegisterIcon(Transform target, InputMappingIcons.Actions action, ActionIcon.SideIconTypes sideIcon, ActionIconSystem.CurrentViewOptions currentViewOption = ActionIconSystem.CurrentViewOptions.AllowInWorld, bool useAltTextIcon = false, bool useBigIcon = false, Texture2D vrIcon = null, string actionStringOverride = null, bool useFillSprite = false)
        {
            ActionIcon actionIcon = ActionIconSystem.InitializeActionIcon(target, action, sideIcon, currentViewOption, useAltTextIcon, useBigIcon);

            if (ForestVR.Enabled && !ActionIconSystem.Instance._activeVRButtonActionIcons.ContainsKey(target))
            {
                VRControllerDisplayManager.AutoShowAction(action, true, vrIcon, sideIcon, actionStringOverride, (!actionIcon.IsNull()) ? actionIcon._fillSpriteAction : null, useFillSprite);
                ActionIconSystem.Instance._activeVRButtonActionIcons.Add(target, action);
            }
            return(actionIcon);
        }
Ejemplo n.º 6
0
    public void ShowRespawnPrompt(bool onoff)
    {
        VRControllerDisplayManager componentInChildren = this.RightHand.GetComponentInChildren <VRControllerDisplayManager>();

        if (componentInChildren == null)
        {
            return;
        }
        if (componentInChildren.RespawnButton)
        {
            componentInChildren.RespawnButton.SetActive(onoff);
        }
    }
Ejemplo n.º 7
0
 public static void ForceRefreshState()
 {
     if (ForestVR.Enabled)
     {
         VRControllerDisplayManager.ForceRefresh();
     }
     if (Input.GetState(InputState.SavingMaps))
     {
         Input.SetMappingExclusive(KeyMapCategory.Default);
         InputMappingIcons.RefreshMappings();
         return;
     }
     if (Input.GetState(InputState.Locked))
     {
         Input.SetMappingExclusive(KeyMapCategory.None);
         InputMappingIcons.RefreshMappings();
         return;
     }
     if (Input.GetState(InputState.Chat))
     {
         Input.SetMappingExclusive(KeyMapCategory.Chat);
         InputMappingIcons.RefreshMappings();
         return;
     }
     if (Input.GetState(InputState.Menu))
     {
         Input.SetMappingExclusive(KeyMapCategory.Menu);
         InputMappingIcons.RefreshMappings();
         return;
     }
     if (Input.GetState(InputState.RadialWorld))
     {
         Input.SetMappingExclusive(KeyMapCategory.RadialWorld);
         InputMappingIcons.RefreshMappings();
         return;
     }
     if (Input.GetState(InputState.Book))
     {
         Input.SetMappingExclusive(KeyMapCategory.Book);
         InputMappingIcons.RefreshMappings();
         return;
     }
     if (Input.GetState(InputState.Inventory))
     {
         Input.SetMappingExclusive(KeyMapCategory.Inventory);
         InputMappingIcons.RefreshMappings();
         return;
     }
     Input.SetMappingExclusive(KeyMapCategory.Default);
     InputMappingIcons.RefreshMappings();
 }
Ejemplo n.º 8
0
 private void ProcessVRInputMappings(Player player)
 {
     VRControllerDisplayManager.VRControllerType activeControllerType = VRControllerDisplayManager.GetActiveControllerType();
     if (activeControllerType != VRControllerDisplayManager.VRControllerType.Vive)
     {
         if (activeControllerType == VRControllerDisplayManager.VRControllerType.OculusTouch)
         {
             this.ProcessVROculusInputMappings(player);
         }
     }
     else
     {
         this.ProcessVRViveInputMappings(player);
     }
 }
Ejemplo n.º 9
0
        public static ActionIcon UnregisterIcon(Transform target, bool useAltTextIcon = false, bool useBigIcon = false)
        {
            if (ForestVR.Enabled && ActionIconSystem.Instance != null && ActionIconSystem.Instance._activeVRButtonActionIcons.ContainsKey(target))
            {
                VRControllerDisplayManager.AutoShowAction(ActionIconSystem.Instance._activeVRButtonActionIcons[target], false, null, ActionIcon.SideIconTypes.None, null, null, false);
                ActionIconSystem.Instance._activeVRButtonActionIcons.Remove(target);
            }
            ActionIcon actionIcon;

            if (ActionIconSystem.Instance && ActionIconSystem.Instance._activeIcons.TryGetValue(target, out actionIcon))
            {
                actionIcon._follow._target2 = null;
                if (actionIcon._fillSpriteAction)
                {
                    actionIcon._fillSpriteAction._actionName = null;
                }
                ActionIconSystem.Instance._activeIcons.Remove(target);
                ActionIconSystem.Instance.DisableActionIcon(actionIcon, useAltTextIcon, useBigIcon);
                return(actionIcon);
            }
            return(null);
        }
Ejemplo n.º 10
0
    public void ShowAction(InputMappingIcons.Actions actionTarget, bool showValue, Texture2D iconTexture = null, ActionIcon.SideIconTypes sideIcon = ActionIcon.SideIconTypes.None, string actionStringOverride = null, DelayedAction delayedAction = null, bool useFillSprite = false)
    {
        Rewired.Player player = ReInput.players.GetPlayer(0);
        if (ReInput.players == null || player == null)
        {
            return;
        }
        Rewired.Player.ControllerHelper controllers = player.controllers;
        string stringValue = actionStringOverride.NullOrEmpty() ? this.GetActionText(actionTarget) : actionStringOverride;

        foreach (ControllerMap controllerMap in controllers.maps.GetAllMaps(ControllerType.Joystick))
        {
            if (controllerMap.enabled)
            {
                Controller controller = ReInput.controllers.GetController(ControllerType.Joystick, controllerMap.controllerId);
                if (controller.name.Equals(this.ControllerName))
                {
                    foreach (ActionElementMap actionElementMap in controllerMap.AllMaps)
                    {
                        InputAction action = ReInput.mapping.GetAction(actionElementMap.actionId);
                        if (action != null)
                        {
                            if (VRControllerDisplayManager.ActionMatches(actionTarget, action))
                            {
                                string elementIdentifierName = actionElementMap.elementIdentifierName;
                                if (iconTexture == null && showValue)
                                {
                                    this.RevertIcon(elementIdentifierName);
                                }
                                this.SetActive(elementIdentifierName, showValue, iconTexture, stringValue.IfNull(string.Empty).ToUpper(), this.ShouldShowTextBacking(), sideIcon, delayedAction, useFillSprite);
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 11
0
    private static bool ActionMatches(InputMappingIcons.Actions actionTarget, InputAction action)
    {
        string name = action.name;

        return(name.Equals(VRControllerDisplayManager.GetActionTargetName(actionTarget), StringComparison.InvariantCultureIgnoreCase));
    }
Ejemplo n.º 12
0
 private void Update()
 {
     VRControllerDisplayManager.VRControllerType vrcontrollerType = (!this.SimulateOculus) ? ((!this.SimulateVive) ? VRControllerDisplayManager.GetActiveControllerType() : VRControllerDisplayManager.VRControllerType.Vive) : VRControllerDisplayManager.VRControllerType.OculusTouch;
     if (this.ActiveControllerType == vrcontrollerType)
     {
         return;
     }
     this.ActiveControllerType = vrcontrollerType;
     if (this.ActiveControllerType == VRControllerDisplayManager.VRControllerType.Vive)
     {
         this.ShowSource(this.ViveSource, this.VivePositionOffset, this.ViveRotationOffset);
     }
     else if (this.ActiveControllerType == VRControllerDisplayManager.VRControllerType.OculusTouch)
     {
         this.ShowSource(this.OculusSource, this.OculusPositionOffset, this.OculusRotationOffset);
     }
 }