Skip to content
Snippets Groups Projects
Commit 29de0c28 authored by BlackAngle233's avatar BlackAngle233
Browse files

10.19 learned

parent 912976bb
Branches
No related merge requests found
Showing
with 1270 additions and 0 deletions
// 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 InputActionRuleVectorAxis : IInputActionRule<Vector3>
{
/// <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 InputActionRuleVectorAxis(MixedRealityInputAction baseAction, MixedRealityInputAction ruleAction, Vector3 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 Vector3 criteria;
/// <inheritdoc />
public Vector3 Criteria => criteria;
}
}
\ 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>
/// Keyword/UnityEvent pair that ties voice input to UnityEvents wired up in the inspector.
/// </summary>
[Serializable]
public struct KeywordAndResponse
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="keyword">The keyword to listen for.</param>
/// <param name="response">The handler to be invoked when the keyword is recognized.</param>
public KeywordAndResponse(string keyword, UnityEvent response)
{
this.keyword = keyword;
this.response = response;
}
[SerializeField]
[Tooltip("The keyword to listen for.")]
private string keyword;
/// <summary>
/// The keyword to listen for.
/// </summary>
public string Keyword => keyword;
[SerializeField]
[Tooltip("The handler to be invoked when the keyword is recognized.")]
private UnityEvent response;
/// <summary>
/// The handler to be invoked when the keyword is recognized.
/// </summary>
public UnityEvent Response => response;
}
}
\ 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>
/// Data structure for mapping gestures to <see cref="MixedRealityInputAction"/>s that can be raised by the Input System.
/// </summary>
[Serializable]
public struct MixedRealityGestureMapping
{
/// <summary>
/// Constructor.
/// </summary>
public MixedRealityGestureMapping(string description, GestureInputType gestureType, MixedRealityInputAction action)
{
this.description = description;
this.gestureType = gestureType;
this.action = action;
}
[SerializeField]
private string description;
/// <summary>
/// Simple, human readable description of the gesture.
/// </summary>
public string Description => description;
[SerializeField]
private GestureInputType gestureType;
/// <summary>
/// Type of Gesture.
/// </summary>
public GestureInputType GestureType => gestureType;
[SerializeField]
private MixedRealityInputAction action;
/// <summary>
/// Action for the associated gesture.
/// </summary>
public MixedRealityInputAction Action => action;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using Microsoft.MixedReality.Toolkit.Windows.Input;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Configuration profile settings for setting up and consuming Input Actions.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Gestures Profile", fileName = "MixedRealityGesturesProfile", order = (int)CreateProfileMenuItemIndices.Gestures)]
[HelpURL("https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Gestures.html")]
public class MixedRealityGesturesProfile : BaseMixedRealityProfile
{
[EnumFlags]
[SerializeField]
[Tooltip("The recognizable Manipulation Gestures.")]
private WindowsGestureSettings manipulationGestures = 0;
/// <summary>
/// The recognizable Manipulation Gestures.
/// </summary>
public WindowsGestureSettings ManipulationGestures => manipulationGestures;
[EnumFlags]
[SerializeField]
[Tooltip("The recognizable Navigation Gestures.")]
private WindowsGestureSettings navigationGestures = 0;
/// <summary>
/// The recognizable Navigation Gestures.
/// </summary>
public WindowsGestureSettings NavigationGestures => navigationGestures;
[SerializeField]
[Tooltip("Should the Navigation use Rails on start?\nNote: This can be changed at runtime to switch between the two Navigation settings.")]
private bool useRailsNavigation = false;
public bool UseRailsNavigation => useRailsNavigation;
[EnumFlags]
[SerializeField]
[Tooltip("The recognizable Rails Navigation Gestures.")]
private WindowsGestureSettings railsNavigationGestures = 0;
/// <summary>
/// The recognizable Navigation Gestures.
/// </summary>
public WindowsGestureSettings RailsNavigationGestures => railsNavigationGestures;
[SerializeField]
private AutoStartBehavior windowsGestureAutoStart = AutoStartBehavior.AutoStart;
public AutoStartBehavior WindowsGestureAutoStart => windowsGestureAutoStart;
[SerializeField]
private MixedRealityGestureMapping[] gestures =
{
new MixedRealityGestureMapping("Hold", GestureInputType.Hold, MixedRealityInputAction.None),
new MixedRealityGestureMapping("Navigation", GestureInputType.Navigation, MixedRealityInputAction.None),
new MixedRealityGestureMapping("Manipulation", GestureInputType.Manipulation, MixedRealityInputAction.None),
};
/// <summary>
/// The currently configured gestures for the application.
/// </summary>
public MixedRealityGestureMapping[] Gestures => gestures;
}
}
\ 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;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// An Input Action for mapping an action to an Input Sources Button, Joystick, Sensor, etc.
/// </summary>
[Serializable]
public struct MixedRealityInputAction : IEqualityComparer
{
/// <summary>
/// Constructor.
/// </summary>
public MixedRealityInputAction(uint id, string description, AxisType axisConstraint = AxisType.None)
{
this.id = id;
this.description = description;
this.axisConstraint = axisConstraint;
}
public static MixedRealityInputAction None { get; } = new MixedRealityInputAction(0, "None");
/// <summary>
/// The Unique Id of this Input Action.
/// </summary>
public uint Id => id;
[SerializeField]
private uint id;
/// <summary>
/// A short description of the Input Action.
/// </summary>
public string Description => description;
[SerializeField]
private string description;
/// <summary>
/// The Axis constraint for the Input Action
/// </summary>
public AxisType AxisConstraint => axisConstraint;
[SerializeField]
private AxisType axisConstraint;
public static bool operator ==(MixedRealityInputAction left, MixedRealityInputAction right)
{
return left.Equals(right);
}
public static bool operator !=(MixedRealityInputAction left, MixedRealityInputAction right)
{
return !left.Equals(right);
}
#region IEqualityComparer Implementation
bool IEqualityComparer.Equals(object left, object right)
{
if (ReferenceEquals(null, left) || ReferenceEquals(null, right)) { return false; }
if (!(left is MixedRealityInputAction) || !(right is MixedRealityInputAction)) { return false; }
return ((MixedRealityInputAction)left).Equals((MixedRealityInputAction)right);
}
public bool Equals(MixedRealityInputAction other)
{
return Id == other.Id &&
AxisConstraint == other.AxisConstraint;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) { return false; }
return obj is MixedRealityInputAction && Equals((MixedRealityInputAction)obj);
}
int IEqualityComparer.GetHashCode(object obj)
{
return obj is MixedRealityInputAction ? ((MixedRealityInputAction)obj).GetHashCode() : 0;
}
public override int GetHashCode()
{
return $"{Id}.{AxisConstraint}".GetHashCode();
}
#endregion IEqualityComparer Implementation
}
}
// 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 Input Action Rules Profile", fileName = "MixedRealityInputActionRulesProfile", order = (int)CreateProfileMenuItemIndices.InputActionRules)]
public class MixedRealityInputActionRulesProfile : BaseMixedRealityProfile
{
[SerializeField]
private InputActionRuleDigital[] inputActionRulesDigital = null;
/// <summary>
/// All the Input Action Rules for <see cref="bool"/> based <see cref="MixedRealityInputAction"/>s
/// </summary>
public InputActionRuleDigital[] InputActionRulesDigital => inputActionRulesDigital;
[SerializeField]
private InputActionRuleSingleAxis[] inputActionRulesSingleAxis = null;
/// <summary>
/// All the Input Action Rules for <see cref="float"/> based <see cref="MixedRealityInputAction"/>s
/// </summary>
public InputActionRuleSingleAxis[] InputActionRulesSingleAxis => inputActionRulesSingleAxis;
[SerializeField]
private InputActionRuleDualAxis[] inputActionRulesDualAxis = null;
/// <summary>
/// All the Input Action Rules for <see href="https://docs.unity3d.com/ScriptReference/Vector2.html">Vector2</see> based <see cref="MixedRealityInputAction"/>s
/// </summary>
public InputActionRuleDualAxis[] InputActionRulesDualAxis => inputActionRulesDualAxis;
[SerializeField]
private InputActionRuleVectorAxis[] inputActionRulesVectorAxis = null;
/// <summary>
/// All the Input Action Rules for <see href="https://docs.unity3d.com/ScriptReference/Vector3.html">Vector3</see> based <see cref="MixedRealityInputAction"/>s
/// </summary>
public InputActionRuleVectorAxis[] InputActionRulesVectorAxis => inputActionRulesVectorAxis;
[SerializeField]
private InputActionRuleQuaternionAxis[] inputActionRulesQuaternionAxis = null;
/// <summary>
/// All the Input Action Rules for <see href="https://docs.unity3d.com/ScriptReference/Quaternion.html">Quaternion</see> based <see cref="MixedRealityInputAction"/>s
/// </summary>
public InputActionRuleQuaternionAxis[] InputActionRulesQuaternionAxis => inputActionRulesQuaternionAxis;
[SerializeField]
private InputActionRulePoseAxis[] inputActionRulesPoseAxis = null;
/// <summary>
/// All the Input Action Rules for <see cref="Microsoft.MixedReality.Toolkit.Utilities.MixedRealityPose"/> based <see cref="MixedRealityInputAction"/>s
/// </summary>
public InputActionRulePoseAxis[] InputActionRulesPoseAxis => inputActionRulesPoseAxis;
}
}
\ No newline at end of file
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.MixedReality.Toolkit.Utilities;
using System.Collections.Generic;
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
/// <summary>
/// Configuration profile settings for setting up and consuming Input Actions.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Input Actions Profile", fileName = "MixedRealityInputActionsProfile", order = (int)CreateProfileMenuItemIndices.InputActions)]
[HelpURL("https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/InputActions.html")]
public class MixedRealityInputActionsProfile : BaseMixedRealityProfile
{
private readonly string[] defaultInputActions =
{
"Select",
"Menu",
"Grip",
"Pointer",
"Walk",
"Look",
"Interact",
"Pickup",
"Inventory",
"ConversationSelect"
}; // Examples only, to be refined later.
private readonly AxisType[] defaultInputActionsAxis =
{
AxisType.Digital,
AxisType.Digital,
AxisType.SixDof,
AxisType.SixDof,
AxisType.DualAxis,
AxisType.DualAxis,
AxisType.DualAxis,
AxisType.Digital,
AxisType.DualAxis,
AxisType.DualAxis
}; // Examples only, to be refined later
[SerializeField]
[Tooltip("The list of actions users can do in your application.")]
private MixedRealityInputAction[] inputActions =
{
// 0 is reserved for "None"
new MixedRealityInputAction(1, "Select"),
new MixedRealityInputAction(2, "Menu"),
new MixedRealityInputAction(3, "Grip")
}; // Examples only, to be refined later
/// <summary>
/// The list of actions users can do in your application.
/// </summary>
/// <remarks>Input Actions are device agnostic and can be paired with any number of device inputs across all platforms.</remarks>
public MixedRealityInputAction[] InputActions => inputActions;
/// <summary>
/// Reset the current InputActions definitions to the Mixed Reality Toolkit defaults
/// If existing mappings exist, they will be preserved and pushed to the end of the array
/// </summary>
/// <returns>Default MRTK Actions plus any custom actions (if already configured)</returns>
public MixedRealityInputAction[] LoadMixedRealityToolKitDefaults()
{
var defaultActions = new List<MixedRealityInputAction>();
bool exists = false;
for (uint i = 0; i < defaultInputActions.Length; i++)
{
defaultActions.Add(new MixedRealityInputAction(i, defaultInputActions[i], defaultInputActionsAxis[i]));
}
for (int i = 0; i < inputActions.Length; i++)
{
if (defaultActions.Contains(inputActions[i]))
{
exists = true;
}
if (!exists)
{
defaultActions.Add(inputActions[i]);
}
exists = false;
}
return inputActions = defaultActions.ToArray();
}
}
}
\ 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
{
/// <summary>
/// Configuration profile settings for setting up controller pointers.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Profiles/Mixed Reality Pointer Profile", fileName = "MixedRealityInputPointerProfile", order = (int)CreateProfileMenuItemIndices.Pointer)]
[HelpURL("https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Pointers.html")]
public class MixedRealityPointerProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("Maximum distance at which all pointers can collide with a GameObject, unless it has an override extent.")]
private float pointingExtent = 10f;
/// <summary>
/// Maximum distance at which all pointers can collide with a GameObject, unless it has an override extent.
/// </summary>
public float PointingExtent => pointingExtent;
[SerializeField]
[Tooltip("The LayerMasks, in prioritized order, that are used to determine the GazeTarget when raycasting.")]
private LayerMask[] pointingRaycastLayerMasks = { UnityEngine.Physics.DefaultRaycastLayers };
/// <summary>
/// The LayerMasks, in prioritized order, that are used to determine the GazeTarget when raycasting.
/// </summary>
public LayerMask[] PointingRaycastLayerMasks => pointingRaycastLayerMasks;
[SerializeField]
private bool debugDrawPointingRays = false;
/// <summary>
/// Toggle to enable or disable debug pointing rays.
/// </summary>
public bool DebugDrawPointingRays => debugDrawPointingRays;
[SerializeField]
private Color[] debugDrawPointingRayColors = null;
/// <summary>
/// The colors to use when debugging pointer rays.
/// </summary>
public Color[] DebugDrawPointingRayColors => debugDrawPointingRayColors;
[Prefab]
[SerializeField]
[Tooltip("The gaze cursor prefab to use on the Gaze pointer.")]
private GameObject gazeCursorPrefab = null;
/// <summary>
/// The gaze cursor prefab to use on the Gaze pointer.
/// </summary>
public GameObject GazeCursorPrefab => gazeCursorPrefab;
[SerializeField]
[Tooltip("The concrete type of IMixedRealityGazeProvider to use.")]
[Implements(typeof(IMixedRealityGazeProvider), TypeGrouping.ByNamespaceFlat)]
private SystemType gazeProviderType;
/// <summary>
/// The concrete type of <see cref="IMixedRealityGazeProvider"/> to use.
/// </summary>
public SystemType GazeProviderType
{
get { return gazeProviderType; }
internal set { gazeProviderType = value; }
}
[SerializeField]
[Tooltip("If true, platform-specific head gaze override is used, when available. Otherwise, the center of the camera frame is used by default.")]
private bool useHeadGazeOverride = false;
/// <summary>
/// If true, platform-specific head gaze override is used, when available. Otherwise, the center of the camera frame is used by default.
/// </summary>
public bool UseHeadGazeOverride => useHeadGazeOverride;
[SerializeField]
[Tooltip("If true, eye-based tracking will be used as gaze input when available. Requires the 'Gaze Input' permission and device eye calibration to have been run.")]
private bool isEyeTrackingEnabled = false;
/// <summary>
/// If true, eye-based tracking will be used as gaze input when available.
/// </summary>
public bool IsEyeTrackingEnabled
{
get { return isEyeTrackingEnabled; }
internal set { isEyeTrackingEnabled = value; }
}
[SerializeField]
[Tooltip("The Pointer options for this profile.")]
private PointerOption[] pointerOptions = System.Array.Empty<PointerOption>();
/// <summary>
/// The Pointer options for this profile.
/// </summary>
public PointerOption[] PointerOptions => pointerOptions;
[SerializeField]
[Implements(typeof(IMixedRealityPointerMediator), TypeGrouping.ByNamespaceFlat)]
[Tooltip("The concrete Pointer Mediator component to use. This is a component that mediates all pointers in system, disabling / enabling them based on the state of other pointers.")]
private SystemType pointerMediator = null;
/// <summary>
/// The concrete Pointer Mediator component to use.
/// This is a component that mediates all pointers in system, disabling / enabling them based on the state of other pointers.
/// </summary>
public SystemType PointerMediator
{
get { return pointerMediator; }
}
[SerializeField]
[Implements(typeof(IMixedRealityPrimaryPointerSelector), TypeGrouping.ByNamespaceFlat)]
[Tooltip("Primary pointer selector implementation to use. This is used by the focus provider to choose the primary pointer.")]
private SystemType primaryPointerSelector = null;
/// <summary>
/// Primary pointer selector implementation to use. This is used by the focus provider to choose the primary pointer.
/// </summary>
public SystemType PrimaryPointerSelector
{
get { return primaryPointerSelector; }
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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