diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 485b15ef..bcfa038d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,7 +29,7 @@ jobs: context: . push: ${{ github.ref == 'refs/heads/main' }} tags: quay.io/decentraland/asset-bundle-converter:next,quay.io/decentraland/asset-bundle-converter:${{ github.sha }} - # load: true + #load: true cache-from: type=gha cache-to: type=gha,mode=max build-args: | diff --git a/Dockerfile b/Dockerfile index 1251d901..3219de4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN npm ci --only=production ########################## END OF BUILD STAGE ########################## -FROM unityci/editor:2021.3.14f1-webgl-1 +FROM unityci/editor:2021.3.20f1-webgl-1 RUN apt-get update -y \ && apt-get -y install \ diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.asmdef b/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.asmdef index fc2d231f..185167fc 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.asmdef +++ b/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.asmdef @@ -22,7 +22,8 @@ "overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", - "Sentry.dll" + "Sentry.dll", + "Unity.Plastic.Newtonsoft.Json.dll" ], "autoReferenced": true, "defineConstraints": [], diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs b/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs index 6368ba56..bddc4716 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/AssetBundleConverter.cs @@ -88,6 +88,8 @@ public enum Step private double visualTestStartupTime; private double visualTestEndTime; + private bool isExitForced = false; + public AssetBundleConverter(Environment env, ClientSettings settings) { this.settings = settings; @@ -111,7 +113,7 @@ public static async Task WaitUntilAsync(Func predicate, int sleep = 50) /// /// /// - public async Task Convert(IReadOnlyList rawContents) + public async Task ConvertAsync(IReadOnlyList rawContents) { log.verboseEnabled = settings.verbose; var scene = EditorSceneManager.OpenScene(SCENE_NAME, OpenSceneMode.Single); @@ -147,6 +149,8 @@ public async Task Convert(IReadOnlyList r // Third step: we import gltfs importStartupTime = EditorApplication.timeSinceStartup; + if (isExitForced) return CurrentState; + if (await ImportAllGltf()) { OnFinish(); @@ -154,6 +158,8 @@ public async Task Convert(IReadOnlyList r return CurrentState; } + if (isExitForced) return CurrentState; + importEndTime = EditorApplication.timeSinceStartup; EditorUtility.ClearProgressBar(); @@ -188,6 +194,8 @@ public async Task Convert(IReadOnlyList r bundlesEndTime = EditorApplication.timeSinceStartup; } + if (isExitForced) return CurrentState; + if (settings.visualTest) { visualTestStartupTime = EditorApplication.timeSinceStartup; @@ -215,6 +223,8 @@ private async Task ImportAllGltf() foreach (GltfImportSettings gltf in gltfToWait) { + if (isExitForced) break; + var gltfUrl = gltf.url; var gltfImport = gltf.import; @@ -291,7 +301,7 @@ private async Task ImportAllGltf() 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); + ForceExit((int)ErrorCodes.GLTFAST_CRITICAL_ERROR); break; } } @@ -300,7 +310,7 @@ private async Task ImportAllGltf() var message = $"Failed to get the gltf importer for {gltfUrl} \nPath: {relativePath}"; log.Error(message); errorReporter.ReportError(message, settings); - Utils.Exit((int)ErrorCodes.GLTF_IMPORTER_NOT_FOUND); + ForceExit((int)ErrorCodes.GLTF_IMPORTER_NOT_FOUND); continue; } @@ -333,7 +343,7 @@ private async Task ImportAllGltf() log.Error("UNCAUGHT FATAL: Failed to load GLTF " + gltf.AssetPath.hash); Debug.LogException(e); errorReporter.ReportException(new ConversionException(ConversionStep.Import, settings, e)); - Utils.Exit((int)ErrorCodes.GLTFAST_CRITICAL_ERROR); + ForceExit((int)ErrorCodes.GLTFAST_CRITICAL_ERROR); break; } } @@ -407,7 +417,7 @@ private void ExtractEmbedMaterialsFromGltf(List textures, GltfImportS 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.EMBED_MATERIAL_FAILURE); + ForceExit((int)ErrorCodes.EMBED_MATERIAL_FAILURE); return; } } @@ -576,7 +586,7 @@ public void CleanAndExit(ErrorCodes errorCode) log.Info(logBuffer); Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.ScriptOnly); - Utils.Exit((int)errorCode); + ForceExit((int)errorCode); } internal void CleanupWorkingFolders() @@ -620,7 +630,7 @@ public virtual bool BuildAssetBundles(out AssetBundleManifest manifest) var message = "Error generating asset bundle!"; log.Error(message); errorReporter.ReportError(message, settings); - Utils.Exit((int)ErrorCodes.ASSET_BUNDLE_BUILD_FAIL); + ForceExit((int)ErrorCodes.ASSET_BUNDLE_BUILD_FAIL); return false; } @@ -727,6 +737,8 @@ private bool DownloadAssets(IReadOnlyList rawCon foreach (var gltfPath in gltfPaths) { + if (isExitForced) break; + if (!string.IsNullOrEmpty(settings.importOnlyEntity)) if (!string.Equals(gltfPath.hash, settings.importOnlyEntity, StringComparison.CurrentCultureIgnoreCase)) continue; @@ -807,6 +819,8 @@ internal List DownloadImportableAssets(List assetPaths) for (var i = 0; i < assetPaths.Count; i++) { + if (isExitForced) break; + EditorUtility.DisplayProgressBar("Asset Bundle Converter", "Downloading Importable Assets", i / (float)assetPaths.Count); @@ -838,11 +852,9 @@ internal List DownloadImportableAssets(List assetPaths) ReduceTextureSizeIfNeeded(finalTexturePath, MAX_TEXTURE_SIZE); } - else - { - env.assetDatabase.ImportAsset(assetPath.finalPath, ImportAssetOptions.ForceUpdate); - env.assetDatabase.SaveAssets(); - } + + env.assetDatabase.ImportAsset(assetPath.finalPath, ImportAssetOptions.ForceUpdate); + env.assetDatabase.SaveAssets(); SetDeterministicAssetDatabaseGuid(assetPath); @@ -951,7 +963,7 @@ void FinallyImportAsset() var message = $"Download Failed {finalUrl} -- {e.Message}"; log.Error(message); errorReporter.ReportError(message, settings); - Utils.Exit((int)ErrorCodes.DOWNLOAD_FAILED); + ForceExit((int)ErrorCodes.DOWNLOAD_FAILED); return null; } @@ -998,7 +1010,7 @@ private void ReduceTextureSizeIfNeeded(string texturePath, float maxSize) float maxTextureSize = maxSize; - if (width < maxTextureSize && height < maxTextureSize) + if (width <= maxTextureSize && height <= maxTextureSize) return; if (width >= height) @@ -1011,9 +1023,6 @@ private void ReduceTextureSizeIfNeeded(string texturePath, float maxSize) Object.DestroyImmediate(tmpTex); File.WriteAllBytes(texturePath, endTex); - - AssetDatabase.ImportAsset(PathUtils.GetRelativePathTo(Application.dataPath, texturePath), ImportAssetOptions.ForceUpdate); - AssetDatabase.SaveAssets(); } /// @@ -1030,6 +1039,8 @@ internal List DownloadRawAssets(List bufferPaths) for (var i = 0; i < bufferPaths.Count; i++) { + if (isExitForced) break; + EditorUtility.DisplayProgressBar("Asset Bundle Converter", "Downloading Raw Assets", i / (float)bufferPaths.Count); @@ -1060,5 +1071,11 @@ internal AssetPath DownloadGltf(AssetPath gltfPath) return path != null ? gltfPath : null; } + + private void ForceExit(int errorCode = 0) + { + isExitForced = true; + Utils.Exit(errorCode); + } } } diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/SceneClient.cs b/asset-bundle-converter/Assets/AssetBundleConverter/SceneClient.cs index 6a0e97af..09e980aa 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/SceneClient.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/SceneClient.cs @@ -318,13 +318,12 @@ private static AssetBundleConverter.State GetUnexpectedResult() => log.Info($"Converting {mappingPairs.Count} entities..."); - if (settings.verbose) - log.Info(string.Join('\n',mappingPairs.Select(mp => mp.file))); + log.Info(string.Join('\n',mappingPairs.Select(mp => mp.file))); EnsureEnvironment(); var core = new AssetBundleConverter(env, settings); - await core.Convert(mappingPairs); + await core.ConvertAsync(mappingPairs); return core.CurrentState; } } diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/Utils.cs b/asset-bundle-converter/Assets/AssetBundleConverter/Utils.cs index 16f7a5a4..07eedcbb 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/Utils.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/Utils.cs @@ -7,7 +7,7 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; -using Newtonsoft.Json; +using Unity.Plastic.Newtonsoft.Json; using UnityEditor; using UnityEngine; using UnityEngine.Networking; diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/Wrappers/Implementations/Default/GltFastFileProvider.cs b/asset-bundle-converter/Assets/AssetBundleConverter/Wrappers/Implementations/Default/GltFastFileProvider.cs index 50642603..704dfa8f 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/Wrappers/Implementations/Default/GltFastFileProvider.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/Wrappers/Implementations/Default/GltFastFileProvider.cs @@ -70,6 +70,9 @@ class SyncTextureLoader : SyncFileLoader, ITextureDownload public override bool Success => Texture != null; + public IDisposableTexture GetTexture(bool forceSampleLinear) => + new NonReusableTexture(Texture); + public SyncTextureLoader(Uri url) : base(url) { @@ -113,7 +116,7 @@ public async Task Request(Uri url) return new SyncFileLoader(newUrl); } - public async Task RequestTexture(Uri url, bool nonReadable) + public async Task RequestTexture(Uri url, bool nonReadable, bool forceLinear) { Uri newUrl = GetDependenciesPaths(RebuildUrl(url)); diff --git a/asset-bundle-converter/Assets/_Downloaded.meta b/asset-bundle-converter/Assets/_Downloaded.meta deleted file mode 100644 index e24e848e..00000000 --- a/asset-bundle-converter/Assets/_Downloaded.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 992694523e1955b43a048366d55a2407 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/asset-bundle-converter/Assets/git-submodules/glTFast b/asset-bundle-converter/Assets/git-submodules/glTFast index 12bd7a9a..c2306e81 160000 --- a/asset-bundle-converter/Assets/git-submodules/glTFast +++ b/asset-bundle-converter/Assets/git-submodules/glTFast @@ -1 +1 @@ -Subproject commit 12bd7a9ad8e709610e3e659df6bb211392ce1bac +Subproject commit c2306e81cfac1520a945a76e818306912d896255 diff --git a/asset-bundle-converter/Assets/git-submodules/unity-shared-dependencies b/asset-bundle-converter/Assets/git-submodules/unity-shared-dependencies index 5577bd12..1b462119 160000 --- a/asset-bundle-converter/Assets/git-submodules/unity-shared-dependencies +++ b/asset-bundle-converter/Assets/git-submodules/unity-shared-dependencies @@ -1 +1 @@ -Subproject commit 5577bd123883e2fa96f51b8d534abd75bad0535f +Subproject commit 1b462119ed2ca0a100d22cea1e482d28dde41dc8 diff --git a/asset-bundle-converter/Packages/manifest.json b/asset-bundle-converter/Packages/manifest.json index d916dd8f..7ec4f0e5 100644 --- a/asset-bundle-converter/Packages/manifest.json +++ b/asset-bundle-converter/Packages/manifest.json @@ -2,12 +2,12 @@ "dependencies": { "com.atteneder.draco": "4.0.2", "com.atteneder.ktx": "2.2.3", - "com.unity.collab-proxy": "1.17.6", - "com.unity.ide.rider": "3.0.16", - "com.unity.ide.visualstudio": "2.0.16", + "com.unity.collab-proxy": "2.0.1", + "com.unity.ide.rider": "3.0.18", + "com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.vscode": "1.2.5", "com.unity.meshopt.decompress": "0.1.0-preview.5", - "com.unity.render-pipelines.universal": "12.1.8", + "com.unity.render-pipelines.universal": "12.1.10", "com.unity.test-framework": "1.1.31", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.4", diff --git a/asset-bundle-converter/Packages/packages-lock.json b/asset-bundle-converter/Packages/packages-lock.json index 27563760..4f57d5a2 100644 --- a/asset-bundle-converter/Packages/packages-lock.json +++ b/asset-bundle-converter/Packages/packages-lock.json @@ -19,7 +19,7 @@ "url": "https://package.openupm.com" }, "com.unity.burst": { - "version": "1.7.3", + "version": "1.8.2", "depth": 1, "source": "registry", "dependencies": { @@ -28,12 +28,10 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "1.17.6", + "version": "2.0.1", "depth": 0, "source": "registry", - "dependencies": { - "com.unity.services.core": "1.0.1" - }, + "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.ext.nunit": { @@ -44,7 +42,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.16", + "version": "3.0.18", "depth": 0, "source": "registry", "dependencies": { @@ -53,7 +51,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.16", + "version": "2.0.17", "depth": 0, "source": "registry", "dependencies": { @@ -85,15 +83,8 @@ }, "url": "https://packages.unity.com" }, - "com.unity.nuget.newtonsoft-json": { - "version": "3.0.2", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, "com.unity.render-pipelines.core": { - "version": "12.1.8", + "version": "12.1.10", "depth": 1, "source": "builtin", "dependencies": { @@ -103,14 +94,14 @@ } }, "com.unity.render-pipelines.universal": { - "version": "12.1.8", + "version": "12.1.10", "depth": 0, "source": "builtin", "dependencies": { "com.unity.mathematics": "1.2.1", - "com.unity.burst": "1.7.3", - "com.unity.render-pipelines.core": "12.1.8", - "com.unity.shadergraph": "12.1.8" + "com.unity.burst": "1.8.2", + "com.unity.render-pipelines.core": "12.1.10", + "com.unity.shadergraph": "12.1.10" } }, "com.unity.searcher": { @@ -120,23 +111,12 @@ "dependencies": {}, "url": "https://packages.unity.com" }, - "com.unity.services.core": { - "version": "1.6.0", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.nuget.newtonsoft-json": "3.0.2", - "com.unity.modules.androidjni": "1.0.0" - }, - "url": "https://packages.unity.com" - }, "com.unity.shadergraph": { - "version": "12.1.8", + "version": "12.1.10", "depth": 1, "source": "builtin", "dependencies": { - "com.unity.render-pipelines.core": "12.1.8", + "com.unity.render-pipelines.core": "12.1.10", "com.unity.searcher": "4.9.1" } }, diff --git a/asset-bundle-converter/ProjectSettings/ProjectVersion.txt b/asset-bundle-converter/ProjectSettings/ProjectVersion.txt index 6a95707e..ed449d8d 100644 --- a/asset-bundle-converter/ProjectSettings/ProjectVersion.txt +++ b/asset-bundle-converter/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.14f1 -m_EditorVersionWithRevision: 2021.3.14f1 (eee1884e7226) +m_EditorVersion: 2021.3.20f1 +m_EditorVersionWithRevision: 2021.3.20f1 (577897200b8b)