Skip to content

Commit

Permalink
feat: Updated unity version and dependencies (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinerius authored Apr 5, 2023
1 parent 50b5375 commit 063885b
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"overrideReferences": true,
"precompiledReferences": [
"Newtonsoft.Json.dll",
"Sentry.dll"
"Sentry.dll",
"Unity.Plastic.Newtonsoft.Json.dll"
],
"autoReferenced": true,
"defineConstraints": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -111,7 +113,7 @@ public static async Task WaitUntilAsync(Func<bool> predicate, int sleep = 50)
/// </summary>
/// <param name="rawContents"></param>
/// <returns></returns>
public async Task<State> Convert(IReadOnlyList<ContentServerUtils.MappingPair> rawContents)
public async Task<State> ConvertAsync(IReadOnlyList<ContentServerUtils.MappingPair> rawContents)
{
log.verboseEnabled = settings.verbose;
var scene = EditorSceneManager.OpenScene(SCENE_NAME, OpenSceneMode.Single);
Expand Down Expand Up @@ -147,13 +149,17 @@ public async Task<State> Convert(IReadOnlyList<ContentServerUtils.MappingPair> r
// Third step: we import gltfs
importStartupTime = EditorApplication.timeSinceStartup;

if (isExitForced) return CurrentState;

if (await ImportAllGltf())
{
OnFinish();

return CurrentState;
}

if (isExitForced) return CurrentState;

importEndTime = EditorApplication.timeSinceStartup;

EditorUtility.ClearProgressBar();
Expand Down Expand Up @@ -188,6 +194,8 @@ public async Task<State> Convert(IReadOnlyList<ContentServerUtils.MappingPair> r
bundlesEndTime = EditorApplication.timeSinceStartup;
}

if (isExitForced) return CurrentState;

if (settings.visualTest)
{
visualTestStartupTime = EditorApplication.timeSinceStartup;
Expand Down Expand Up @@ -215,6 +223,8 @@ private async Task<bool> ImportAllGltf()

foreach (GltfImportSettings gltf in gltfToWait)
{
if (isExitForced) break;

var gltfUrl = gltf.url;
var gltfImport = gltf.import;

Expand Down Expand Up @@ -291,7 +301,7 @@ private async Task<bool> 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;
}
}
Expand All @@ -300,7 +310,7 @@ private async Task<bool> 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;
}

Expand Down Expand Up @@ -333,7 +343,7 @@ private async Task<bool> 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;
}
}
Expand Down Expand Up @@ -407,7 +417,7 @@ private void ExtractEmbedMaterialsFromGltf(List<Texture2D> 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;
}
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -727,6 +737,8 @@ private bool DownloadAssets(IReadOnlyList<ContentServerUtils.MappingPair> rawCon

foreach (var gltfPath in gltfPaths)
{
if (isExitForced) break;

if (!string.IsNullOrEmpty(settings.importOnlyEntity))
if (!string.Equals(gltfPath.hash, settings.importOnlyEntity, StringComparison.CurrentCultureIgnoreCase))
continue;
Expand Down Expand Up @@ -807,6 +819,8 @@ internal List<AssetPath> DownloadImportableAssets(List<AssetPath> assetPaths)

for (var i = 0; i < assetPaths.Count; i++)
{
if (isExitForced) break;

EditorUtility.DisplayProgressBar("Asset Bundle Converter", "Downloading Importable Assets",
i / (float)assetPaths.Count);

Expand Down Expand Up @@ -838,11 +852,9 @@ internal List<AssetPath> DownloadImportableAssets(List<AssetPath> 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);

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand All @@ -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();
}

/// <summary>
Expand All @@ -1030,6 +1039,8 @@ internal List<AssetPath> DownloadRawAssets(List<AssetPath> bufferPaths)

for (var i = 0; i < bufferPaths.Count; i++)
{
if (isExitForced) break;

EditorUtility.DisplayProgressBar("Asset Bundle Converter", "Downloading Raw Assets",
i / (float)bufferPaths.Count);

Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -113,7 +116,7 @@ public async Task<IDownload> Request(Uri url)
return new SyncFileLoader(newUrl);
}

public async Task<ITextureDownload> RequestTexture(Uri url, bool nonReadable)
public async Task<ITextureDownload> RequestTexture(Uri url, bool nonReadable, bool forceLinear)
{
Uri newUrl = GetDependenciesPaths(RebuildUrl(url));

Expand Down
8 changes: 0 additions & 8 deletions asset-bundle-converter/Assets/_Downloaded.meta

This file was deleted.

8 changes: 4 additions & 4 deletions asset-bundle-converter/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 12 additions & 32 deletions asset-bundle-converter/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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"
}
},
Expand Down
Loading

0 comments on commit 063885b

Please sign in to comment.