public static async Task <AnchorManagerXR> TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { bool xrRunning = await CheckXRRunning(); if (!xrRunning) { return(null); } /// Try to find an XRAnchorManager (to be XRAnchorManager) here. /// If we fail that, /// give up. /// Else /// pass the manager into AnchorManagerXR for its use. XRAnchorSubsystem xrAnchorManager = FindAnchorManager(); if (xrAnchorManager == null) { return(null); } if (!xrAnchorManager.running) { xrAnchorManager.Start(); } var session = FindSessionSubsystem(); AnchorManagerXR anchorManager = new AnchorManagerXR(plugin, headTracker, xrAnchorManager, session); return(anchorManager); }
private WorldLockingManager() { CreateUpdaterNode(); /// It might look nicer to pull these off into internal setup functions, /// but by leaving them in the constructor, these fields can be marked "readonly", /// which they conceptually are. if (Core.Plugin.HasEngine()) { Plugin = new Plugin(); } else { Plugin = new PluginNoop(); } DiagnosticRecordings.Start(Plugin); headPoseTracker = new HeadPoseTrackerCamera(); /// This should never fail. It's a null-manager. anchorManager = AnchorManagerNull.TryCreate(Plugin, headPoseTracker); Debug.Assert(anchorManager != null, "Null manager creation should never fail"); var fm = new FragmentManager(Plugin); fragmentManager = fm; attachmentPointManager = fm; /// Note the alignmentManager accesses the FragmentManager in its constructor /// to register for refit notifications. Either FragmentManager needs to be fully /// setup before constructing AlignmentManager, or that registration needs to be deferred. alignmentManager = new AlignmentManager(this); }
public static AnchorManagerXR TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { /// Try to find an XRAnchorManager (to be XRAnchorManager) here. /// If we fail that, /// give up. /// Else /// pass the manager into AnchorManagerXR for its use. XRAnchorSubsystem xrAnchorManager = FindAnchorManager(); if (xrAnchorManager == null) { return(null); } if (!xrAnchorManager.running) { xrAnchorManager.Start(); } var session = FindSessionSubsystem(); /// mafinc - Currently a problem in OpenXR obtaining the session subsystem. /// Everything can function without it, it is only used for detecting loss of tracking. //if (session == null) //{ // return null; //} AnchorManagerXR anchorManager = new AnchorManagerXR(plugin, headTracker, xrAnchorManager, session); return(anchorManager); }
private IAnchorManager SelectAnchorManager(IPlugin plugin, IHeadPoseTracker headTracker) { Debug.Log($"Select {shared.anchorSettings.anchorSubsystem} anchor manager."); if (AnchorManager != null) { Debug.Log("Creating new anchormanager, but have old one. Reseting it before replacing."); AnchorManager.Reset(); } var anchorSettings = shared.anchorSettings; #if WLT_ARFOUNDATION_PRESENT if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.DONT_USE) { Debug.Log($"Trying to create ARF anchor manager on {anchorSettings.ARSessionSource.name} and {anchorSettings.ARSessionOriginSource.name}"); AnchorManagerARF arfAnchorManager = AnchorManagerARF.TryCreate(plugin, headTracker, anchorSettings.ARSessionSource, anchorSettings.ARSessionOriginSource); if (arfAnchorManager != null) { Debug.Log("Success creating ARF anchor manager"); return(arfAnchorManager); } Debug.Log("Failed to create requested AR Foundation anchor manager!"); } #endif // WLT_ARFOUNDATION_PRESENT #if WLT_ARSUBSYSTEMS_PRESENT if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.XRSDK) { Debug.Log($"Trying to create XR anchor manager"); AnchorManagerXR xrAnchorManager = AnchorManagerXR.TryCreate(plugin, headTracker); if (xrAnchorManager != null) { Debug.Log("Success creating XR anchor manager"); return(xrAnchorManager); } Debug.Log("Failed to create requested XR SDK anchor manager!"); } #endif // WLT_ARSUBSYSTEMS_PRESENT #if UNITY_WSA if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.WSA) { AnchorManagerWSA wsaAnchorManager = AnchorManagerWSA.TryCreate(plugin, headTracker); if (wsaAnchorManager != null) { Debug.Log("Success creating WSA anchor manager"); return(wsaAnchorManager); } Debug.Log("Failed to create requested WSA anchor manager!"); } #endif // UNITY_WSA if (anchorSettings.anchorSubsystem != AnchorSettings.AnchorSubsystem.Null) { Debug.Log("Failure creating useful anchor manager of any type. Creating null manager"); anchorSettings.anchorSubsystem = AnchorSettings.AnchorSubsystem.Null; } AnchorManagerNull nullAnchorManager = AnchorManagerNull.TryCreate(plugin, headTracker); Debug.Assert(nullAnchorManager != null, "Creation of Null anchor manager should never fail."); return(nullAnchorManager); }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> public AnchorManager(IPlugin plugin, IHeadPoseTracker headTracker) { this.plugin = plugin; this.headTracker = headTracker; worldAnchorParent = new GameObject("SpongyWorldAnchorRoot").transform; lastAnchorAddTime = float.NegativeInfinity; lastTrackingInactiveTime = float.NegativeInfinity; }
public static AnchorManagerARCore TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { AnchorManagerARCore anchorManagerARCore = null; #if WLT_ARCORE_SDK_INCLUDED anchorManagerARCore = new AnchorManagerARCore(plugin, headTracker); #endif // WLT_ARCORE_SDK_INCLUDED return(anchorManagerARCore); }
public static AnchorManagerWSA TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { if (!UnityEngine.XR.XRSettings.enabled) { return(null); } AnchorManagerWSA anchorManagerWSA = new AnchorManagerWSA(plugin, headTracker); return(anchorManagerWSA); }
public static AnchorManagerWSA TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { if (!UnityEngine.XR.XRSettings.enabled) { Debug.LogWarning($"Warning: Legacy WSA AnchorManager selected but legacy WSA not enabled. Check Player Settings/XR."); } AnchorManagerWSA anchorManagerWSA = new AnchorManagerWSA(plugin, headTracker); return(anchorManagerWSA); }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> private AnchorManagerXR(IPlugin plugin, IHeadPoseTracker headTracker, XRAnchorSubsystem xrAnchorManager, XRSessionSubsystem session) : base(plugin, headTracker) { this.xrAnchorManager = xrAnchorManager; this.sessionSubsystem = session; Debug.Log($"XR: Created AnchorManager XR, xrMgr={(this.xrAnchorManager != null ? "good" : "null")}"); Debug.Log($"ActiveLoader name:[{XRGeneralSettings.Instance.Manager.activeLoader.name}] type:[{XRGeneralSettings.Instance.Manager.activeLoader.GetType().FullName}]"); #if WLT_XR_MANAGEMENT_PRESENT wmrPersistence = XRGeneralSettings.Instance.Manager.activeLoader.name.StartsWith("Windows MR"); openXRPersistence = XRGeneralSettings.Instance.Manager.activeLoader.name.StartsWith("Open XR"); #endif // WLT_XR_MANAGEMENT_PRESENT Debug.Log($"XRSDK Persistence: WMR={wmrPersistence} OpenXR={openXRPersistence}"); }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> private AnchorManagerARF(IPlugin plugin, IHeadPoseTracker headTracker, ARSession arSession, ARSessionOrigin arSessionOrigin) : base(plugin, headTracker) { DebugLogSetup($"ARF: Creating AnchorManagerARF with {arSession.name} and {arSessionOrigin.name}"); this.arSession = arSession; this.arSessionOrigin = arSessionOrigin; this.arReferencePointManager = arSessionOrigin.gameObject.GetComponent <ARReferencePointManager>(); if (this.arReferencePointManager == null) { DebugLogSetup($"Adding AR reference point manager to {arSessionOrigin.name}"); this.arReferencePointManager = arSessionOrigin.gameObject.AddComponent <ARReferencePointManager>(); } DebugLogSetup($"ARF: Created AnchorManager ARF"); }
public static async Task <AnchorManagerARF> TryCreate(IPlugin plugin, IHeadPoseTracker headTracker, GameObject arSessionSource, GameObject arSessionOriginSource) { bool xrRunning = await CheckXRRunning(); if (!xrRunning) { Debug.LogError($"Error checking that XR is up and running."); return(null); } if (arSessionSource == null) { Debug.LogError("Trying to create an AR Foundation anchor manager with null session source holder GameObject."); return(null); } if (arSessionOriginSource == null) { Debug.LogError("Trying to create an AR Foundation anchor manager with null session origin source holder GameObject."); return(null); } ARSession arSession = arSessionSource.GetComponent <ARSession>(); if (arSession == null) { DebugLogSetup($"Adding AR session to {arSessionSource.name}"); arSession = arSessionSource.AddComponent <ARSession>(); } if (arSession == null) { Debug.LogError($"Failure acquiring ARSession component from {arSessionSource.name}, can't create AnchorManagerARF"); return(null); } ARSessionOrigin arSessionOrigin = arSessionOriginSource.GetComponent <ARSessionOrigin>(); if (arSessionOrigin == null) { DebugLogSetup($"Adding AR session origin to {arSessionOriginSource.name}"); arSessionOrigin = arSessionOriginSource.AddComponent <ARSessionOrigin>(); } if (arSessionOrigin == null) { Debug.LogError($"Failure acquiring ARSessionOrigin from {arSessionOriginSource.name}, can't create AnchorManagerARF"); } AnchorManagerARF anchorManager = new AnchorManagerARF(plugin, headTracker, arSession, arSessionOrigin); return(anchorManager); }
public static AnchorManagerXR TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { /// Try to find an XRReferencePointManager (to be XRAnchorManager) here. /// If we fail that, /// give up. /// Else /// pass the manager into AnchorManagerXR for its use. XRReferencePointSubsystem xrReferencePointManager = FindReferencePointManager(); if (xrReferencePointManager == null) { return(null); } xrReferencePointManager.Start(); AnchorManagerXR anchorManager = new AnchorManagerXR(plugin, headTracker, xrReferencePointManager); return(anchorManager); }
public static AnchorManagerARF TryCreate(IPlugin plugin, IHeadPoseTracker headTracker, GameObject arSessionSource, GameObject arSessionOriginSource) { if (arSessionSource == null) { Debug.LogError("Trying to create an AR Foundation anchor manager with null session source holder GameObject."); return(null); } if (arSessionOriginSource == null) { Debug.LogError("Trying to create an AR Foundation anchor manager with null session origin source holder GameObject."); return(null); } ARSession arSession = arSessionSource.GetComponent <ARSession>(); if (arSession == null) { Debug.Log($"Adding AR session to {arSessionSource.name}"); arSession = arSessionSource.AddComponent <ARSession>(); } if (arSession == null) { Debug.LogError($"Failure acquiring ARSession component from {arSessionSource.name}, can't create AnchorManagerARF"); return(null); } ARSessionOrigin arSessionOrigin = arSessionOriginSource.GetComponent <ARSessionOrigin>(); if (arSessionOrigin == null) { Debug.Log($"Adding AR session origin to {arSessionOriginSource.name}"); arSessionOrigin = arSessionOriginSource.AddComponent <ARSessionOrigin>(); } if (arSessionOrigin == null) { Debug.LogError($"Failure acquiring ARSessionOrigin from {arSessionOriginSource.name}, can't create AnchorManagerARF"); } AnchorManagerARF anchorManager = new AnchorManagerARF(plugin, headTracker, arSession, arSessionOrigin); return(anchorManager); }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> private AnchorManagerARF(IPlugin plugin, IHeadPoseTracker headTracker, ARSession arSession, ARSessionOrigin arSessionOrigin) : base(plugin, headTracker) { DebugLogSetup($"ARF: Creating AnchorManagerARF with {arSession.name} and {arSessionOrigin.name}"); this.arSession = arSession; this.arSessionOrigin = arSessionOrigin; #if WLT_XR_MANAGEMENT_PRESENT openXRPersistence = XRGeneralSettings.Instance.Manager.activeLoader.name.StartsWith("Open XR"); #endif // WLT_XR_MANAGEMENT_PRESENT this.arAnchorManager = arSessionOrigin.gameObject.GetComponent <ARAnchorManager>(); if (this.arAnchorManager == null) { DebugLogSetup($"Adding AR reference point manager to {arSessionOrigin.name}"); this.arAnchorManager = arSessionOrigin.gameObject.AddComponent <ARAnchorManager>(); } DebugLogSetup($"ARF: Created AnchorManager ARF"); #if WLT_XR_PERSISTENCE // See notes at OnAnchorsChanged definition. this.arAnchorManager.anchorsChanged += OnAnchorsChanged; #endif // WLT_XR_PERSISTENCE }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> private AnchorManagerWSA(IPlugin plugin, IHeadPoseTracker headTracker) : base(plugin, headTracker) { }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> private AnchorManagerNull(IPlugin plugin, IHeadPoseTracker headTracker) : base(plugin, headTracker) { DebugLogSetup($"Null: Creating AnchorManagerNull"); }
public static AnchorManagerNull TryCreate(IPlugin plugin, IHeadPoseTracker headTracker) { AnchorManagerNull anchorManager = new AnchorManagerNull(plugin, headTracker); return(anchorManager); }
private async Task <IAnchorManager> SelectAnchorManager(IPlugin plugin, IHeadPoseTracker headTracker) { #if false DebugLogSetup($"Select {shared.anchorSettings.anchorSubsystem} anchor manager."); if (AnchorManager != null) { DebugLogSetup("Creating new anchor manager, but have old one. Reseting it before replacing."); AnchorManager.Reset(); } var anchorSettings = shared.anchorSettings; #else if (AnchorManager != null) { DebugLogSetup("Creating new anchor manager, but have old one. Reseting it before replacing."); AnchorManager.Reset(); } var anchorSettings = shared.anchorSettings; #if UNITY_EDITOR if (anchorSettings.NullSubsystemInEditor) { DebugLogSetup($"Switching from {anchorSettings.anchorSubsystem} to AnchorSubsystem.Null because running in editor."); anchorSettings.anchorSubsystem = AnchorSettings.AnchorSubsystem.Null; } #endif // UNITY_EDITOR DebugLogSetup($"Select {anchorSettings.anchorSubsystem} anchor manager."); #endif #if WLT_ARFOUNDATION_PRESENT if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.ARFoundation) { DebugLogSetup($"Trying to create ARF anchor manager on {anchorSettings.ARSessionSource.name} and {anchorSettings.ARSessionOriginSource.name}"); AnchorManagerARF arfAnchorManager = await AnchorManagerARF.TryCreate(plugin, headTracker, anchorSettings.ARSessionSource, anchorSettings.ARSessionOriginSource); if (arfAnchorManager != null) { DebugLogSetup("Success creating ARF anchor manager"); return(arfAnchorManager); } Debug.LogError("Failed to create requested AR Foundation anchor manager!"); } #endif // WLT_ARFOUNDATION_PRESENT #if WLT_ARSUBSYSTEMS_PRESENT if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.XRSDK) { DebugLogSetup($"Trying to create XR anchor manager"); AnchorManagerXR xrAnchorManager = await AnchorManagerXR.TryCreate(plugin, headTracker); if (xrAnchorManager != null) { DebugLogSetup("Success creating XR anchor manager"); return(xrAnchorManager); } Debug.LogError("Failed to create requested XR SDK anchor manager!"); } #endif // WLT_ARSUBSYSTEMS_PRESENT #if UNITY_WSA && !UNITY_2020_1_OR_NEWER if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.WSA) { AnchorManagerWSA wsaAnchorManager = AnchorManagerWSA.TryCreate(plugin, headTracker); if (wsaAnchorManager != null) { DebugLogSetup("Success creating WSA anchor manager"); return(wsaAnchorManager); } Debug.LogError("Failed to create requested WSA anchor manager!"); } #endif // UNITY_WSA #if WLT_ARCORE_SDK_INCLUDED if (anchorSettings.anchorSubsystem == AnchorSettings.AnchorSubsystem.ARCore) { AnchorManagerARCore arCoreAnchorManager = AnchorManagerARCore.TryCreate(plugin, headTracker); if (arCoreAnchorManager != null) { DebugLogSetup("Success creating ARCore anchor manager"); return(arCoreAnchorManager); } Debug.LogError("Failed to create requested ARCore anchor manager!"); } #endif // WLT_ARCORE_SDK_INCLUDED if (anchorSettings.anchorSubsystem != AnchorSettings.AnchorSubsystem.Null) { DebugLogSetup("Failure creating useful anchor manager of any type. Creating null manager"); anchorSettings.anchorSubsystem = AnchorSettings.AnchorSubsystem.Null; shared.anchorSettings = anchorSettings; } AnchorManagerNull nullAnchorManager = AnchorManagerNull.TryCreate(plugin, headTracker); Debug.Assert(nullAnchorManager != null, "Creation of Null anchor manager should never fail."); /// No-op await here to suppress warnings if no anchor manager system which requires asynchronous startup is compiled in. await Task.CompletedTask; return(nullAnchorManager); }
/// <summary> /// Set up an anchor manager. /// </summary> /// <param name="plugin">The engine interface to update with the current anchor graph.</param> private AnchorManagerXR(IPlugin plugin, IHeadPoseTracker headTracker, XRReferencePointSubsystem xrReferencePointManager) : base(plugin, headTracker) { this.xrReferencePointManager = xrReferencePointManager; Debug.Log($"XR: Created AnchorManager XR, xrMgr={(this.xrReferencePointManager != null ? "good" : "null")}"); }