@@ -617,6 +617,51 @@ namespace Ichni.Editor
|
||||
pathnode.Refresh();
|
||||
}
|
||||
}
|
||||
public static void FloorAnim()
|
||||
{
|
||||
if (inspector.connectedGameElement == null)
|
||||
{
|
||||
LogWindow.Log("Please select a Element first!");
|
||||
return;
|
||||
}
|
||||
List<AnimationBase> elements = inspector.connectedGameElement.GetAllGameElementsFromThis().OfType<AnimationBase>().ToList();
|
||||
// 预先缓存属性信息(如果在循环外部知道具体类型)
|
||||
var propertiesToCheck = typeof(GameElement).GetProperties()
|
||||
.Where(p => p.PropertyType == typeof(FlexibleFloat))
|
||||
.ToArray();
|
||||
|
||||
foreach (var element in elements)
|
||||
{
|
||||
bool needsRefresh = false;
|
||||
|
||||
foreach (var prop in propertiesToCheck)
|
||||
{
|
||||
var ff = prop.GetValue(element) as FlexibleFloat;
|
||||
if (ff?.animations?.Count > 0 && ff.animations[0] != null)
|
||||
{
|
||||
var firstAnimation = ff.animations[0];
|
||||
if (firstAnimation.startTime > 0)
|
||||
{
|
||||
ff.animations.Insert(0, new AnimatedFloat(
|
||||
0,
|
||||
Math.Min(firstAnimation.startTime, 1),
|
||||
firstAnimation.startValue,
|
||||
firstAnimation.startValue,
|
||||
AnimationCurveType.Linear
|
||||
));
|
||||
|
||||
needsRefresh = true;
|
||||
Debug.Log($"Added 0 keyframe to {element.elementName}'s {prop.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needsRefresh)
|
||||
{
|
||||
element.Refresh();
|
||||
element.animatedObject?.Refresh(); // 使用空条件运算符
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user