private void OnFocus() { if (window.IsNull()) { Close(); } currentControllerTexture = ControllerMappingLibrary.GetControllerTexture(controllerDataProviderProfile); }
private void OnFocus() { currentControllerTexture = ControllerMappingLibrary.GetControllerTexture(currentControllerMapping.ControllerType, currentControllerMapping.Handedness); #region Interaction Constraint Setup actionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Select(action => (int)action.Id) .Prepend(0).ToArray(); axisLabels = ControllerMappingLibrary.UnityInputManagerAxes .Select(axis => new GUIContent(axis.Name)) .Prepend(new GUIContent("None")).ToArray(); actionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.None) .Select(action => (int)action.Id) .Prepend(0).ToArray(); actionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.None) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); rawActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Raw) .Select(action => (int)action.Id) .Prepend(0).ToArray(); rawActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Raw) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); digitalActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Digital) .Select(action => (int)action.Id) .Prepend(0).ToArray(); digitalActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Digital) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); singleAxisActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SingleAxis) .Select(action => (int)action.Id) .Prepend(0).ToArray(); singleAxisActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SingleAxis) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); dualAxisActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.DualAxis) .Select(action => (int)action.Id).Prepend(0).ToArray(); dualAxisActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.DualAxis) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); threeDofPositionActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofPosition) .Select(action => (int)action.Id) .Prepend(0).ToArray(); threeDofPositionActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofPosition) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); threeDofRotationActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofRotation) .Select(action => (int)action.Id) .Prepend(0).ToArray(); threeDofRotationActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofRotation) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); sixDofActionIds = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SixDof) .Select(action => (int)action.Id) .Prepend(0).ToArray(); sixDofActionLabels = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SixDof) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); #endregion Interaction Constraint Setup }
/// <summary> /// Shows the controller pop out window using the provided profile and serialized interaction mapping property /// </summary> /// <param name="profile"></param> /// <param name="interactionMappingProfiles"></param> public static void Show(MixedRealityControllerMappingProfile profile, SerializedProperty interactionMappingProfiles) { var handednessTitleText = profile.Handedness != Handedness.None ? $"{profile.Handedness} Hand " : string.Empty; if (window != null) { window.Close(); } if (profile.ControllerType?.Type == null) { Debug.LogError($"No controller type defined for {profile.name}"); return; } window = (ControllerPopupWindow)CreateInstance(typeof(ControllerPopupWindow)); window.currentControllerName = profile.ControllerType?.Type?.Name; window.currentControllerName = profile.ControllerType?.Type?.Name; window.titleContent = new GUIContent($"{window.currentControllerName} {handednessTitleText}Input Action Assignment"); window.controllerDataProviderProfile = profile; window.currentInteractionProfiles = interactionMappingProfiles; window.currentControllerTexture = ControllerMappingLibrary.GetControllerTexture(profile); isMouseInRects = new bool[interactionMappingProfiles.arraySize]; var asset = AssetDatabase.LoadAssetAtPath <TextAsset>(EditorWindowOptionsPath); if (asset.IsNull()) { var empty = new ControllerInputActionOptions { Controllers = new List <ControllerInputActionOption> { new ControllerInputActionOption { Controller = null, Handedness = Handedness.None, InputLabelPositions = new[] { new Vector2(0, 0) }, IsLabelFlipped = new [] { false } } } }; File.WriteAllText(Path.GetFullPath(EditorWindowOptionsPath), JsonUtility.ToJson(empty, true)); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } else { controllerInputActionOptions = JsonUtility.FromJson <ControllerInputActionOptions>(asset.text); // if the controller option doesn't exist, then make a new one. if (!controllerInputActionOptions.Controllers.Any(option => option.Controller == window.currentControllerName && option.Handedness == window.Handedness)) { var newOption = new ControllerInputActionOption { Controller = window.currentControllerName, Handedness = window.Handedness, InputLabelPositions = new Vector2[interactionMappingProfiles.arraySize], IsLabelFlipped = new bool[interactionMappingProfiles.arraySize] }; controllerInputActionOptions.Controllers.Add(newOption); } window.currentControllerOption = controllerInputActionOptions.Controllers.FirstOrDefault(option => option.Controller == window.currentControllerName && option.Handedness == window.Handedness); if (window.currentControllerOption.IsLabelFlipped == null) { window.currentControllerOption.IsLabelFlipped = new bool[interactionMappingProfiles.arraySize]; } if (window.currentControllerOption.InputLabelPositions == null) { window.currentControllerOption.InputLabelPositions = new Vector2[interactionMappingProfiles.arraySize]; } } var windowSize = new Vector2(window.IsCustomController || window.currentControllerTexture == null ? 896f : 768f, 512f); window.ShowUtility(); window.maxSize = windowSize; window.minSize = windowSize; window.CenterOnMainWin(); }
public static void Show(BaseMixedRealityControllerMappingProfile profile, SupportedControllerType controllerType, SerializedProperty interactionsList, Handedness handedness = Handedness.None, bool isLocked = false) { var handednessTitleText = handedness != Handedness.None ? $"{handedness} Hand " : string.Empty; if (window != null) { window.Close(); } window = (ControllerPopupWindow)CreateInstance(typeof(ControllerPopupWindow)); window.titleContent = new GUIContent($"{controllerType} {handednessTitleText}Input Action Assignment"); window.isLocked = isLocked; window.mappingProfile = profile; window.currentHandedness = handedness; window.currentControllerType = controllerType; window.currentInteractionList = interactionsList; window.currentControllerTexture = ControllerMappingLibrary.GetControllerTexture(profile, controllerType, handedness); isMouseInRects = new bool[interactionsList.arraySize]; var asset = AssetDatabase.LoadAssetAtPath <TextAsset>(EditorWindowOptionsPath); if (asset == null) { var empty = new ControllerInputActionOptions { Controllers = new List <ControllerInputActionOption> { new ControllerInputActionOption { Controller = SupportedControllerType.None, Handedness = Handedness.None, InputLabelPositions = new[] { new Vector2(0, 0) }, IsLabelFlipped = new [] { false } } } }; File.WriteAllText(Path.GetFullPath(EditorWindowOptionsPath), JsonUtility.ToJson(empty, true)); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } else { controllerInputActionOptions = JsonUtility.FromJson <ControllerInputActionOptions>(asset.text); if (controllerInputActionOptions.Controllers.Any(option => option.Controller == controllerType && option.Handedness == handedness)) { window.currentControllerOption = controllerInputActionOptions.Controllers.FirstOrDefault(option => option.Controller == controllerType && option.Handedness == handedness); if (window.currentControllerOption.IsLabelFlipped == null) { window.currentControllerOption.IsLabelFlipped = new bool[interactionsList.arraySize]; } if (window.currentControllerOption.InputLabelPositions == null) { window.currentControllerOption.InputLabelPositions = new Vector2[interactionsList.arraySize]; } } } var windowSize = new Vector2(window.IsCustomController || window.currentControllerTexture == null ? 896f : 768f, 512f); window.ShowUtility(); window.maxSize = windowSize; window.minSize = windowSize; window.CenterOnMainWin(); defaultLabelWidth = EditorGUIUtility.labelWidth; defaultFieldWidth = EditorGUIUtility.fieldWidth; }
private void OnFocus() { if (window == null) { Close(); } currentControllerTexture = ControllerMappingLibrary.GetControllerTexture(mappingProfile, currentControllerType, currentHandedness); inputSystemProfile = mappingProfile.ParentProfile.ParentProfile as MixedRealityInputSystemProfile; if (inputSystemProfile == null) { Debug.LogWarning("No Input System Profile found. Be sure to assign this mapping profile to an input system."); return; } #region Interaction Constraint Setup actionIds = inputSystemProfile.InputActionsProfile.InputActions .Select(action => (int)action.Id) .Prepend(0).ToArray(); axisLabels = ControllerMappingLibrary.UnityInputManagerAxes .Select(axis => new GUIContent(axis.Name)) .Prepend(new GUIContent(ControllerMappingLibrary.MouseScroll)) .Prepend(new GUIContent(ControllerMappingLibrary.MouseY)) .Prepend(new GUIContent(ControllerMappingLibrary.MouseX)) .Prepend(new GUIContent(ControllerMappingLibrary.Vertical)) .Prepend(new GUIContent(ControllerMappingLibrary.Horizontal)) .Prepend(new GUIContent("None")).ToArray(); actionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.None) .Select(action => (int)action.Id) .Prepend(0).ToArray(); actionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.None) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); rawActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Raw) .Select(action => (int)action.Id) .Prepend(0).ToArray(); rawActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Raw) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); digitalActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Digital) .Select(action => (int)action.Id) .Prepend(0).ToArray(); digitalActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.Digital) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); singleAxisActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SingleAxis) .Select(action => (int)action.Id) .Prepend(0).ToArray(); singleAxisActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SingleAxis) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); dualAxisActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.DualAxis) .Select(action => (int)action.Id).Prepend(0).ToArray(); dualAxisActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.DualAxis) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); threeDofPositionActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofPosition) .Select(action => (int)action.Id) .Prepend(0).ToArray(); threeDofPositionActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofPosition) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); threeDofRotationActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofRotation) .Select(action => (int)action.Id) .Prepend(0).ToArray(); threeDofRotationActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.ThreeDofRotation) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); sixDofActionIds = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SixDof) .Select(action => (int)action.Id) .Prepend(0).ToArray(); sixDofActionLabels = inputSystemProfile.InputActionsProfile.InputActions .Where(inputAction => inputAction.AxisConstraint == AxisType.SixDof) .Select(inputAction => new GUIContent(inputAction.Description)) .Prepend(new GUIContent("None")).ToArray(); #endregion Interaction Constraint Setup }