예제 #1
0
 public void SetPlayerHandleMaps(PlayerHandle handle, bool initializeWithDevices = true, bool allowAssignUnassignedDevices = false)
 {
     handle.maps.Clear();
     for (int i = 0; i < actionMaps.Count; i++)
     {
         ActionMapSlot  actionMapSlot  = actionMaps[i];
         ActionMapInput actionMapInput = ActionMapInput.Create(actionMapSlot.actionMap);
         actionMapInput.active          = actionMapSlot.active;
         actionMapInput.blockSubsequent = actionMapSlot.blockSubsequent;
         if (initializeWithDevices)
         {
             actionMapInput.TryInitializeWithDevices(handle.GetApplicableDevices(allowAssignUnassignedDevices));
         }
         if (!handle.global && allowAssignUnassignedDevices)
         {
             List <InputDevice> usedDevices = actionMapInput.GetCurrentlyUsedDevices();
             for (int deviceIndex = 0; deviceIndex < usedDevices.Count; deviceIndex++)
             {
                 if (usedDevices[deviceIndex].GetAssignment() == null)
                 {
                     handle.AssignDevice(usedDevices[deviceIndex]);
                 }
             }
         }
         handle.maps.Add(actionMapInput);
     }
 }
예제 #2
0
        public bool CanInstantiateNewPlayerInputFromThis()
        {
            var unassignedDevices = new List <InputDevice>();

            for (int i = 0; i < InputSystem.devices.Count; i++)
            {
                if (InputSystem.devices[i].GetAssignment() == null)
                {
                    unassignedDevices.Add(InputSystem.devices[i]);
                }
            }

            for (int i = 0; i < actionMaps.Count; i++)
            {
                ActionMapSlot actionMapSlot = actionMaps[i];
                if (!actionMapSlot.actionMap.CanInitializeInstanceWithDevices(unassignedDevices))
                {
                    return(false);
                }
            }
            return(true);
        }