示例#1
0
        protected override void OnEnable()
        {
            base.OnEnable();

            controllerMappings       = serializedObject.FindProperty("controllerMappings");
            controllerMappingProfile = target as BaseMixedRealityControllerMappingProfile;
        }
示例#2
0
        private static Texture2D GetControllerTextureCached(BaseMixedRealityControllerMappingProfile mappingProfile, SupportedControllerType controllerType, Handedness handedness, bool scaled = false)
        {
            var key = new Tuple <SupportedControllerType, Handedness, bool>(controllerType, handedness, scaled);

            if (CachedTextures.TryGetValue(key, out var texture))
            {
                return(texture);
            }

            texture = GetControllerTextureInternal(mappingProfile, controllerType, handedness, scaled);
            CachedTextures.Add(key, texture);
            return(texture);
        }
示例#3
0
        private static Texture2D GetControllerTextureInternal(BaseMixedRealityControllerMappingProfile mappingProfile, SupportedControllerType controllerType, Handedness handedness, bool scaled)
        {
            if (mappingProfile != null &&
                mappingProfile.ControllerType == controllerType)
            {
                var texture = GetControllerTextureInternal(mappingProfile.TexturePath, handedness, scaled);

                if (texture != null)
                {
                    return(texture);
                }
            }

            return(GetControllerTextureInternal($"{MixedRealityEditorSettings.MixedRealityToolkit_RelativeFolderPath}/StandardAssets/Textures/Generic_controller", Handedness.None, scaled));
        }
示例#4
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (!MixedRealityInspectorUtility.CheckMixedRealityConfigured(false))
            {
                return;
            }

            if (!MixedRealityToolkit.Instance.ActiveProfile.IsInputSystemEnabled ||
                MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile == null)
            {
                return;
            }

            controllerMappings = serializedObject.FindProperty("controllerMappings");
            profile            = target as BaseMixedRealityControllerMappingProfile;
        }
示例#5
0
        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;
        }
示例#6
0
 /// <summary>
 /// Gets a scaled texture for the <see cref="SupportedControllerType"/> based on a list of the active <see cref="MixedRealityControllerMappingProfiles"/>.
 /// </summary>
 /// <param name="controllerType"></param>
 /// <param name="handedness"></param>
 /// <returns>The scaled texture for the controller type, if none found then a generic texture is returned.</returns>
 public static Texture2D GetControllerTextureScaled(BaseMixedRealityControllerMappingProfile mappingProfile, SupportedControllerType controllerType, Handedness handedness)
 {
     return(GetControllerTextureCached(mappingProfile, controllerType, handedness, true));
 }