Raw enumerator to CustomYieldInstruction. More yield instructions.

This commit is contained in:
2017-02-17 17:00:45 +07:00
parent 1abb0878b9
commit 1976d315c4
13 changed files with 385 additions and 79 deletions

View File

@@ -0,0 +1,49 @@
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();
}
}
}