Improve integration with Live2D assets

- Added container-independent method for searching AnimationClip assets
(However, it's not really universal, so it can't completely replace the container-dependent method)
This commit is contained in:
VaDiM
2025-04-10 01:16:25 +03:00
parent 0cc74b8c12
commit a0c2a7bdfe
6 changed files with 75 additions and 1 deletions

View File

@ -586,6 +586,7 @@ namespace AssetStudioCLI.Options
o_exportAssetTypes.Value = new List<ClassIDType>
{
ClassIDType.AnimationClip,
ClassIDType.Animator,
ClassIDType.MonoBehaviour,
ClassIDType.Texture2D,
};

View File

@ -295,6 +295,7 @@ namespace AssetStudioCLI
if (m_GameObject.CubismModel != null && TryGetCubismMoc(m_GameObject.CubismModel.CubismModelMono, out var mocMono))
{
l2dModelDict[mocMono] = m_GameObject.CubismModel;
BindAnimationClips(m_GameObject);
}
break;
case Animator m_Animator:
@ -940,6 +941,34 @@ namespace AssetStudioCLI
}
}
private static void BindAnimationClips(GameObject gameObject)
{
if (gameObject.m_Animator == null || gameObject.m_Animator.m_Controller.IsNull)
return;
if (!gameObject.m_Animator.m_Controller.TryGet(out var controller))
return;
AnimatorController animatorController;
if (controller is AnimatorOverrideController overrideController)
{
if (!overrideController.m_Controller.TryGet(out animatorController))
return;
}
else
{
animatorController = (AnimatorController)controller;
}
foreach (var clipPptr in animatorController.m_AnimationClips)
{
if (clipPptr.TryGet(out var m_AnimationClip))
{
gameObject.CubismModel.ClipMotionList.Add(m_AnimationClip);
}
}
}
private static Transform GetRootTransform(Transform m_Transform)
{
if (m_Transform == null)