Files
ichni_Creator_Studio/Assets/Scripts/Animations/Transform/Scale.cs
SoulliesOfficial 39b4a5e7ff 基础内容-5
主题包;
测试NoteVisual与NoteEffect;
LookAt旋转动画与FlexibleBool
动画杂项
控制台初步
2025-01-29 23:49:18 -05:00

59 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class Scale : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat scaleX, scaleY, scaleZ;
public static Scale GenerateElement(string elementName, BaseElement targetObject,
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
{
Scale scale = Lean.Pool.LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Scale>();
scale.NewInitialize(elementName, targetObject);
scale.scaleX = scaleX;
scale.scaleY = scaleY;
scale.scaleZ = scaleZ;
scale.animationReturnType = FlexibleReturnType.Before;
if (targetObject.transformSubmodule != null)
{
scale.targetTransformSubmodule = targetObject.transformSubmodule;
}
else
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
scale.SetTimeDuration(scaleX, scaleY, scaleZ);
return scale;
}
protected override void UpdateAnimation(float songTime)
{
scaleX.UpdateFlexibleFloat(songTime);
scaleY.UpdateFlexibleFloat(songTime);
scaleZ.UpdateFlexibleFloat(songTime);
if (scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
targetTransformSubmodule.scaleOffset.Add(currentScale);
targetTransformSubmodule.scaleDirtyMark = true;
}
else
{
animationReturnType = FlexibleReturnType.MiddleInterval;
}
}
}
}