mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 15:08:02 -05:00
ImporterContext.LoadAnimation
This commit is contained in:
parent
2d1211e94b
commit
eca75c54a4
|
|
@ -18,6 +18,8 @@ namespace UniGLTF
|
|||
public TextureFactory TextureFactory { get; }
|
||||
public MaterialFactory MaterialFactory { get; }
|
||||
public AnimationClipFactory AnimationClipFactory { get; }
|
||||
public bool LoadAnimation { get; set; } = true;
|
||||
|
||||
public IReadOnlyDictionary<SubAssetKey, UnityEngine.Object> ExternalObjectMap;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -113,10 +115,13 @@ namespace UniGLTF
|
|||
|
||||
await LoadGeometryAsync(awaitCaller, MeasureTime);
|
||||
|
||||
using (MeasureTime("AnimationImporter"))
|
||||
if (LoadAnimation)
|
||||
{
|
||||
await LoadAnimationAsync(awaitCaller);
|
||||
await SetupAnimationsAsync(awaitCaller);
|
||||
using (MeasureTime("AnimationImporter"))
|
||||
{
|
||||
await LoadAnimationAsync(awaitCaller);
|
||||
await SetupAnimationsAsync(awaitCaller);
|
||||
}
|
||||
}
|
||||
|
||||
await OnLoadHierarchy(awaitCaller, MeasureTime);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace VRM
|
|||
|
||||
// 確実に Dispose するために敢えて再パースしている
|
||||
using (var data = new GlbFileParser(vrmPath).Parse())
|
||||
using (var context = new VRMImporterContext(new VRMData(data), externalObjectMap: map))
|
||||
using (var context = new VRMImporterContext(new VRMData(data), externalObjectMap: map, loadAnimation: true))
|
||||
{
|
||||
var editor = new VRMEditorImporterContext(context, prefabPath);
|
||||
foreach (var textureInfo in context.TextureDescriptorGenerator.Get().GetEnumerable())
|
||||
|
|
|
|||
|
|
@ -25,11 +25,13 @@ namespace VRM
|
|||
VRMData data,
|
||||
IReadOnlyDictionary<SubAssetKey, Object> externalObjectMap = null,
|
||||
ITextureDeserializer textureDeserializer = null,
|
||||
IMaterialDescriptorGenerator materialGenerator = null)
|
||||
IMaterialDescriptorGenerator materialGenerator = null,
|
||||
bool loadAnimation = false)
|
||||
: base(data.Data, externalObjectMap, textureDeserializer, materialGenerator ?? new VRMMaterialDescriptorGenerator(data.VrmExtension))
|
||||
{
|
||||
_data = data;
|
||||
TextureDescriptorGenerator = new VrmTextureDescriptorGenerator(Data, VRM);
|
||||
LoadAnimation = loadAnimation;
|
||||
}
|
||||
|
||||
#region OnLoad
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ namespace VRM
|
|||
public static async Task<RuntimeGltfInstance> LoadAsync(string path,
|
||||
IAwaitCaller awaitCaller = null,
|
||||
MaterialGeneratorCallback materialGeneratorCallback = null,
|
||||
MetaCallback metaCallback = null
|
||||
MetaCallback metaCallback = null,
|
||||
bool loadAnimation = false
|
||||
)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
|
|
@ -38,7 +39,7 @@ namespace VRM
|
|||
{
|
||||
materialGen = materialGeneratorCallback(vrm.VrmExtension);
|
||||
}
|
||||
using (var loader = new VRMImporterContext(vrm, materialGenerator: materialGen))
|
||||
using (var loader = new VRMImporterContext(vrm, materialGenerator: materialGen, loadAnimation: loadAnimation))
|
||||
{
|
||||
if (metaCallback != null)
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -34,6 +34,9 @@ namespace VRM.SimpleViewer
|
|||
[SerializeField]
|
||||
Toggle m_useAsync = default;
|
||||
|
||||
[SerializeField]
|
||||
Toggle m_loadAnimation = default;
|
||||
|
||||
[SerializeField]
|
||||
Toggle m_useFastSpringBone = default;
|
||||
#endregion
|
||||
|
|
@ -386,7 +389,7 @@ namespace VRM.SimpleViewer
|
|||
{
|
||||
VrmUtility.MaterialGeneratorCallback materialCallback = (VRM.glTF_VRM_extensions vrm) => GetVrmMaterialGenerator(m_useUrpMaterial.isOn, vrm);
|
||||
VrmUtility.MetaCallback metaCallback = m_texts.UpdateMeta;
|
||||
var instance = await VrmUtility.LoadAsync(path, GetIAwaitCaller(m_useAsync.isOn), materialCallback, metaCallback);
|
||||
var instance = await VrmUtility.LoadAsync(path, GetIAwaitCaller(m_useAsync.isOn), materialCallback, metaCallback, loadAnimation: m_loadAnimation.isOn);
|
||||
SetModel(instance);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user