diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/IAnimationImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/IAnimationImporter.cs deleted file mode 100644 index 6e9a2f773b..0000000000 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/IAnimationImporter.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -using VRMShaders; - -namespace UniGLTF -{ - public interface IAnimationImporter - { - AnimationClip Import(glTF gltf, int i, Axes invertAxis); - } -} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/IAnimationImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/IAnimationImporter.cs.meta deleted file mode 100644 index 83586e0860..0000000000 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/IAnimationImporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4f950ba9271cbff4cbc4345f5a23a5d8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/RootAnimationImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/RootAnimationImporter.cs deleted file mode 100644 index 980caec8a4..0000000000 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/RootAnimationImporter.cs +++ /dev/null @@ -1,12 +0,0 @@ -using UnityEngine; - -namespace UniGLTF -{ - public sealed class RootAnimationImporter : IAnimationImporter - { - public AnimationClip Import(glTF gltf, int i, Axes invertAxis) - { - return AnimationImporterUtil.ConvertAnimationClip(gltf, gltf.animations[i], invertAxis.Create()); - } - } -} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/RootAnimationImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/RootAnimationImporter.cs.meta deleted file mode 100644 index 2ea8cfbed7..0000000000 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationIO/RootAnimationImporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 27640e6274339664ea492827be5a2217 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs index f513391e3e..616afcda2c 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs @@ -12,26 +12,6 @@ namespace UniGLTF /// public class ImporterContext : IDisposable { - #region Animation - protected IAnimationImporter m_animationImporter; - public void SetAnimationImporter(IAnimationImporter animationImporter) - { - m_animationImporter = animationImporter; - } - public IAnimationImporter AnimationImporter - { - get - { - if (m_animationImporter == null) - { - m_animationImporter = new RootAnimationImporter(); - } - return m_animationImporter; - } - } - - #endregion - public ITextureDescriptorGenerator TextureDescriptorGenerator { get; protected set; } public IMaterialDescriptorGenerator MaterialDescriptorGenerator { get; protected set; } public TextureFactory TextureFactory { get; } @@ -123,33 +103,61 @@ public virtual async Task LoadAsync(IAwaitCaller awaitCaller = null, Func + /// ImporterContext.AnimationClips に AnimationClip を読み込むところまでが責務 + /// + /// + /// + protected virtual async Task LoadAnimationAsync(IAwaitCaller awaitCaller) + { + if (GLTF.animations != null && GLTF.animations.Any()) + { + for (int i = 0; i < GLTF.animations.Count; ++i) { - var animation = Root.AddComponent(); - for (int i = 0; i < GLTF.animations.Count; ++i) + var gltfAnimation = GLTF.animations[i]; + AnimationClip clip = default; + if (_externalObjectMap.TryGetValue(new SubAssetKey(typeof(AnimationClip), gltfAnimation.name), out UnityEngine.Object value)) + { + clip = value as AnimationClip; + } + else { - var gltfAnimation = GLTF.animations[i]; - AnimationClip clip = default; - if (_externalObjectMap.TryGetValue(new SubAssetKey(typeof(AnimationClip), gltfAnimation.name), out UnityEngine.Object value)) - { - clip = value as AnimationClip; - } - else - { - clip = AnimationImporter.Import(GLTF, i, InvertAxis); - AnimationClips.Add(clip); - } - - animation.AddClip(clip, clip.name); - if (i == 0) - { - animation.clip = clip; - } + clip = AnimationImporterUtil.ConvertAnimationClip(GLTF, GLTF.animations[i], InvertAxis.Create()); + AnimationClips.Add(clip); } } + + await awaitCaller.NextFrame(); } + } - await OnLoadHierarchy(awaitCaller, MeasureTime); + /// + /// AnimationClips を AnimationComponent に載せる + /// + protected virtual async Task SetupAnimationsAsync(IAwaitCaller awaitCaller) + { + if (AnimationClips.Count == 0) + { + return; + } + var animation = Root.AddComponent(); + for (int i = 0; i < AnimationClips.Count; ++i) + { + var clip = AnimationClips[i]; + animation.AddClip(clip, clip.name); + if (i == 0) + { + animation.clip = clip; + } + } + await awaitCaller.NextFrame(); } protected virtual async Task LoadGeometryAsync(IAwaitCaller awaitCaller, Func MeasureTime) diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneJoint.cs b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneJoint.cs index 9ad55c1943..3c8d4e44bc 100644 --- a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneJoint.cs +++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneJoint.cs @@ -28,7 +28,7 @@ public class VRM10SpringBoneJoint : MonoBehaviour [SerializeField, Range(0, 0.5f), Header("Collision")] public float m_jointRadius = 0.02f; - SpringBoneLogic m_logic; + SpringBoneLogic m_logic = null; public void DrawGizmo(Transform center, Color color) { diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs index c565911a59..407ea4515a 100644 --- a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs @@ -141,7 +141,7 @@ public static bool TryExportMaterialAsMToon(Material src, ITextureExporter textu return true; } - catch (Exception e) + catch (Exception) { dst = null; return false;