internal override IMixedRealityPointer InitializeGazePointer() { using (InitializeConeCastGazePointerPerfMarker.Auto()) { if (gazeTransform == null) { gazeTransform = CameraCache.Main.transform; } Debug.Assert(gazeTransform != null, "No gaze transform to raycast from!"); coneCastPointer = new GazeConePointer(this, "Gaze Pointer", null, raycastLayerMasks, maxGazeCollisionDistance, gazeTransform, stabilizer); if ((GazeCursor == null) && (GazeCursorPrefab != null)) { GameObject cursor = Instantiate(GazeCursorPrefab); MixedRealityPlayspace.AddChild(cursor.transform); SetGazeCursor(cursor); } coneCastPointer.IsTargetPositionLockedOnFocusLock = lockCursorWhenFocusLocked; return(coneCastPointer); } }
/// <summary> /// Request an array of pointers for the controller type. /// </summary> /// <param name="controllerType">The controller type making the request for pointers.</param> /// <param name="controllingHand">The handedness of the controller making the request.</param> /// <param name="useSpecificType">Only register pointers with a specific type.</param> protected virtual IMixedRealityPointer[] RequestPointers(SupportedControllerType controllerType, Handedness controllingHand) { var pointers = new List <IMixedRealityPointer>(); if ((InputSystem != null) && (InputSystemProfile != null) && InputSystemProfile.PointerProfile != null) { for (int i = 0; i < InputSystemProfile.PointerProfile.PointerOptions.Length; i++) { var pointerProfile = InputSystemProfile.PointerProfile.PointerOptions[i]; if (((pointerProfile.ControllerType & controllerType) != 0) && (pointerProfile.Handedness == Handedness.Any || pointerProfile.Handedness == Handedness.Both || pointerProfile.Handedness == controllingHand)) { var pointerObject = Object.Instantiate(pointerProfile.PointerPrefab); MixedRealityPlayspace.AddChild(pointerObject.transform); var pointer = pointerObject.GetComponent <IMixedRealityPointer>(); if (pointer != null) { pointers.Add(pointer); } else { Debug.LogWarning($"Failed to attach {pointerProfile.PointerPrefab.name} to {controllerType}."); } } } } return(pointers.Count == 0 ? null : pointers.ToArray()); }
/// <summary> /// Initialize the service. This will create a new SpatialAnchorManager if one doesn't exist. /// </summary> public override void Initialize() { if (!Application.isPlaying) { return; } _appContext = SynchronizationContext.Current; if (AnchorManager == null) { AnchorManager = MixedRealityPlayspace.Transform.GetComponentInChildren <SpatialAnchorManager>(); } if (AnchorManager == null) { GameObject anchorManagerObject = new GameObject("SpatialAnchorManager"); anchorManagerObject.SetActive(false); AnchorManager = anchorManagerObject.AddComponent <SpatialAnchorManager>(); AnchorManager.enabled = false; MixedRealityPlayspace.AddChild(anchorManagerObject.transform); anchorManagerObject.SetActive(true); } AnchorManager.AnchorLocated += AnchorLocated; }
/// <summary> /// Creates the diagnostic visualizations and parents them so that the scene hierarchy does not get overly cluttered. /// </summary> private void CreateVisualizations() { diagnosticVisualizationParent = new GameObject("Diagnostics"); MixedRealityPlayspace.AddChild(diagnosticVisualizationParent.transform); diagnosticVisualizationParent.SetActive(ShowDiagnostics); // visual profiler settings visualProfiler = diagnosticVisualizationParent.AddComponent <MixedRealityToolkitVisualProfiler>(); visualProfiler.WindowParent = diagnosticVisualizationParent.transform; visualProfiler.IsVisible = ShowProfiler; visualProfiler.FrameSampleRate = FrameSampleRate; visualProfiler.WindowAnchor = WindowAnchor; visualProfiler.WindowOffset = WindowOffset; visualProfiler.WindowScale = WindowScale; visualProfiler.WindowFollowSpeed = WindowFollowSpeed; }
private IMixedRealityPointer InitializeGazePointer() { if (gazeTransform == null) { gazeTransform = CameraCache.Main.transform; } Debug.Assert(gazeTransform != null, "No gaze transform to raycast from!"); gazePointer = new InternalGazePointer(this, "Gaze Pointer", null, raycastLayerMasks, maxGazeCollisionDistance, gazeTransform, stabilizer); if ((GazeCursor == null) && (GazeCursorPrefab != null)) { GameObject cursor = Instantiate(GazeCursorPrefab); MixedRealityPlayspace.AddChild(cursor.transform); SetGazeCursor(cursor); } return(gazePointer); }
protected bool TryAddControllerModelToSceneHierarchy(GameObject controllerObject) { if (controllerObject != null) { controllerObject.name = $"{ControllerHandedness}_{controllerObject.name}"; MixedRealityPlayspace.AddChild(controllerObject.transform); Visualizer = controllerObject.GetComponent <IMixedRealityControllerVisualizer>(); if (Visualizer != null) { Visualizer.Controller = this; return(true); } else { Debug.LogError($"{controllerObject.name} is missing a IMixedRealityControllerVisualizer component!"); return(false); } } return(false); }
private void Awake() { markerParent = new GameObject(); markerParent.name = "Boundary Demo Markers"; MixedRealityPlayspace.AddChild(markerParent.transform); }
public void Start() { // put it at root of scene MixedRealityPlayspace.AddChild(visualsRoot.transform); visualsRoot.gameObject.name = $"{gameObject.name}_NearTetherVisualsRoot"; }
protected virtual bool TryRenderControllerModel(Type controllerType, InputSourceType inputSourceType) { GameObject controllerModel = null; if (GetControllerVisualizationProfile() == null || !GetControllerVisualizationProfile().RenderMotionControllers) { return(true); } // If a specific controller template wants to override the global model, assign that instead. if (IsControllerMappingEnabled() && GetControllerVisualizationProfile() != null && inputSourceType == InputSourceType.Controller && !(GetControllerVisualizationProfile().GetUseDefaultModelsOverride(controllerType, ControllerHandedness))) { controllerModel = GetControllerVisualizationProfile().GetControllerModelOverride(controllerType, ControllerHandedness); } // Get the global controller model for each hand. if (controllerModel == null && GetControllerVisualizationProfile() != null) { if (inputSourceType == InputSourceType.Controller) { if (ControllerHandedness == Handedness.Left && GetControllerVisualizationProfile().GlobalLeftHandModel != null) { controllerModel = GetControllerVisualizationProfile().GlobalLeftHandModel; } else if (ControllerHandedness == Handedness.Right && GetControllerVisualizationProfile().GlobalRightHandModel != null) { controllerModel = GetControllerVisualizationProfile().GlobalRightHandModel; } } else if (inputSourceType == InputSourceType.Hand) { if (ControllerHandedness == Handedness.Left && GetControllerVisualizationProfile().GlobalLeftHandVisualizer != null) { controllerModel = GetControllerVisualizationProfile().GlobalLeftHandVisualizer; } else if (ControllerHandedness == Handedness.Right && GetControllerVisualizationProfile().GlobalRightHandVisualizer != null) { controllerModel = GetControllerVisualizationProfile().GlobalRightHandVisualizer; } } } if (controllerModel == null) { // no controller model available return(false); } // If we've got a controller model prefab, then create it and place it in the scene. GameObject controllerObject = UnityEngine.Object.Instantiate(controllerModel); MixedRealityPlayspace.AddChild(controllerObject.transform); return(TryAddControllerModelToSceneHierarchy(controllerObject)); }