/// <summary> /// Invoked when a new [XRReferenceObject](xref:UnityEngine.XR.ARSubsystems.XRReferenceObject) is added to an /// [XRReferenceObjectLibrary](xref:UnityEngine.XR.ARSubsystems.XRReferenceObjectLibrary). /// </summary> /// <param name="library">The library to which the reference object is being added.</param> /// <param name="xrReferenceObject">The reference object being added to the <paramref name="library"/>.</param> protected override void OnAddToLibrary(XRReferenceObjectLibrary library, XRReferenceObject xrReferenceObject) { base.OnAddToLibrary(library, xrReferenceObject); if (m_ARKitReferenceObject == null) { return; } var instance = XRGeneralSettings.Instance; if (instance == null) { return; } var manager = instance.Manager; if (manager == null) { return; } var loader = manager.activeLoader; if (loader == null) { return; } if (loader.GetLoadedSubsystem <XRObjectTrackingSubsystem>() is ARKitXRObjectTrackingSubsystem subsystem) { subsystem.AddReferenceObject(library, GetARKitReferenceObject(xrReferenceObject)); } }
public ARReferenceObject(XRReferenceObject referenceObject, ARKitReferenceObjectEntry entry) { m_Path = AssetDatabase.GetAssetPath(entry); if (string.IsNullOrEmpty(m_Path)) { throw new InvalidAssetPathException(); } var info = ARObjectImporter.ReadInfo(m_Path); if (!info.HasValue) { throw new MissingMetadataException(); } else if (string.IsNullOrEmpty(info.Value.trackingDataReference)) { throw new MissingTrackingDataException(); } name = referenceObject.name + "_" + referenceObject.guid.ToUUIDString(); }
internal ARReferenceObject GetARKitReferenceObject(XRReferenceObject referenceObject) { m_ARKitReferenceObject.SetName(referenceObject); return(m_ARKitReferenceObject); }
/// <summary> /// Invoked when an <see cref="XRReferenceObject"/> is added to an <see cref="XRReferenceObjectLibrary"/>. /// </summary> /// <remarks> /// Override this method if your <see cref="XRReferenceObjectEntry"/> needs to perform logic when a novel /// <see cref="XRReferenceObject"/> is added to an <see cref="XRReferenceObjectLibrary"/>. /// /// The default implementation takes no action and has no effect. /// </remarks> /// <param name="library">The library to which <param name="referenceObject"> is being added.</param></param> /// <param name="referenceObject">The reference object being added to <paramref name="library"/>.</param> protected internal virtual void OnAddToLibrary(XRReferenceObjectLibrary library, XRReferenceObject referenceObject) { }