public override void OnInspectorGUI() { var entry = target as ARKitReferenceObjectEntry; if (m_ShouldReadARObject) { var path = AssetDatabase.GetAssetPath(entry); m_ARObject = ARObjectImporter.ReadARObject(path); m_ShouldReadARObject = false; } if (m_ARObject.HasValue) { var info = m_ARObject.Value.info; EditorGUILayout.LabelField(Content.info); using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.IntField(Content.infoVersion, info.version); EditorGUILayout.LabelField(Content.referenceOrigin); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.Vector3Field(Content.infoPosition, info.referenceOrigin.position); EditorGUILayout.Vector3Field(Content.infoRotation, info.referenceOrigin.rotation.eulerAngles); } TextureField(m_ARObject.Value.preview); } } else { EditorGUILayout.LabelField("Could not read object info."); } }
static void ValidateReferenceObjects(Warnings warnings) { foreach (var library in ARKitBuildHelper.AssetsOfType <XRReferenceObjectLibrary>()) { var resourceCount = 0; foreach (var referenceObject in library) { if (string.IsNullOrEmpty(referenceObject.name) && (warnings & Warnings.MissingName) != 0) { Debug.LogWarning($"Reference object {library.IndexOf(referenceObject)} named '{referenceObject.name}' in library {AssetDatabase.GetAssetPath(library)} does not have a name. The reference object will still work, but you will not be able to refer to it by name."); } var arkitEntry = referenceObject.FindEntry <ARKitReferenceObjectEntry>(); if (arkitEntry == null) { if ((warnings & Warnings.MissingEntry) != 0) { Debug.LogWarning($"The ARKit variant for reference object {library.IndexOf(referenceObject)} named '{referenceObject.name}' in library {AssetDatabase.GetAssetPath(library)} is missing. This reference object will omitted from the library."); } } else { var assetPath = AssetDatabase.GetAssetPath(arkitEntry); if (string.IsNullOrEmpty(assetPath)) { throw new BuildFailedException($"The ARKit variant for reference object {library.IndexOf(referenceObject)} named '{referenceObject.name}' in reference object library {AssetDatabase.GetAssetPath(library)} does not refer to a valid asset file."); } var info = ARObjectImporter.ReadInfo(assetPath); if (!info.HasValue) { throw new BuildFailedException($"The ARKit variant for reference object {library.IndexOf(referenceObject)} named '{referenceObject.name}' in reference object library {AssetDatabase.GetAssetPath(library)} could not be read. The arobject file may be corrupt."); } if (string.IsNullOrEmpty(info.Value.trackingDataReference)) { throw new BuildFailedException($"The ARKit variant for reference object {library.IndexOf(referenceObject)} named '{referenceObject.name}' in reference object library {AssetDatabase.GetAssetPath(library)} is missing tracking data (the 3D object scan data). The arobject file may be corrupt."); } resourceCount++; } } if (resourceCount == 0 && (warnings & Warnings.EmptyLibrary) != 0) { Debug.LogWarning($"Reference object library at {AssetDatabase.GetAssetPath(library)} does not contain any ARKit reference objects. The library will be empty."); } } }
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(); }