Example #1
0
 public static bool Contains <T> (this UnityEngine.InputSystem.Utilities.ReadOnlyArray <T> array, T element)
 {
     foreach (T obj in array)
     {
         if (obj.Equals(element))
         {
             return(true);
         }
     }
     return(false);
 }
 public static bool Contains <T> (this UnityEngine.InputSystem.Utilities.ReadOnlyArray <T> array, T element)
 {
     for (int i = 0; i < array.Count; i++)
     {
         T obj = array[i];
         if (obj.Equals(element))
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
        /// <summary>
        /// Vibrates the controller at the specified index, if it exists
        /// </summary>
        /// <param name="index">The index to vibrate the controller</param>
        /// <param name="settings">The settings of the vibration</param>
        public static void VibrateController(int index, VibrationSettings settings)
        {
            UnityEngine.InputSystem.Utilities.ReadOnlyArray <Gamepad> pads = Gamepad.all;
            if (index >= pads.Count)
            {
                Debug.LogError("Controller at index " + index + " not found.");
                return;
            }
            Gamepad currentGamepad = pads[index];

            WSoft.Core.GameManager gameManager = WSoft.Core.GameManager.Instance;
            if (gameManager == null)
            {
                Debug.LogError("Game Manager does not exist in current scene");
                return;
            }
            gameManager.StartCoroutine(VibrateControllerCoroutine(currentGamepad, settings));
        }
Example #4
0
        /// <summary>
        /// Load keybindings.
        /// </summary>
        public void Load()
        {
            BindingWrapper load = JsonUtility.FromJson <BindingWrapper>(PlayerPrefs.GetString("Controls"));

            if (load == null || load.overrides.Count <= 0)
            {
                return;
            }

            foreach (InputActionMap map in controls.asset.actionMaps)
            {
                UnityEngine.InputSystem.Utilities.ReadOnlyArray <InputBinding> bindings = map.bindings;
                for (int i = 0; i < bindings.Count; i++)
                {
                    Binding overrideBinding = load.overrides.SingleOrDefault(x => x.id == bindings[i].id.ToString());
                    if (overrideBinding != null)
                    {
                        map.ApplyBindingOverride(i, new InputBinding {
                            overridePath = overrideBinding.path
                        });
                    }
                }
            }
        }