mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[unity] Reload during Play mode now copies registered event subscribers from before reload. Closes #1704.
This commit is contained in:
parent
5b65f3f155
commit
7ecc3b6f95
@ -85,6 +85,25 @@ namespace Spine {
|
||||
|
||||
public delegate void TrackEntryEventDelegate (TrackEntry trackEntry, Event e);
|
||||
public event TrackEntryEventDelegate Event;
|
||||
|
||||
public void AssignEventSubscribersFrom (AnimationState src) {
|
||||
Event = src.Event;
|
||||
Start = src.Start;
|
||||
Interrupt = src.Interrupt;
|
||||
End = src.End;
|
||||
Dispose = src.Dispose;
|
||||
Complete = src.Complete;
|
||||
}
|
||||
|
||||
public void AddEventSubscribersFrom (AnimationState src) {
|
||||
Event += src.Event;
|
||||
Start += src.Start;
|
||||
Interrupt += src.Interrupt;
|
||||
End += src.End;
|
||||
Dispose += src.Dispose;
|
||||
Complete += src.Complete;
|
||||
}
|
||||
|
||||
// end of difference
|
||||
private readonly EventQueue queue; // Initialized by constructor.
|
||||
private readonly HashSet<int> propertyIDs = new HashSet<int>();
|
||||
|
||||
@ -219,7 +219,18 @@ namespace Spine.Unity.Editor {
|
||||
public static void ReinitializeComponent (SkeletonRenderer component) {
|
||||
if (component == null) return;
|
||||
if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
|
||||
component.Initialize(true);
|
||||
|
||||
var stateComponent = component as IAnimationStateComponent;
|
||||
AnimationState oldAnimationState = null;
|
||||
if (stateComponent != null) {
|
||||
oldAnimationState = stateComponent.AnimationState;
|
||||
}
|
||||
|
||||
component.Initialize(true); // implicitly clears any subscribers
|
||||
|
||||
if (oldAnimationState != null) {
|
||||
stateComponent.AnimationState.AssignEventSubscribersFrom(oldAnimationState);
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
SpineMaskUtilities.EditorAssignSpriteMaskMaterials(component);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user