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); } }
void DrawActionMapInput(ActionMapInput map) { EditorGUI.BeginDisabledGroup(!map.active); GUIContent mapContent = new GUIContent(map.actionMap.name); GUILayout.BeginVertical(mapContent, Styles.mapStyle); { LabelField("Block Subsequent", map.blockSubsequent.ToString()); string schemeString = "-"; if (map.active && map.controlScheme != null) { schemeString = map.controlScheme.name; } LabelField("Current Control Scheme", schemeString); string devicesString = ""; if (map.active) { devicesString = string.Join(", ", map.GetCurrentlyUsedDevices().Select(e => e.name).ToArray()); } if (string.IsNullOrEmpty(devicesString)) { devicesString = "-"; } LabelField("Currently Used Devices", devicesString); } EditorGUILayout.EndVertical(); EditorGUI.EndDisabledGroup(); }