Skip to content

Commit

Permalink
chore: update gltf plugin (#180)
Browse files Browse the repository at this point in the history
Updated Rider package. Updated gltfFast plugin
  • Loading branch information
AlejandroAlvarezMelucciDCL authored Dec 6, 2024
1 parent 9523a4d commit ffcb8bc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
using System.Threading.Tasks;
using GLTFast.Loading;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace AssetBundleConverter.Wrappers.Implementations.Default
{
#pragma warning disable 1998

class SyncFileLoader : IDownload
internal class SyncFileLoader : IDownload
{
public SyncFileLoader(Uri url)
{
Expand Down Expand Up @@ -44,13 +43,13 @@ public bool? IsBinary
public void Dispose() { }
}

static class GltfGlobals
internal static class GltfGlobals
{
/// <summary>
/// First four bytes of a glTF-Binary file are made up of this signature
/// Represents glTF in ASCII
/// </summary>
internal const uint GLB_MAGIC = 0x46546c67;
private const uint GLB_MAGIC = 0x46546c67;

/// <summary>
/// Figures out if a byte array contains data of a glTF-Binary
Expand All @@ -67,7 +66,7 @@ public static bool IsGltfBinary(byte[] data)
}
}

class SyncTextureLoader : SyncFileLoader, ITextureDownload
internal class SyncTextureLoader : SyncFileLoader, ITextureDownload
{
public Texture2D Texture { get; }

Expand All @@ -92,10 +91,10 @@ public class GltFastFileProvider : IEditorDownloadProvider, IDisposable
private readonly Dictionary<string, string> contentTable;

// Note (Kinerius): Since we can get multiple dependencies with the same name ( mostly textures ) we have to use the glb original root to determine which of them to use
// for example 'models/Genesis_TX.png' and 'models/core_building/Genesis_TX.png', the importer is going to ask for Genesis_TX.png since its path is relative
// for example 'models/Genesis_TX.png' and 'models/core_building/Genesis_TX.png', the importer is going to ask for Genesis_TX.png since its path is relative,
// so we have to create a new path using the original root path that is already mapped by the asset bundle converter.
private string fileRootPath;
private string hash;
private readonly string fileRootPath;
private readonly string hash;
private readonly List<GltfAssetDependency> gltfAssetDependencies = new ();

public GltFastFileProvider(string fileRootPath, string hash, Dictionary<string, string> contentTable)
Expand All @@ -105,7 +104,7 @@ public GltFastFileProvider(string fileRootPath, string hash, Dictionary<string,
this.contentTable = contentTable;
}

public async Task<IDownload> Request(Uri url)
public async Task<IDownload> RequestAsync(Uri url)
{
Uri newUrl = GetDependenciesPaths(RebuildUrl(url));

Expand All @@ -119,7 +118,7 @@ public async Task<IDownload> Request(Uri url)
return new SyncFileLoader(newUrl);
}

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

Expand All @@ -136,7 +135,7 @@ public async Task<ITextureDownload> RequestTexture(Uri url, bool nonReadable, bo
private Uri RebuildUrl(Uri url)
{
var absolutePath = url.OriginalString;
string relativePath = $"{fileRootPath}{absolutePath.Substring(absolutePath.IndexOf(hash) + hash.Length + 1)}";
string relativePath = $"{fileRootPath}{absolutePath.Substring(absolutePath.IndexOf(hash, StringComparison.Ordinal) + hash.Length + 1)}";
relativePath = relativePath.Replace("\\", "/");
return new Uri(relativePath, UriKind.Relative);
}
Expand Down
2 changes: 1 addition & 1 deletion asset-bundle-converter/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"com.unity.ai.navigation": "1.1.5",
"com.unity.assetbundlebrowser": "https://github.com/Unity-Technologies/AssetBundles-Browser.git",
"com.unity.collab-proxy": "2.2.0",
"com.unity.ide.rider": "3.0.25",
"com.unity.ide.rider": "3.0.34",
"com.unity.ide.visualstudio": "2.0.21",
"com.unity.ide.vscode": "1.2.5",
"com.unity.meshopt.decompress": "0.1.0-preview.5",
Expand Down
6 changes: 3 additions & 3 deletions asset-bundle-converter/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.25",
"version": "3.0.34",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down Expand Up @@ -101,8 +101,8 @@
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.2.1",
"com.unity.burst": "1.4.11"
"com.unity.burst": "1.4.11",
"com.unity.mathematics": "1.2.1"
},
"url": "https://packages.unity.com"
},
Expand Down

0 comments on commit ffcb8bc

Please sign in to comment.