diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs b/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs index eb6cd9c6..e4159728 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs @@ -11,7 +11,6 @@ using GLTFast; using GLTFast.Logging; using GLTFast.Materials; -using System.Threading; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; @@ -212,11 +211,11 @@ private async Task ImportAllGltf() foreach (GltfImportSettings gltf in gltfToWait) { + var gltfUrl = gltf.url; + var gltfImport = gltf.import; + try { - var gltfUrl = gltf.url; - var gltfImport = gltf.import; - EditorUtility.DisplayProgressBar("Asset Bundle Converter", $"Loading GLTF {gltfUrl}", loadedGltf / (float)totalGltfToLoad); @@ -287,6 +286,7 @@ private async Task ImportAllGltf() if (importedGameObject == null) { var message = "Fatal error when importing this object, check previous error messages"; + log.Error(message); errorReporter.ReportError(message, settings); Utils.Exit((int)ErrorCodes.GLTFAST_CRITICAL_ERROR); break; @@ -297,7 +297,6 @@ private async Task ImportAllGltf() var message = $"Failed to get the gltf importer for {gltfUrl} \nPath: {relativePath}"; log.Error(message); errorReporter.ReportError(message, settings); - EditorUtility.ClearProgressBar(); continue; } @@ -326,9 +325,11 @@ private async Task ImportAllGltf() } catch (Exception e) { - log.Exception(e.ToString()); + log.Error("UNCAUGHT FATAL: Failed to load GLTF " + gltf.AssetPath.hash); + Debug.LogException(e); errorReporter.ReportException(new ConversionException(ConversionStep.Import, settings, e)); - continue; + Utils.Exit((int)ErrorCodes.GLTFAST_CRITICAL_ERROR); + break; } } @@ -394,7 +395,13 @@ private void CreateMaterialsForThisGltf(List textures, GltfImportSett else { if (prevTexture == null) - log.Error($"Failed to set texture \"{texName}\" to material \"{matName}\". This will cause white materials"); + { + var message = $"Failed to set texture \"{texName}\" to material \"{matName}\". This will cause white materials"; + log.Error(message); + errorReporter.ReportError(message, settings); + Utils.Exit((int)ErrorCodes.GLTFAST_CRITICAL_ERROR); + return; + } } } @@ -426,16 +433,11 @@ private List CreateTextureAssets(List textures, string fol for (int i = 0; i < textures.Count; i++) { var tex = textures[i]; - var ext = ".png"; string texName = tex.name; texName = Utils.NicifyName(texName); var texPath = string.Concat(texturesRoot, texName); - // some textures might already contain the extension, adding it a second time confuses unity into an exception - if (!texPath.EndsWith(".png")) - texPath = string.Concat(texPath, ext); - texPath = texPath.Replace('\\', '/'); var absolutePath = $"{Application.dataPath}/../{texPath}"; @@ -443,19 +445,33 @@ private List CreateTextureAssets(List textures, string fol if (File.Exists(absolutePath)) { - newTextures.Add(AssetDatabase.LoadAssetAtPath(PathUtils.GetRelativePathTo(Application.dataPath, absolutePath))); - continue; + Texture2D loadedAsset = AssetDatabase.LoadAssetAtPath(PathUtils.GetRelativePathTo(Application.dataPath, absolutePath)); + + if (loadedAsset != null) + { + newTextures.Add(loadedAsset); + continue; + } } if (!string.IsNullOrEmpty(texturePath)) { - newTextures.Add(AssetDatabase.LoadAssetAtPath(texPath)); - continue; + Texture2D loadedAsset = AssetDatabase.LoadAssetAtPath(texturePath); + + if (loadedAsset != null) + { + newTextures.Add(loadedAsset); + continue; + } } if (!Directory.Exists(texturesRoot)) Directory.CreateDirectory(texturesRoot); + // We are always encoding to PNG + if (!Path.HasExtension(texPath)) + texPath += ".png"; + if (tex.isReadable) { File.WriteAllBytes(texPath, tex.EncodeToPNG()); } else { diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/Editor/CustomGltfImporter.cs b/asset-bundle-converter/Assets/AssetBundleConverter/Editor/CustomGltfImporter.cs index 71673de5..fb77ea5b 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/Editor/CustomGltfImporter.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/Editor/CustomGltfImporter.cs @@ -77,7 +77,12 @@ public override void OnImportAsset(AssetImportContext ctx) SetupCustomMaterialGenerator(new AssetBundleConverterMaterialGenerator()); try { base.OnImportAsset(ctx); } - catch (Exception e) { Debug.LogException(e); } + catch (Exception e) + { + Debug.LogError("UNCAUGHT FATAL: Failed to Import GLTF " + hash); + Debug.LogException(e); + Utils.Exit((int)DCL.ABConverter.AssetBundleConverter.ErrorCodes.GLTFAST_CRITICAL_ERROR); + } } protected override void CreateMaterialAssets(AssetImportContext ctx) @@ -166,15 +171,17 @@ private void FixTextureReferences(List textures, string folderName, L string texPath = AssetDatabase.GetAssetPath(tex); if (string.IsNullOrEmpty(texPath)) + { texPath = $"{folderName}{separator}Textures{separator}{tex.name}"; - texPath = texPath.Replace(separator, '/'); + texPath = texPath.Replace(separator, '/'); - //remove all whitespaces - texPath = Regex.Replace(texPath, @"\s+", ""); + //remove all whitespaces + texPath = Regex.Replace(texPath, @"\s+", ""); - if (!texPath.EndsWith(".png")) - texPath += ".png"; + if (!Path.HasExtension(texPath)) + texPath += ".png"; + } //var importedTex = AssetDatabase.LoadAssetAtPath(texPath); var importer = GetAtPath(texPath); @@ -205,7 +212,10 @@ private void FixTextureReferences(List textures, string folderName, L EditorUtility.SetDirty(tImporter); tImporter.SaveAndReimport(); } - else { Debug.LogError($"GLTFImporter: Unable to import texture at path: {texPath}"); } + else + { + throw new Exception($"GLTFImporter: Unable to import texture at path: {texPath}"); + } } } } diff --git a/asset-bundle-converter/Assets/Plugins/Sentry/SentryRuntimeOptionsConfiguration.cs b/asset-bundle-converter/Assets/Plugins/Sentry/SentryRuntimeOptionsConfiguration.cs deleted file mode 100644 index f97d3b14..00000000 --- a/asset-bundle-converter/Assets/Plugins/Sentry/SentryRuntimeOptionsConfiguration.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using UnityEngine; -using Sentry.Unity; - -[CreateAssetMenu(fileName = "Assets/Resources/Sentry/SentryRuntimeOptionsConfiguration.asset", menuName = "Sentry/Assets/Resources/Sentry/SentryRuntimeOptionsConfiguration.asset", order = 999)] -public class SentryRuntimeOptionsConfiguration : Sentry.Unity.ScriptableOptionsConfiguration -{ - /// See base class for documentation. - /// Learn more at https://docs.sentry.io/platforms/unity/configuration/options/#programmatic-configuration - public override void Configure(SentryUnityOptions options) - { - // TODO implement - } -} diff --git a/asset-bundle-converter/Assets/Plugins/Sentry/SentryRuntimeOptionsConfiguration.cs.meta b/asset-bundle-converter/Assets/Plugins/Sentry/SentryRuntimeOptionsConfiguration.cs.meta deleted file mode 100644 index a74f2d46..00000000 --- a/asset-bundle-converter/Assets/Plugins/Sentry/SentryRuntimeOptionsConfiguration.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d80e0cee32da9c4f9109c53d1a12f13 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/asset-bundle-converter/Packages/packages-lock.json b/asset-bundle-converter/Packages/packages-lock.json index 360cfefd..27563760 100644 --- a/asset-bundle-converter/Packages/packages-lock.json +++ b/asset-bundle-converter/Packages/packages-lock.json @@ -186,7 +186,7 @@ "depth": 0, "source": "git", "dependencies": {}, - "hash": "b562146d739c6f99a76e2b4147a7e034e4344fa8" + "hash": "77a57521b9ee47969dfcdc529c01dc9077a69223" }, "com.unity.modules.ai": { "version": "1.0.0",