Commit 29de0c28 authored by BlackAngle233's avatar BlackAngle233
Browse files

10.19 learned

parent 912976bb
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
[assembly: InternalsVisibleTo("Microsoft.MixedReality.Toolkit.Editor.Inspectors")]
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Used to define a controller or other input device's physical buttons, and other attributes.
/// </summary>
[Serializable]
public struct MixedRealityControllerMapping
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="controllerType">Controller Type to instantiate at runtime.</param>
/// <param name="handedness">The designated hand that the device is managing.</param>
public MixedRealityControllerMapping(Type controllerType, Handedness handedness = Handedness.None) : this()
{
this.controllerType = new SystemType(controllerType);
this.handedness = handedness;
interactions = null;
}
/// <summary>
/// Description of the Device.
/// </summary>
public string Description
{
get
{
string controllerName = "Unknown";
if (controllerType.Type != null)
{
var attr = MixedRealityControllerAttribute.Find(controllerType);
if (attr != null)
{
controllerName = attr.SupportedControllerType.ToString().ToProperCase();
}
}
string handednessText = string.Empty;
switch (handedness)
{
case Handedness.Left:
case Handedness.Right:
handednessText = $"{handedness} Hand ";
// Avoid multiple occurrences of "Hand":
controllerName = controllerName.Replace("Hand", "").Trim();
break;
}
return $"{controllerName} {handednessText}Controller";
}
}
[SerializeField]
[Tooltip("Controller type to instantiate at runtime.")]
[Implements(typeof(IMixedRealityController), TypeGrouping.ByNamespaceFlat)]
private SystemType controllerType;
/// <summary>
/// Controller Type to instantiate at runtime.
/// </summary>
public SystemType ControllerType => controllerType;
public SupportedControllerType SupportedControllerType
{
get
{
if (controllerType.Type != null)
{
var attr = MixedRealityControllerAttribute.Find(controllerType);
if (attr != null)
{
return attr.SupportedControllerType;
}
}
return 0;
}
}
[SerializeField]
[Tooltip("The designated hand that the device is managing.")]
private Handedness handedness;
/// <summary>
/// The designated hand that the device is managing.
/// </summary>
public Handedness Handedness => handedness;
/// <summary>
/// Is this controller mapping using custom interactions?
/// </summary>
public bool HasCustomInteractionMappings
{
get
{
if (controllerType.Type != null)
{
var attr = MixedRealityControllerAttribute.Find(controllerType);
if (attr != null)
{
return attr.Flags.HasFlag(MixedRealityControllerConfigurationFlags.UseCustomInteractionMappings);
}
}
return false;
}
}
[SerializeField]
[Tooltip("Details the list of available buttons / interactions available from the device.")]
private MixedRealityInteractionMapping[] interactions;
/// <summary>
/// Details the list of available buttons / interactions available from the device.
/// </summary>
public MixedRealityInteractionMapping[] Interactions => interactions;
/// <summary>
/// Sets the default interaction mapping based on the current controller type.
/// </summary>
internal void SetDefaultInteractionMapping(bool overwrite = false)
{
if (interactions == null || interactions.Length == 0 || overwrite)
{
MixedRealityInteractionMapping[] defaultMappings = GetDefaultInteractionMappings();
if (defaultMappings != null)
{
interactions = defaultMappings;
}
}
}
internal bool UpdateInteractionSettingsFromDefault()
{
if (interactions == null || interactions.Length == 0) { return false; }
MixedRealityInteractionMapping[] newDefaultInteractions = GetDefaultInteractionMappings();
if (newDefaultInteractions == null)
{
return false;
}
if (interactions.Length != newDefaultInteractions.Length)
{
interactions = CreateNewMatchedMapping(interactions, newDefaultInteractions);
return true;
}
bool updatedMappings = false;
for (int i = 0; i < newDefaultInteractions.Length; i++)
{
MixedRealityInteractionMapping currentMapping = interactions[i];
MixedRealityInteractionMapping currentDefaultMapping = newDefaultInteractions[i];
if (!Equals(currentMapping, currentDefaultMapping))
{
interactions[i] = new MixedRealityInteractionMapping(currentDefaultMapping)
{
MixedRealityInputAction = currentMapping.MixedRealityInputAction
};
updatedMappings = true;
}
}
return updatedMappings;
}
private MixedRealityInteractionMapping[] CreateNewMatchedMapping(MixedRealityInteractionMapping[] interactions, MixedRealityInteractionMapping[] newDefaultInteractions)
{
MixedRealityInteractionMapping[] newDefaultMapping = new MixedRealityInteractionMapping[newDefaultInteractions.Length];
for (int i = 0; i < newDefaultInteractions.Length; i++)
{
for (int j = 0; j < interactions.Length; j++)
{
if (Equals(interactions[j], newDefaultInteractions[i]))
{
newDefaultMapping[i] = new MixedRealityInteractionMapping(newDefaultInteractions[i])
{
MixedRealityInputAction = interactions[j].MixedRealityInputAction
};
break;
}
}
if (newDefaultMapping[i] == null)
{
newDefaultMapping[i] = new MixedRealityInteractionMapping(newDefaultInteractions[i]);
}
}
return newDefaultMapping;
}
private bool Equals(MixedRealityInteractionMapping a, MixedRealityInteractionMapping b)
{
return !(a.Description != b.Description ||
a.AxisType != b.AxisType ||
a.InputType != b.InputType ||
a.KeyCode != b.KeyCode ||
a.AxisCodeX != b.AxisCodeX ||
a.AxisCodeY != b.AxisCodeY ||
a.InvertXAxis != b.InvertXAxis ||
a.InvertYAxis != b.InvertYAxis);
}
private MixedRealityInteractionMapping[] GetDefaultInteractionMappings()
{
if (Activator.CreateInstance(controllerType, TrackingState.NotTracked, handedness, null, null) is BaseController detectedController)
{
switch (handedness)
{
case Handedness.Left:
return detectedController.DefaultLeftHandedInteractions ?? detectedController.DefaultInteractions;
case Handedness.Right:
return detectedController.DefaultRightHandedInteractions ?? detectedController.DefaultInteractions;
default:
return detectedController.DefaultInteractions;
}
}
return null;
}
/// <summary>
/// Synchronizes the input actions of the same physical controller of a different concrete type.
/// </summary>
internal void SynchronizeInputActions(MixedRealityInteractionMapping[] otherControllerMapping)
{
if (otherControllerMapping.Length != interactions.Length)
{
throw new ArgumentException($"otherControllerMapping length {otherControllerMapping.Length} does not match this length {interactions.Length}.");
}
for (int i = 0; i < interactions.Length; i++)
{
interactions[i].MixedRealityInputAction = otherControllerMapping[i].MixedRealityInputAction;
}
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
#if UNITY_EDITOR
using UnityEditor;
#endif // UNITY_EDITOR
using UnityEngine;
using UnityEngine.Serialization;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// New controller types can be registered by adding the MixedRealityControllerAttribute to
/// the controller class.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Controller Mapping Profile", fileName = "MixedRealityControllerMappingProfile", order = (int)CreateProfileMenuItemIndices.ControllerMapping)]
public class MixedRealityControllerMappingProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("The list of controller mappings your application can use.")]
[FormerlySerializedAs("mixedRealityControllerMappingProfiles")]
private MixedRealityControllerMapping[] mixedRealityControllerMappings = Array.Empty<MixedRealityControllerMapping>();
/// <summary>
/// The list of controller mappings your application can use.
/// </summary>
public MixedRealityControllerMapping[] MixedRealityControllerMappings => mixedRealityControllerMappings;
[Obsolete("MixedRealityControllerMappingProfiles is obsolete. Please use MixedRealityControllerMappings.")]
public MixedRealityControllerMapping[] MixedRealityControllerMappingProfiles => mixedRealityControllerMappings;
#if UNITY_EDITOR
[MenuItem("Mixed Reality Toolkit/Utilities/Update/Controller Mapping Profiles")]
private static void UpdateAllControllerMappingProfiles()
{
string[] guids = AssetDatabase.FindAssets("t:MixedRealityControllerMappingProfile");
string[] assetPaths = new string[guids.Length];
for (int i = 0; i < guids.Length; i++)
{
string guid = guids[i];
assetPaths[i] = AssetDatabase.GUIDToAssetPath(guid);
MixedRealityControllerMappingProfile asset = AssetDatabase.LoadAssetAtPath(assetPaths[i], typeof(MixedRealityControllerMappingProfile)) as MixedRealityControllerMappingProfile;
List<MixedRealityControllerMapping> updatedMappings = new List<MixedRealityControllerMapping>();
foreach (MixedRealityControllerMapping mapping in asset.MixedRealityControllerMappings)
{
if (mapping.ControllerType.Type == null)
{
continue;
}
if (!mapping.HasCustomInteractionMappings)
{
mapping.UpdateInteractionSettingsFromDefault();
}
updatedMappings.Add(mapping);
}
asset.mixedRealityControllerMappings = updatedMappings.ToArray();
}
AssetDatabase.ForceReserializeAssets(assetPaths);
}
private static Type[] controllerMappingTypes;
public static Type[] ControllerMappingTypes { get { CollectControllerTypes(); return controllerMappingTypes; } }
public static Type[] CustomControllerMappingTypes { get => (from type in ControllerMappingTypes where UsesCustomInteractionMapping(type) select type).ToArray(); }
private static void CollectControllerTypes()
{
if (controllerMappingTypes == null)
{
List<Type> controllerTypes = new List<Type>();
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
IEnumerable<Type> types = null;
try
{
types = assembly.ExportedTypes;
}
catch (NotSupportedException)
{
// assembly.ExportedTypes may not be supported.
}
catch (ReflectionTypeLoadException e)
{
// Not all assemblies may load correctly, but even upon encountering error
// some subset may have loaded in.
if (e.Types != null)
{
List<Type> loadedTypes = new List<Type>();
foreach (Type type in e.Types)
{
// According to API docs, this array may contain null values
// so they must be filtered out here.
if (type != null)
{
loadedTypes.Add(type);
}
}
types = loadedTypes;
}
}
if (types != null)
{
foreach (Type type in types)
{
if (type.IsSubclassOf(typeof(BaseController)) &&
MixedRealityControllerAttribute.Find(type) != null)
{
controllerTypes.Add(type);
}
}
}
}
controllerMappingTypes = controllerTypes.ToArray();
}
}
public void Awake()
{
AddMappings();
SortMappings();
}
private void AddMappings()
{
foreach (var controllerType in ControllerMappingTypes)
{
// Don't auto-add custom mappings when migrating, these can be removed by the user in the inspector.
if (UsesCustomInteractionMapping(controllerType))
{
continue;
}
foreach (Handedness handedness in GetSupportedHandedness(controllerType))
{
// Try to find index of mapping in asset.
int idx = Array.FindIndex(MixedRealityControllerMappings, 0, MixedRealityControllerMappings.Length,
profile => profile.ControllerType.Type == controllerType && profile.Handedness == handedness);
if (idx < 0)
{
var newMapping = new MixedRealityControllerMapping(controllerType, handedness);
newMapping.SetDefaultInteractionMapping(overwrite: false);
// Re-use existing mapping with the same supported controller type.
foreach (var otherMapping in mixedRealityControllerMappings)
{
if (otherMapping.SupportedControllerType == newMapping.SupportedControllerType &&
otherMapping.Handedness == newMapping.Handedness)
{
try
{
newMapping.SynchronizeInputActions(otherMapping.Interactions);
}
catch (ArgumentException e)
{
Debug.LogError($"Controller mappings between {newMapping.Description} and {otherMapping.Description} do not match. Error message: {e.Message}");
}
break;
}
}
idx = mixedRealityControllerMappings.Length;
Array.Resize(ref mixedRealityControllerMappings, idx + 1);
mixedRealityControllerMappings[idx] = newMapping;
}
else
{
mixedRealityControllerMappings[idx].UpdateInteractionSettingsFromDefault();
}
}
}
}
private void SortMappings()
{
Array.Sort(mixedRealityControllerMappings, (profile1, profile2) =>
{
bool isOptional1 = (profile1.ControllerType.Type == null || profile1.HasCustomInteractionMappings);
bool isOptional2 = (profile2.ControllerType.Type == null || profile2.HasCustomInteractionMappings);
if (!isOptional1 && !isOptional2)
{
int idx1 = Array.FindIndex(ControllerMappingTypes, type => type == profile1.ControllerType.Type);
int idx2 = Array.FindIndex(ControllerMappingTypes, type => type == profile2.ControllerType.Type);
if (idx1 == idx2)
{
idx1 = (int)profile1.Handedness;
idx2 = (int)profile2.Handedness;
}
return Math.Sign(idx1 - idx2);
}
if (isOptional1 && isOptional2)
{
return 0;
}
return isOptional1 ? 1 : -1; // Put custom mappings at the end. These can be added / removed in the inspector.
});
}
#endif // UNITY_EDITOR
private static bool UsesCustomInteractionMapping(Type controllerType)
{
var attribute = MixedRealityControllerAttribute.Find(controllerType);
return attribute != null ? attribute.Flags.HasFlag(MixedRealityControllerConfigurationFlags.UseCustomInteractionMappings) : false;
}
private static Handedness[] GetSupportedHandedness(Type controllerType)
{
var attribute = MixedRealityControllerAttribute.Find(controllerType);
return attribute != null ? attribute.SupportedHandedness : Array.Empty<Handedness>();
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Profile that determines relevant overrides and properties for controller visualization
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Controller Visualization Profile", fileName = "MixedRealityControllerVisualizationProfile", order = (int)CreateProfileMenuItemIndices.ControllerVisualization)]
[MixedRealityServiceProfile(typeof(IMixedRealityControllerVisualizer))]
public class MixedRealityControllerVisualizationProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("Enable and configure the controller rendering of the Motion Controllers on Startup.")]
private bool renderMotionControllers = false;
/// <summary>
/// Enable and configure the controller rendering of the Motion Controllers on Startup.
/// </summary>
public bool RenderMotionControllers
{
get => renderMotionControllers;
private set => renderMotionControllers = value;
}
[SerializeField]
[Implements(typeof(IMixedRealityControllerVisualizer), TypeGrouping.ByNamespaceFlat)]
[Tooltip("The default controller visualization type. This value is used as a fallback if no controller definition exists with a custom visualization type.")]
private SystemType defaultControllerVisualizationType;
/// <summary>
/// The default controller visualization type. This value is used as a fallback if no controller definition exists with a custom visualization type.
/// </summary>
public SystemType DefaultControllerVisualizationType
{
get => defaultControllerVisualizationType;
private set => defaultControllerVisualizationType = value;
}
[SerializeField]
[Tooltip("Check to obtain controller models from the platform SDK. If left unchecked, the global models will be used. Note: this value is overridden by controller definitions.")]
private bool useDefaultModels = false;
/// <summary>
/// Check to obtain controller models from the platform SDK. If left unchecked, the global models will be used. Note: this value is overridden by controller definitions.
/// </summary>
public bool UseDefaultModels
{
get => useDefaultModels;
private set => useDefaultModels = value;
}
[SerializeField]
[Tooltip("The default controller model material when loading platform SDK controller models. This value is used as a fallback if no controller definition exists with a custom material type.")]
private Material defaultControllerModelMaterial;
/// <summary>
/// The default controller model material when loading platform SDK controller models. This value is used as a fallback if no controller definition exists with a custom material type.
/// </summary>
public Material DefaultControllerModelMaterial
{
get => defaultControllerModelMaterial;
private set => defaultControllerModelMaterial = value;
}
[SerializeField]
[Tooltip("Override Left Controller Model.")]
private GameObject globalLeftControllerModel;
/// <summary>
/// The Default controller model when there is no specific controller model for the Left hand or when no hand is specified (Handedness = none)
/// </summary>
/// <remarks>
/// If the default model for the left hand controller can not be found, the controller will fall back and use this for visualization.
/// </remarks>
public GameObject GlobalLeftHandModel
{
get => globalLeftControllerModel;
private set => globalLeftControllerModel = value;
}
[SerializeField]
[Tooltip("Override Right Controller Model.\nNote: If the default model is not found, the fallback is the global right hand model.")]
private GameObject globalRightControllerModel;
/// <summary>
/// The Default controller model when there is no specific controller model for the Right hand.
/// </summary>
/// <remarks>
/// If the default model for the right hand controller can not be found, the controller will fall back and use this for visualization.
/// </remarks>
public GameObject GlobalRightHandModel
{
get => globalRightControllerModel;
private set => globalRightControllerModel = value;
}
[SerializeField]
[Tooltip("Override Left Hand Visualizer.")]
private GameObject globalLeftHandVisualizer;
/// <summary>
/// The Default controller model when there is no specific controller model for the Left hand or when no hand is specified (Handedness = none)
/// </summary>
/// <remarks>
/// If the default model for the left hand controller can not be found, the controller will fall back and use this for visualization.
/// </remarks>
public GameObject GlobalLeftHandVisualizer
{
get => globalLeftHandVisualizer;
private set => globalLeftHandVisualizer = value;
}
[SerializeField]
[Tooltip("Override Right Controller Model.\nNote: If the default model is not found, the fallback is the global right hand model.")]
private GameObject globalRightHandVisualizer;
/// <summary>
/// The Default hand model when there is no specific hand model for the Right hand.
/// </summary>
/// <remarks>
/// If the default model for the right hand can not be found, the hand will fall back and use this for visualization.
/// </remarks>
public GameObject GlobalRightHandVisualizer
{
get => globalRightHandVisualizer;
private set => globalRightHandVisualizer = value;
}
[SerializeField]
private MixedRealityControllerVisualizationSetting[] controllerVisualizationSettings = Array.Empty<MixedRealityControllerVisualizationSetting>();
/// <summary>
/// The current list of controller visualization settings.
/// </summary>
public MixedRealityControllerVisualizationSetting[] ControllerVisualizationSettings => controllerVisualizationSettings;
/// <summary>
/// Gets the override model for a specific controller type and hand
/// </summary>
/// <param name="controllerType">The type of controller to query for</param>
/// <param name="hand">The specific hand assigned to the controller</param>
public GameObject GetControllerModelOverride(Type controllerType, Handedness hand)
{
for (int i = 0; i < controllerVisualizationSettings.Length; i++)
{
if (SettingContainsParameters(controllerVisualizationSettings[i], controllerType, hand))
{
return controllerVisualizationSettings[i].OverrideControllerModel;
}
}
return null;
}
/// <summary>
/// Gets the override <see cref="IMixedRealityControllerVisualizer"/> type for a specific controller type and hand.
/// If the requested controller type is not defined, DefaultControllerVisualizationType is returned.
/// </summary>
/// <param name="controllerType">The type of controller to query for</param>
/// <param name="hand">The specific hand assigned to the controller</param>
public SystemType GetControllerVisualizationTypeOverride(Type controllerType, Handedness hand)
{
for (int i = 0; i < controllerVisualizationSettings.Length; i++)
{
if (SettingContainsParameters(controllerVisualizationSettings[i], controllerType, hand))
{
return controllerVisualizationSettings[i].ControllerVisualizationType;
}
}
return defaultControllerVisualizationType;
}
/// <summary>
/// Gets the UseDefaultModels value defined for the specified controller definition.
/// If the requested controller type is not defined, the default UseDefaultModels is returned.
/// </summary>
/// <param name="controllerType">The type of controller to query for</param>
/// <param name="hand">The specific hand assigned to the controller</param>
public bool GetUseDefaultModelsOverride(Type controllerType, Handedness hand)
{
for (int i = 0; i < controllerVisualizationSettings.Length; i++)
{
if (SettingContainsParameters(controllerVisualizationSettings[i], controllerType, hand))
{
return controllerVisualizationSettings[i].UseDefaultModel;
}
}
return useDefaultModels;
}
/// <summary>
/// Gets the DefaultModelMaterial value defined for the specified controller definition.
/// If the requested controller type is not defined, the global DefaultControllerModelMaterial is returned.
/// </summary>
/// <param name="controllerType">The type of controller to query for</param>
/// <param name="hand">The specific hand assigned to the controller</param>
public Material GetDefaultControllerModelMaterialOverride(Type controllerType, Handedness hand)
{
for (int i = 0; i < controllerVisualizationSettings.Length; i++)
{
if (SettingContainsParameters(controllerVisualizationSettings[i], controllerType, hand))
{
return controllerVisualizationSettings[i].DefaultModelMaterial;
}
}
return defaultControllerModelMaterial;
}
private bool SettingContainsParameters(MixedRealityControllerVisualizationSetting setting, Type controllerType, Handedness hand)
{
return setting.ControllerType != null &&
setting.ControllerType.Type == controllerType &&
setting.Handedness.HasFlag(hand) && setting.Handedness != Handedness.None;
}
}
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Used to define a controller's visualization settings.
/// </summary>
[Serializable]
public struct MixedRealityControllerVisualizationSetting
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="description">Description of the Device.</param>
/// <param name="controllerType">Controller Type to instantiate at runtime.</param>
/// <param name="handedness">The designated hand that the device is managing.</param>
/// <param name="overrideModel">The controller model prefab to be rendered.</param>
public MixedRealityControllerVisualizationSetting(string description, Type controllerType, Handedness handedness = Handedness.None, GameObject overrideModel = null) : this()
{
this.description = description;
this.controllerType = new SystemType(controllerType);
this.handedness = handedness;
this.overrideModel = overrideModel;
useDefaultModel = false;
defaultModelMaterial = null;
}
[SerializeField]
private string description;
/// <summary>
/// Description of the Device.
/// </summary>
public string Description => description;
[SerializeField]
[Tooltip("Controller type to instantiate at runtime.")]
[Implements(typeof(IMixedRealityController), TypeGrouping.ByNamespaceFlat)]
private SystemType controllerType;
/// <summary>
/// Controller Type to instantiate at runtime.
/// </summary>
public SystemType ControllerType => controllerType;
[SerializeField]
[Tooltip("The designated hand that the device is managing.")]
private Handedness handedness;
/// <summary>
/// The designated hand that the device is managing.
/// </summary>
public Handedness Handedness => handedness;
[SerializeField]
[Tooltip("Check to obtain controller models from the platform SDK. If left unchecked, the global models will be used.")]
private bool useDefaultModel;
/// <summary>
/// Check to obtain controller models from the platform SDK. If left unchecked, the global models will be used.
/// </summary>
public bool UseDefaultModel => useDefaultModel;
[SerializeField]
[Tooltip("The default controller model material when loading platform SDK controller models.")]
private Material defaultModelMaterial;
/// <summary>
/// The default controller model material when loading platform SDK controller models. This value is used as a fallback if no controller definition exists with a custom material type.
/// </summary>
public Material DefaultModelMaterial => defaultModelMaterial;
[SerializeField]
[Tooltip("An override model to display for this specific controller.")]
private GameObject overrideModel;
/// <summary>
/// The controller model prefab to be rendered.
/// </summary>
public GameObject OverrideControllerModel => overrideModel;
[SerializeField]
[Tooltip("The concrete Controller Visualizer component to use on the rendered controller model.")]
[Implements(typeof(IMixedRealityControllerVisualizer), TypeGrouping.ByNamespaceFlat)]
private SystemType controllerVisualizationType;
/// <summary>
/// The concrete Controller Visualizer component to use on the rendered controller model
/// </summary>
public SystemType ControllerVisualizationType
{
get => controllerVisualizationType;
private set => controllerVisualizationType = value;
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Input;
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Eye Tracking Profile", fileName = "MixedRealityEyeTrackingProfile", order = (int)CreateProfileMenuItemIndices.EyeTracking)]
[MixedRealityServiceProfile(requiredTypes: new Type[] { typeof(IMixedRealityEyeGazeDataProvider), typeof(IMixedRealityEyeSaccadeProvider) })]
public class MixedRealityEyeTrackingProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("Use smoothed eye tracking signal.")]
private bool smoothEyeTracking = false;
/// <summary>
/// Use smoothed eye tracking signal.
/// </summary>
public bool SmoothEyeTracking => smoothEyeTracking;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Hand Tracking Profile", fileName = "MixedRealityHandTrackingProfile", order = (int)CreateProfileMenuItemIndices.HandTracking)]
[HelpURL("https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/HandTracking.html")]
public class MixedRealityHandTrackingProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("The joint prefab to use.")]
private GameObject jointPrefab = null;
[SerializeField]
[Tooltip("The joint prefab to use for palm.")]
private GameObject palmPrefab = null;
[SerializeField]
[Tooltip("The joint prefab to use for the index tip (point of interaction.")]
private GameObject fingertipPrefab = null;
/// <summary>
/// The joint prefab to use.
/// </summary>
public GameObject JointPrefab => jointPrefab;
/// <summary>
/// The joint prefab to use for palm
/// </summary>
public GameObject PalmJointPrefab => palmPrefab;
/// <summary>
/// The joint prefab to use for finger tip
/// </summary>
public GameObject FingerTipPrefab => fingertipPrefab;
[SerializeField]
[Tooltip("If this is not null and hand system supports hand meshes, use this mesh to render hand mesh.")]
private GameObject handMeshPrefab = null;
/// <summary>
/// The hand mesh prefab to use to render the hand
/// </summary>
public GameObject HandMeshPrefab => handMeshPrefab;
/// <summary>
/// The hand mesh visualization enable/disable state of the current application mode.
/// </summary>
/// <remarks>
/// If this property is called while in-editor, this will only affect the in-editor settings
/// (i.e. the SupportedApplicationModes.Editor flag of HandMeshVisualizationModes).
/// If this property is called while in-player, this will only affect the in-player settings
/// (i.e. the SupportedApplicationModes.Player flag of HandMeshVisualizationModes).
/// </remarks>
public bool EnableHandMeshVisualization
{
get => IsSupportedApplicationMode(handMeshVisualizationModes);
set => handMeshVisualizationModes = UpdateSupportedApplicationMode(value, handMeshVisualizationModes);
}
/// <summary>
/// The hand joint visualization enable/disable state of the current application mode.
/// </summary>
/// <remarks>
/// If this property is called while in-editor, this will only affect the in-editor settings
/// (i.e. the SupportedApplicationModes.Editor flag of HandJointVisualizationModes).
/// If this property is called while in-player, this will only affect the in-player settings
/// (i.e. the SupportedApplicationModes.Player flag of HandJointVisualizationModes).
/// </remarks>
public bool EnableHandJointVisualization
{
get => IsSupportedApplicationMode(handJointVisualizationModes);
set => handJointVisualizationModes = UpdateSupportedApplicationMode(value, handJointVisualizationModes);
}
[EnumFlags]
[SerializeField]
[Tooltip("The application modes in which hand mesh visualizations will display. " +
"Will only show if the system provides hand mesh data. Note: this could reduce performance")]
private SupportedApplicationModes handMeshVisualizationModes = 0;
public SupportedApplicationModes HandMeshVisualizationModes
{
get => handMeshVisualizationModes;
set => handMeshVisualizationModes = value;
}
[EnumFlags]
[SerializeField]
[Tooltip("The application modes in which hand joint visualizations will display. " +
"Will only show if the system provides joint data. Note: this could reduce performance")]
private SupportedApplicationModes handJointVisualizationModes = 0;
public SupportedApplicationModes HandJointVisualizationModes
{
get => handJointVisualizationModes;
set => handJointVisualizationModes = value;
}
/// <summary>
/// Returns true if the modes specified by the specified SupportedApplicationModes matches
/// the current mode that the code is running in.
/// </summary>
/// <remarks>
/// For example, if the code is currently running in editor mode (for testing in-editor
/// simulation), this would return true if modes contained the SupportedApplicationModes.Editor
/// bit.
/// </remarks>
private static bool IsSupportedApplicationMode(SupportedApplicationModes modes)
{
#if UNITY_EDITOR
return (modes & SupportedApplicationModes.Editor) != 0;
#else // !UNITY_EDITOR
return (modes & SupportedApplicationModes.Player) != 0;
#endif
}
/// <summary>
/// Updates the given SupportedApplicationModes by setting the bit associated with the
/// currently active application mode.
/// </summary>
/// <remarks>
/// For example, if the code is currently running in editor mode (for testing in-editor
/// simulation), and modes is currently SupportedApplicationModes.Player | SupportedApplicationModes.Editor
/// and enabled is 'false', this would return SupportedApplicationModes.Player.
/// </remarks>
private static SupportedApplicationModes UpdateSupportedApplicationMode(bool enabled, SupportedApplicationModes modes)
{
#if UNITY_EDITOR
var bitValue = enabled ? SupportedApplicationModes.Editor : 0;
return (modes & ~SupportedApplicationModes.Editor) | bitValue;
#else // !UNITY_EDITOR
var bitValue = enabled ? SupportedApplicationModes.Player : 0;
return (modes & ~SupportedApplicationModes.Player) | bitValue;
#endif
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Maps the capabilities of controllers, linking the Physical inputs of a controller to a Logical construct in a runtime project<para/>
/// </summary>
/// <remarks>
/// One definition should exist for each physical device input, such as buttons, triggers, joysticks, dpads, and more.
/// </remarks>
[Serializable]
public class MixedRealityInteractionMapping
{
/// <summary>
/// The constructor for a new Interaction Mapping definition
/// </summary>
/// <param name="id">Identity for mapping</param>
/// <param name="description">The description of the interaction mapping.</param>
/// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param>
/// <param name="inputType">The physical input device / control</param>
/// <param name="axisCodeX">Optional horizontal or single axis value to get axis data from Unity's old input system.</param>
/// <param name="axisCodeY">Optional vertical axis value to get axis data from Unity's old input system.</param>
/// <param name="invertXAxis">Optional horizontal axis invert option.</param>
/// <param name="invertYAxis">Optional vertical axis invert option.</param>
public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, string axisCodeX = "", string axisCodeY = "", bool invertXAxis = false, bool invertYAxis = false)
: this(id, description, axisType, inputType, MixedRealityInputAction.None, KeyCode.None, axisCodeX, axisCodeY, invertXAxis, invertYAxis) { }
/// <summary>
/// The constructor for a new Interaction Mapping definition
/// </summary>
/// <param name="id">Identity for mapping</param>
/// <param name="description">The description of the interaction mapping.</param>
/// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param>
/// <param name="inputType">The physical input device / control</param>
/// <param name="keyCode">Optional KeyCode value to get input from Unity's old input system</param>
public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, KeyCode keyCode)
: this(id, description, axisType, inputType, MixedRealityInputAction.None, keyCode) { }
/// <summary>
/// The constructor for a new Interaction Mapping definition
/// </summary>
/// <param name="id">Identity for mapping</param>
/// <param name="description">The description of the interaction mapping.</param>
/// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param>
/// <param name="inputType">The physical input device / control</param>
/// <param name="inputAction">The logical MixedRealityInputAction that this input performs</param>
/// <param name="keyCode">Optional KeyCode value to get input from Unity's old input system</param>
/// <param name="axisCodeX">Optional horizontal or single axis value to get axis data from Unity's old input system.</param>
/// <param name="axisCodeY">Optional vertical axis value to get axis data from Unity's old input system.</param>
/// <param name="invertXAxis">Optional horizontal axis invert option.</param>
/// <param name="invertYAxis">Optional vertical axis invert option.</param>
public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, MixedRealityInputAction inputAction, KeyCode keyCode = KeyCode.None, string axisCodeX = "", string axisCodeY = "", bool invertXAxis = false, bool invertYAxis = false)
{
this.id = id;
this.description = description;
this.axisType = axisType;
this.inputType = inputType;
this.inputAction = inputAction;
this.keyCode = keyCode;
this.axisCodeX = axisCodeX;
this.axisCodeY = axisCodeY;
this.invertXAxis = invertXAxis;
this.invertYAxis = invertYAxis;
rawData = null;
boolData = false;
floatData = 0f;
vector2Data = Vector2.zero;
positionData = Vector3.zero;
rotationData = Quaternion.identity;
poseData = MixedRealityPose.ZeroIdentity;
changed = false;
}
public MixedRealityInteractionMapping(MixedRealityInteractionMapping mixedRealityInteractionMapping)
: this(mixedRealityInteractionMapping.id,
mixedRealityInteractionMapping.Description,
mixedRealityInteractionMapping.AxisType,
mixedRealityInteractionMapping.InputType,
mixedRealityInteractionMapping.MixedRealityInputAction,
mixedRealityInteractionMapping.keyCode,
mixedRealityInteractionMapping.axisCodeX,
mixedRealityInteractionMapping.axisCodeY,
mixedRealityInteractionMapping.invertXAxis,
mixedRealityInteractionMapping.invertYAxis) { }
#region Interaction Properties
[SerializeField]
[Tooltip("The Id assigned to the Interaction.")]
private uint id;
/// <summary>
/// The Id assigned to the Interaction.
/// </summary>
public uint Id => id;
[SerializeField]
[Tooltip("The description of the interaction mapping.")]
private string description;
/// <summary>
/// The description of the interaction mapping.
/// </summary>
public string Description => description;
[SerializeField]
[Tooltip("The axis type of the button, e.g. Analogue, Digital, etc.")]
private AxisType axisType;
/// <summary>
/// The axis type of the button, e.g. Analogue, Digital, etc.
/// </summary>
public AxisType AxisType => axisType;
[SerializeField]
[Tooltip("The primary action of the input as defined by the controller SDK.")]
private DeviceInputType inputType;
/// <summary>
/// The primary action of the input as defined by the controller SDK.
/// </summary>
public DeviceInputType InputType => inputType;
[SerializeField]
[Tooltip("Action to be raised to the Input Manager when the input data has changed.")]
private MixedRealityInputAction inputAction;
/// <summary>
/// Action to be raised to the Input Manager when the input data has changed.
/// </summary>
public MixedRealityInputAction MixedRealityInputAction
{
get { return inputAction; }
internal set { inputAction = value; }
}
[SerializeField]
[Tooltip("Optional KeyCode value to get input from Unity's old input system.")]
private KeyCode keyCode;
/// <summary>
/// Optional KeyCode value to get input from Unity's old input system.
/// </summary>
public KeyCode KeyCode => keyCode;
[SerializeField]
[Tooltip("Optional horizontal or single axis value to get axis data from Unity's old input system.")]
private string axisCodeX;
/// <summary>
/// Optional horizontal or single axis value to get axis data from Unity's old input system.
/// </summary>
public string AxisCodeX => axisCodeX;
[SerializeField]
[Tooltip("Optional vertical axis value to get axis data from Unity's old input system.")]
private string axisCodeY;
/// <summary>
/// Optional vertical axis value to get axis data from Unity's old input system.
/// </summary>
public string AxisCodeY => axisCodeY;
[SerializeField]
[Tooltip("Should the X axis be inverted?")]
private bool invertXAxis = false;
/// <summary>
/// Should the X axis be inverted?
/// </summary>
/// <remarks>
/// Only valid for <see cref="Microsoft.MixedReality.Toolkit.Utilities.AxisType.SingleAxis"/> and <see cref="Microsoft.MixedReality.Toolkit.Utilities.AxisType.DualAxis"/> inputs.
/// </remarks>
public bool InvertXAxis
{
get { return invertXAxis; }
set
{
if (AxisType != AxisType.SingleAxis && AxisType != AxisType.DualAxis)
{
Debug.LogWarning("Inverted X axis only valid for Single or Dual Axis inputs.");
return;
}
invertXAxis = value;
}
}
[SerializeField]
[Tooltip("Should the Y axis be inverted?")]
private bool invertYAxis = false;
/// <summary>
/// Should the Y axis be inverted?
/// </summary>
/// <remarks>
/// Only valid for <see cref="Microsoft.MixedReality.Toolkit.Utilities.AxisType.DualAxis"/> inputs.
/// </remarks>
public bool InvertYAxis
{
get { return invertYAxis; }
set
{
if (AxisType != AxisType.DualAxis)
{
Debug.LogWarning("Inverted Y axis only valid for Dual Axis inputs.");
return;
}
invertYAxis = value;
}
}
private bool changed;
/// <summary>
/// Has the value changed since the last reading.
/// </summary>
public bool Changed
{
get
{
bool returnValue = changed;
if (changed)
{
changed = false;
}
return returnValue;
}
private set
{
changed = value;
}
}
#endregion Interaction Properties
#region Definition Data Items
private object rawData;
private bool boolData;
private float floatData;
private Vector2 vector2Data;
private Vector3 positionData;
private Quaternion rotationData;
private MixedRealityPose poseData;
#endregion Definition Data Items
#region Data Properties
/// <summary>
/// The Raw (object) data value.
/// </summary>
/// <remarks>Only supported for a Raw mapping axis type</remarks>
public object RawData
{
get
{
return rawData;
}
set
{
if (AxisType != AxisType.Raw)
{
Debug.LogError($"SetRawValue is only valid for AxisType.Raw InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
Changed = rawData != value;
rawData = value;
}
}
/// <summary>
/// The Bool data value.
/// </summary>
/// <remarks>Only supported for a Digital mapping axis type</remarks>
public bool BoolData
{
get
{
return boolData;
}
set
{
if (AxisType != AxisType.Digital && AxisType != AxisType.SingleAxis && AxisType != AxisType.DualAxis)
{
Debug.LogError($"SetBoolValue is only valid for AxisType.Digital, AxisType.SingleAxis, or AxisType.DualAxis InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
Changed = boolData != value;
boolData = value;
}
}
/// <summary>
/// The Float data value.
/// </summary>
/// <remarks>Only supported for a SingleAxis mapping axis type</remarks>
public float FloatData
{
get
{
return floatData;
}
set
{
if (AxisType != AxisType.SingleAxis)
{
Debug.LogError($"SetFloatValue is only valid for AxisType.SingleAxis InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
if (invertXAxis)
{
Changed = !floatData.Equals(value * -1f);
floatData = value * -1f;
}
else
{
Changed = !floatData.Equals(value);
floatData = value;
}
}
}
/// <summary>
/// The Vector2 data value.
/// </summary>
/// <remarks>Only supported for a DualAxis mapping axis type</remarks>
public Vector2 Vector2Data
{
get
{
return vector2Data;
}
set
{
if (AxisType != AxisType.DualAxis)
{
Debug.LogError($"SetVector2Value is only valid for AxisType.DualAxis InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
Vector2 newValue = value * new Vector2(invertXAxis ? -1f : 1f, invertYAxis ? -1f : 1f);
Changed = vector2Data != newValue;
vector2Data = newValue;
}
}
/// <summary>
/// The ThreeDof Vector3 Position data value.
/// </summary>
/// <remarks>Only supported for a ThreeDof mapping axis type</remarks>
public Vector3 PositionData
{
get
{
return positionData;
}
set
{
if (AxisType != AxisType.ThreeDofPosition)
{
{
Debug.LogError($"SetPositionValue is only valid for AxisType.ThreeDoFPosition InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
}
Changed = positionData != value;
positionData = value;
}
}
/// <summary>
/// The ThreeDof Quaternion Rotation data value.
/// </summary>
/// <remarks>Only supported for a ThreeDof mapping axis type</remarks>
public Quaternion RotationData
{
get
{
return rotationData;
}
set
{
if (AxisType != AxisType.ThreeDofRotation)
{
Debug.LogError($"SetRotationValue is only valid for AxisType.ThreeDoFRotation InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
Changed = rotationData != value;
rotationData = value;
}
}
/// <summary>
/// The Pose data value.
/// </summary>
/// <remarks>Only supported for a SixDof mapping axis type</remarks>
public MixedRealityPose PoseData
{
get
{
return poseData;
}
set
{
if (AxisType != AxisType.SixDof)
{
Debug.LogError($"SetPoseValue is only valid for AxisType.SixDoF InteractionMappings\nPlease check the {InputType} mapping for the current controller");
}
Changed = poseData != value;
poseData = value;
positionData = poseData.Position;
rotationData = poseData.Rotation;
}
}
#endregion Data Properties
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.MixedReality.Toolkit
{
/// <summary>
/// The SDKType lists the XR SDKs that are supported by the Mixed Reality Toolkit.
/// Initially, this lists proposed SDKs, not all may be implemented at this time (please see ReleaseNotes for more details)
/// </summary>
public enum SDKType
{
/// <summary>
/// No specified type or Standalone / non-XR type
/// </summary>
None = 0,
/// <summary>
/// Undefined SDK.
/// </summary>
Other,
/// <summary>
/// The Windows 10 Mixed reality SDK provided by the Universal Windows Platform (UWP), for Immersive MR headsets and HoloLens.
/// </summary>
WindowsMR,
/// <summary>
/// The OpenVR platform provided by Unity (does not support the downloadable SteamVR SDK).
/// </summary>
OpenVR,
/// <summary>
/// The OpenXR platform. SDK to be determined once released.
/// </summary>
OpenXR
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
namespace Microsoft.MixedReality.Toolkit.Input
{
// todo: remove this.... it requires customization to add new device types
/// <summary>
/// The SDKType lists the XR SDKs that are supported by the Mixed Reality Toolkit.
/// Initially, this lists proposed SDKs, not all may be implemented at this time (please see ReleaseNotes for more details)
/// </summary>
[Flags]
public enum SupportedControllerType
{
GenericOpenVR = 1 << 0,
ViveWand = 1 << 1,
ViveKnuckles = 1 << 2,
OculusTouch = 1 << 3,
OculusRemote = 1 << 4,
WindowsMixedReality = 1 << 5,
GenericUnity = 1 << 6,
Xbox = 1 << 7,
TouchScreen = 1 << 8,
Mouse = 1 << 9,
ArticulatedHand = 1 << 10,
GGVHand = 1 << 11
}
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.MixedReality.Toolkit
{
/// <summary>
/// The Tracking State defines how a device is currently being tracked.
/// This enables developers to be able to handle non-tracked situations and react accordingly.
/// </summary>
/// <remarks>
/// Tracking is being defined as receiving sensor (positional and/or rotational) data from the device.
/// </remarks>
public enum TrackingState
{
/// <summary>
/// The device does not support tracking (ex: a traditional game controller).
/// </summary>
NotApplicable = 0,
/// <summary>
/// The device is not tracked.
/// </summary>
NotTracked,
/// <summary>
/// The device is tracked (positionally and/or rotationally).
/// </summary>
/// <remarks>
/// Some devices provide additional details regarding the accuracy of the tracking.
/// </remarks>
Tracked
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;
using UnityEngine.Serialization;
namespace Microsoft.MixedReality.Toolkit.Diagnostics
{
/// <summary>
/// Configuration profile settings for setting up diagnostics.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Diagnostics Profile", fileName = "MixedRealityDiagnosticsProfile", order = (int)CreateProfileMenuItemIndices.Diagnostics)]
[MixedRealityServiceProfile(typeof(IMixedRealityDiagnosticsSystem))]
[HelpURL("https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Diagnostics/DiagnosticsSystemGettingStarted.html")]
public class MixedRealityDiagnosticsProfile : BaseMixedRealityProfile
{
[SerializeField]
[FormerlySerializedAs("visible")]
[Tooltip("Display all enabled diagnostics")]
private bool showDiagnostics = true;
/// <summary>
/// Show or hide diagnostic visualizations.
/// </summary>
public bool ShowDiagnostics => showDiagnostics;
[SerializeField]
[Tooltip("Display profiler")]
private bool showProfiler = true;
/// <summary>
/// Show or hide the profiler UI.
/// </summary>
public bool ShowProfiler => showProfiler;
[SerializeField]
[Tooltip("Display the frame info (per frame stats).")]
private bool showFrameInfo = true;
/// <summary>
/// Show or hide the frame info (per frame stats).
/// </summary>
public bool ShowFrameInfo => showFrameInfo;
[SerializeField]
[Tooltip("Display the memory stats (used, peak, and limit).")]
private bool showMemoryStats = true;
/// <summary>
/// Show or hide the memory stats (used, peak, and limit).
/// </summary>
public bool ShowMemoryStats => showMemoryStats;
[SerializeField]
[FormerlySerializedAs("frameRateDuration")]
[Tooltip("The amount of time, in seconds, to collect frames for frame rate calculation.")]
[Range(0, 5)]
private float frameSampleRate = 0.1f;
/// <summary>
/// The amount of time, in seconds, to collect frames for frame rate calculation.
/// </summary>
public float FrameSampleRate => frameSampleRate;
[SerializeField]
[Tooltip("What part of the view port to anchor the window to.")]
private TextAnchor windowAnchor = TextAnchor.LowerCenter;
/// <summary>
/// What part of the view port to anchor the window to.
/// </summary>
public TextAnchor WindowAnchor => windowAnchor;
[SerializeField]
[Tooltip("The offset from the view port center applied based on the window anchor selection.")]
private Vector2 windowOffset = new Vector2(0.1f, 0.1f);
/// <summary>
/// The offset from the view port center applied based on the window anchor selection.
/// </summary>
public Vector2 WindowOffset => windowOffset;
[SerializeField]
[Tooltip("Use to scale the window size up or down, can simulate a zooming effect.")]
private float windowScale = 1.0f;
/// <summary>
/// Use to scale the window size up or down, can simulate a zooming effect.
/// </summary>
public float WindowScale => windowScale;
[SerializeField]
[Tooltip("How quickly to interpolate the window towards its target position and rotation.")]
private float windowFollowSpeed = 5.0f;
/// <summary>
/// How quickly to interpolate the window towards its target position and rotation.
/// </summary>
public float WindowFollowSpeed => windowFollowSpeed;
[SerializeField]
[Tooltip("A material that the diagnostics system can use to render objects with instanced color support.")]
private Material defaultInstancedMaterial = null;
/// <summary>
/// A material that the diagnostics system can use to render objects with instanced color support.
/// A asset reference is required here to make sure the shader permutation is pulled into player builds.
/// </summary>
public Material DefaultInstancedMaterial => defaultInstancedMaterial;
[SerializeField]
[Tooltip("If the diagnostics profiler should be visible while a mixed reality capture is happening on HoloLens.")]
private bool showProfilerDuringMRC = false;
/// <summary>
/// If the diagnostics profiler should be visible while a mixed reality capture is happening on HoloLens.
/// </summary>
/// <remarks>This is not usually recommended, as MRC can have an effect on an app's frame rate.</remarks>
public bool ShowProfilerDuringMRC => showProfilerDuringMRC;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
[Serializable]
public class AnimatedCursorStateData : AnimatedCursorData<CursorStateEnum> { }
[Serializable]
public class AnimatedCursorContextData : AnimatedCursorData<CursorContextEnum> { }
/// <summary>
/// Data struct for cursor state information for the Animated Cursor, which leverages the Unity animation system.
/// This defines a modification to an Unity animation parameter, based on cursor state.
/// </summary>
[Serializable]
public class AnimatedCursorData<T>
{
[SerializeField]
[Tooltip("The name of this specific cursor state.")]
protected string name;
/// <summary>
/// The name of this specific cursor state.
/// </summary>
public string Name => name;
[SerializeField]
[Tooltip("The Cursor State for this specific animation.")]
protected T cursorState;
/// <summary>
/// The Cursor State for this specific animation.
/// </summary>
public T CursorState => cursorState;
[SerializeField]
[Tooltip("Animator parameter definition for this cursor state.")]
protected AnimatorParameter parameter;
/// <summary>
/// Animator parameter definition for this cursor state.
/// </summary>
public AnimatorParameter Parameter => parameter;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Enum for current cursor context
/// </summary>
public enum CursorContextEnum
{
None = -1,
MoveEastWest,
MoveNorthSouth,
MoveNorthwestSoutheast,
MoveNortheastSouthwest,
MoveCross,
RotateEastWest,
RotateNorthSouth,
Contextual
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Enum for current cursor state
/// </summary>
public enum CursorStateEnum
{
/// <summary>
/// Useful for releasing external override.
/// See <c>CursorStateEnum.Contextual</c>
/// </summary>
None = -1,
/// <summary>
/// Not IsHandDetected OR HasTeleportIntent
/// </summary>
Observe,
/// <summary>
/// Not IsHandDetected AND not IsPointerDown AND TargetedObject exists OR HasTeleportIntent AND Teleport Surface IsValid
/// </summary>
ObserveHover,
/// <summary>
/// IsHandDetected AND not IsPointerDown AND TargetedObject is NULL
/// </summary>
Interact,
/// <summary>
/// IsHandDetected AND not IsPointerDown AND TargetedObject exists
/// </summary>
InteractHover,
/// <summary>
/// IsHandDetected AND IsPointerDown
/// </summary>
Select,
/// <summary>
/// Available for use by classes that extend Cursor.
/// No logic for setting Release state exists in the base Cursor class.
/// </summary>
Release,
/// <summary>
/// Allows for external override
/// </summary>
Contextual
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using UnityEngine;
using UnityEngine.Events;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Data class that maps <see cref="MixedRealityInputAction"/>s to <see cref="UnityEvent"/>s wired up in the inspector.
/// </summary>
[Serializable]
public struct InputActionEventPair
{
/// <summary>
/// Constructor.
/// </summary>
public InputActionEventPair(MixedRealityInputAction inputAction, UnityEvent unityEvent)
{
this.inputAction = inputAction;
this.unityEvent = unityEvent;
}
[SerializeField]
[Tooltip("The MixedRealityInputAction to listen for to invoke the UnityEvent.")]
private MixedRealityInputAction inputAction;
/// <summary>
/// The <see cref="MixedRealityInputAction"/> to listen for to invoke the <see cref="UnityEvent"/>.
/// </summary>
public MixedRealityInputAction InputAction => inputAction;
[SerializeField]
[Tooltip("The UnityEvent to invoke when MixedRealityInputAction is raised.")]
private UnityEvent unityEvent;
/// <summary>
/// The <see cref="UnityEvent"/> to invoke when <see cref="MixedRealityInputAction"/> is raised.
/// </summary>
public UnityEvent UnityEvent => unityEvent;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Generic Input Action Rule for raising actions based on specific criteria.
/// </summary>
[Serializable]
public struct InputActionRuleDigital : IInputActionRule<bool>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="baseAction">The Base Action that the rule will listen to.</param>
/// <param name="ruleAction">The Action to raise if the criteria is met.</param>
/// <param name="criteria">The criteria to check against for determining if the action should be raised.</param>
public InputActionRuleDigital(MixedRealityInputAction baseAction, MixedRealityInputAction ruleAction, bool criteria)
{
this.baseAction = baseAction;
this.ruleAction = ruleAction;
this.criteria = criteria;
}
[SerializeField]
[Tooltip("The Base Action that the rule will listen to.")]
private MixedRealityInputAction baseAction;
/// <inheritdoc />
public MixedRealityInputAction BaseAction => baseAction;
[SerializeField]
[Tooltip("The Action to raise if the criteria is met.")]
private MixedRealityInputAction ruleAction;
/// <inheritdoc />
public MixedRealityInputAction RuleAction => ruleAction;
[SerializeField]
[Tooltip("The criteria to check against for determining if the action should be raised.")]
private bool criteria;
/// <inheritdoc />
public bool Criteria => criteria;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Generic Input Action Rule for raising actions based on specific criteria.
/// </summary>
[Serializable]
public struct InputActionRuleDualAxis : IInputActionRule<Vector2>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="baseAction">The Base Action that the rule will listen to.</param>
/// <param name="ruleAction">The Action to raise if the criteria is met.</param>
/// <param name="criteria">The criteria to check against for determining if the action should be raised.</param>
public InputActionRuleDualAxis(MixedRealityInputAction baseAction, MixedRealityInputAction ruleAction, Vector2 criteria)
{
this.baseAction = baseAction;
this.ruleAction = ruleAction;
this.criteria = criteria;
}
[SerializeField]
[Tooltip("The Base Action that the rule will listen to.")]
private MixedRealityInputAction baseAction;
/// <inheritdoc />
public MixedRealityInputAction BaseAction => baseAction;
[SerializeField]
[Tooltip("The Action to raise if the criteria is met.")]
private MixedRealityInputAction ruleAction;
/// <inheritdoc />
public MixedRealityInputAction RuleAction => ruleAction;
[SerializeField]
[Tooltip("The criteria to check against for determining if the action should be raised.")]
private Vector2 criteria;
/// <inheritdoc />
public Vector2 Criteria => criteria;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Generic Input Action Rule for raising actions based on specific criteria.
/// </summary>
[Serializable]
public struct InputActionRulePoseAxis : IInputActionRule<MixedRealityPose>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="baseAction">The Base Action that the rule will listen to.</param>
/// <param name="ruleAction">The Action to raise if the criteria is met.</param>
/// <param name="criteria">The criteria to check against for determining if the action should be raised.</param>
public InputActionRulePoseAxis(MixedRealityInputAction baseAction, MixedRealityInputAction ruleAction, MixedRealityPose criteria)
{
this.baseAction = baseAction;
this.ruleAction = ruleAction;
this.criteria = criteria;
}
[SerializeField]
[Tooltip("The Base Action that the rule will listen to.")]
private MixedRealityInputAction baseAction;
/// <inheritdoc />
public MixedRealityInputAction BaseAction => baseAction;
[SerializeField]
[Tooltip("The Action to raise if the criteria is met.")]
private MixedRealityInputAction ruleAction;
/// <inheritdoc />
public MixedRealityInputAction RuleAction => ruleAction;
[SerializeField]
[Tooltip("The criteria to check against for determining if the action should be raised.")]
private MixedRealityPose criteria;
/// <inheritdoc />
public MixedRealityPose Criteria => criteria;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Generic Input Action Rule for raising actions based on specific criteria.
/// </summary>
[Serializable]
public struct InputActionRuleQuaternionAxis : IInputActionRule<Quaternion>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="baseAction">The Base Action that the rule will listen to.</param>
/// <param name="ruleAction">The Action to raise if the criteria is met.</param>
/// <param name="criteria">The criteria to check against for determining if the action should be raised.</param>
public InputActionRuleQuaternionAxis(MixedRealityInputAction baseAction, MixedRealityInputAction ruleAction, Quaternion criteria)
{
this.baseAction = baseAction;
this.ruleAction = ruleAction;
this.criteria = criteria;
}
[SerializeField]
[Tooltip("The Base Action that the rule will listen to.")]
private MixedRealityInputAction baseAction;
/// <inheritdoc />
public MixedRealityInputAction BaseAction => baseAction;
[SerializeField]
[Tooltip("The Action to raise if the criteria is met.")]
private MixedRealityInputAction ruleAction;
/// <inheritdoc />
public MixedRealityInputAction RuleAction => ruleAction;
[SerializeField]
[Tooltip("The criteria to check against for determining if the action should be raised.")]
private Quaternion criteria;
/// <inheritdoc />
public Quaternion Criteria => criteria;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Generic Input Action Rule for raising actions based on specific criteria.
/// </summary>
[Serializable]
public struct InputActionRuleSingleAxis : IInputActionRule<float>
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="baseAction">The Base Action that the rule will listen to.</param>
/// <param name="ruleAction">The Action to raise if the criteria is met.</param>
/// <param name="criteria">The criteria to check against for determining if the action should be raised.</param>
public InputActionRuleSingleAxis(MixedRealityInputAction baseAction, MixedRealityInputAction ruleAction, float criteria)
{
this.baseAction = baseAction;
this.ruleAction = ruleAction;
this.criteria = criteria;
}
[SerializeField]
[Tooltip("The Base Action that the rule will listen to.")]
private MixedRealityInputAction baseAction;
/// <inheritdoc />
public MixedRealityInputAction BaseAction => baseAction;
[SerializeField]
[Tooltip("The Action to raise if the criteria is met.")]
private MixedRealityInputAction ruleAction;
/// <inheritdoc />
public MixedRealityInputAction RuleAction => ruleAction;
[SerializeField]
[Tooltip("The criteria to check against for determining if the action should be raised.")]
private float criteria;
/// <inheritdoc />
public float Criteria => criteria;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment