mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-14 04:02:12 +07:00
49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
namespace FTRuntime.Yields {
|
|
public class SwfWaitStopOrRewindPlaying : CustomYieldInstruction {
|
|
SwfClipController _waitCtrl;
|
|
|
|
public SwfWaitStopOrRewindPlaying(SwfClipController ctrl) {
|
|
Subscribe(ctrl);
|
|
}
|
|
|
|
public SwfWaitStopOrRewindPlaying Reuse(SwfClipController ctrl) {
|
|
return Subscribe(ctrl);
|
|
}
|
|
|
|
public override bool keepWaiting {
|
|
get {
|
|
return _waitCtrl != null;
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------
|
|
//
|
|
// Internal
|
|
//
|
|
// ---------------------------------------------------------------------
|
|
|
|
SwfWaitStopOrRewindPlaying Subscribe(SwfClipController ctrl) {
|
|
Unsubscribe();
|
|
if ( ctrl ) {
|
|
_waitCtrl = ctrl;
|
|
ctrl.OnStopPlayingEvent += OnStopOrRewindPlaying;
|
|
ctrl.OnRewindPlayingEvent += OnStopOrRewindPlaying;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
void Unsubscribe() {
|
|
if ( _waitCtrl != null ) {
|
|
_waitCtrl.OnStopPlayingEvent -= OnStopOrRewindPlaying;
|
|
_waitCtrl.OnRewindPlayingEvent -= OnStopOrRewindPlaying;
|
|
_waitCtrl = null;
|
|
}
|
|
}
|
|
|
|
void OnStopOrRewindPlaying(SwfClipController ctrl) {
|
|
Unsubscribe();
|
|
}
|
|
}
|
|
} |