Skip to content

Commit

Permalink
refactoring dataloader verify in sceneimporter
Browse files Browse the repository at this point in the history
  • Loading branch information
pfcDorn committed Oct 5, 2023
1 parent 5723e55 commit f550189
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Runtime/Scripts/GLTFSceneImporter.cs
Expand Up @@ -289,16 +289,7 @@ public GLTFSceneImporter(string gltfFileName, ImportOptions options)
else
Debug = UnityEngine.Debug.unityLogger;

if (_options.DataLoader == null)
{
if (_options.ExternalDataLoader == null)
{
_options.DataLoader = new UnityWebRequestLoader(URIHelper.GetDirectoryName(gltfFileName));
_gltfFileName = URIHelper.GetFileFromUri(new Uri(_gltfFileName));
}
else
_options.DataLoader = LegacyLoaderWrapper.Wrap(_options.ExternalDataLoader);
}
VerifyDataLoader();
}

public GLTFSceneImporter(GLTFRoot rootNode, Stream gltfStream, ImportOptions options)
Expand All @@ -316,9 +307,20 @@ public GLTFSceneImporter(GLTFRoot rootNode, Stream gltfStream, ImportOptions opt
}

_options = options;
VerifyDataLoader();
}

private void VerifyDataLoader()
{
if (_options.DataLoader == null)
{
_options.DataLoader = LegacyLoaderWrapper.Wrap(_options.ExternalDataLoader);
if (_options.ExternalDataLoader == null)
{
_options.DataLoader = new UnityWebRequestLoader(URIHelper.GetDirectoryName(_gltfFileName));
_gltfFileName = URIHelper.GetFileFromUri(new Uri(_gltfFileName));
}
else
_options.DataLoader = LegacyLoaderWrapper.Wrap(_options.ExternalDataLoader);
}
}

Expand Down

0 comments on commit f550189

Please sign in to comment.