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

@ -236,6 +236,7 @@ namespace AssetStudioGUI
if (m_GameObject.CubismModel != null && TryGetCubismMoc(m_GameObject.CubismModel.CubismModelMono, out var mocMono))
{
l2dModelDict[mocMono] = m_GameObject.CubismModel;
BindAnimationClips(m_GameObject);
}
break;
case Texture2D m_Texture2D:
@ -1075,6 +1076,34 @@ namespace AssetStudioGUI
}
}
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)