A small refactoring for Live2D motion export

This commit is contained in:
VaDiM 2025-01-23 18:04:32 +03:00
parent cc21d4fa4d
commit a8bb6c714b

View File

@ -289,9 +289,11 @@ namespace CubismLive2DExtractor
var destMotionPath = Path.Combine(destPath, "motions") + Path.DirectorySeparatorChar;
var motionFps = 0f;
if (motionMode == Live2DMotionMode.MonoBehaviour && FadeMotionLst != null) //Fade motions from Fade Motion List
if (motionMode == Live2DMotionMode.MonoBehaviour) //Fade motions from MonoBehaviour
{
Logger.Debug("Motion export method: MonoBehaviour (Fade motion)");
if (FadeMotionLst != null) //Fade motions from fadeMotionList
{
Logger.Debug("Parsing fade motion list..");
var fadeMotionLstDict = ParseMonoBehaviour(FadeMotionLst, CubismMonoBehaviourType.FadeMotionList, Assembly);
if (fadeMotionLstDict != null)
{
@ -312,32 +314,35 @@ namespace CubismLive2DExtractor
}
}
}
if (motionMode == Live2DMotionMode.MonoBehaviour && FadeMotions.Count > 0) //motion from MonoBehaviour
if (FadeMotions.Count > 0)
{
Logger.Debug("Motion export method: MonoBehaviour (Fade motion)");
ExportFadeMotions(destMotionPath, forceBezier, motions, ref motionFps);
}
if (motions.Count == 0) //motion from AnimationClip
{
CubismMotion3Converter converter = null;
var exportMethod = "AnimationClip";
if (motionMode != Live2DMotionMode.AnimationClipV1) //AnimationClipV2
{
exportMethod += "V2";
converter = new CubismMotion3Converter(AnimationClips, PartNames, ParameterNames);
}
else if (Model?.ModelGameObject != null) //AnimationClipV1
if (motions.Count == 0) //motions from AnimationClip
{
CubismMotion3Converter converter;
var exportMethod = "AnimationClip";
switch (motionMode)
{
case Live2DMotionMode.AnimationClipV1 when Model?.ModelGameObject != null:
exportMethod += "V1";
converter = new CubismMotion3Converter(Model.ModelGameObject, AnimationClips);
}
break;
default: //AnimationClipV2
exportMethod += "V2";
if (motionMode == Live2DMotionMode.MonoBehaviour)
{
exportMethod = FadeMotions.Count > 0
? exportMethod + " (unable to export motions using Fade motion method)"
: exportMethod + " (no Fade motions found)";
}
converter = new CubismMotion3Converter(AnimationClips, PartNames, ParameterNames);
break;
}
Logger.Debug($"Motion export method: {exportMethod}");
ExportClipMotions(destMotionPath, converter, forceBezier, motions, ref motionFps);