增加轨道参数保存
This commit is contained in:
@@ -35,7 +35,7 @@ namespace SpineViewer.Models
|
|||||||
|
|
||||||
public List<string> DisabledSlots { get; set; } = [];
|
public List<string> DisabledSlots { get; set; } = [];
|
||||||
|
|
||||||
public List<string?> Animations { get; set; } = [];
|
public List<TrackConfigModel?> Animations { get; set; } = [];
|
||||||
|
|
||||||
public bool DebugTexture { get; set; } = true;
|
public bool DebugTexture { get; set; } = true;
|
||||||
|
|
||||||
@@ -59,12 +59,12 @@ namespace SpineViewer.Models
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AnimationConfigModel
|
public class TrackConfigModel
|
||||||
{
|
{
|
||||||
string Name { get; set; } = "";
|
public string AnimationName { get; set; } = "";
|
||||||
|
|
||||||
float TimeScale { get; set; } = 1f;
|
public float TimeScale { get; set; } = 1f;
|
||||||
|
|
||||||
float Alpha { get; set; } = 1f;
|
public float Alpha { get; set; } = 1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -459,7 +459,22 @@ namespace SpineViewer.Models
|
|||||||
config.DisabledSlots = _spineObject.Skeleton.Slots.Where(it => it.Disabled).Select(it => it.Name).ToList();
|
config.DisabledSlots = _spineObject.Skeleton.Slots.Where(it => it.Disabled).Select(it => it.Name).ToList();
|
||||||
|
|
||||||
// XXX: 处理空动画
|
// XXX: 处理空动画
|
||||||
config.Animations.AddRange(_spineObject.AnimationState.IterTracks().Select(tr => tr?.Animation.Name));
|
foreach (var tr in _spineObject.AnimationState.IterTracks())
|
||||||
|
{
|
||||||
|
if (tr is not null)
|
||||||
|
{
|
||||||
|
config.Animations.Add(new()
|
||||||
|
{
|
||||||
|
AnimationName = tr.Animation.Name,
|
||||||
|
TimeScale = tr.TimeScale,
|
||||||
|
Alpha = tr.Alpha
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.Animations.Add(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -498,11 +513,15 @@ namespace SpineViewer.Models
|
|||||||
// XXX: 处理空动画
|
// XXX: 处理空动画
|
||||||
_spineObject.AnimationState.ClearTracks();
|
_spineObject.AnimationState.ClearTracks();
|
||||||
int trackIndex = 0;
|
int trackIndex = 0;
|
||||||
foreach (var name in value.Animations)
|
foreach (var trConfig in value.Animations)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(name))
|
if (trConfig is not null && !string.IsNullOrEmpty(trConfig.AnimationName))
|
||||||
_spineObject.AnimationState.SetAnimation(trackIndex, name, true);
|
{
|
||||||
TrackPropertyChanged?.Invoke(this, new(trackIndex, nameof(TrackPropertyChangedEventArgs.AnimationName)));
|
var tr = _spineObject.AnimationState.SetAnimation(trackIndex, trConfig.AnimationName, true);
|
||||||
|
tr.TimeScale = trConfig.TimeScale;
|
||||||
|
tr.Alpha = trConfig.Alpha;
|
||||||
|
TrackPropertyChanged?.Invoke(this, new(trackIndex, nameof(TrackPropertyChangedEventArgs.AnimationName)));
|
||||||
|
}
|
||||||
trackIndex++;
|
trackIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user