mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-13 19:48:03 +07:00
Raw enumerator to CustomYieldInstruction. More yield instructions.
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0e3bddf96333643c8a12fd862ebc9ec7
|
|
||||||
folderAsset: yes
|
|
||||||
timeCreated: 1480709542
|
|
||||||
licenseType: Free
|
|
||||||
DefaultImporter:
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
###### Version 1.3.6
|
###### Version 1.3.6
|
||||||
* Fix for scale very small vector items
|
* Fix for scale very small vector items
|
||||||
* Big vector item optimization
|
* Big vector item optimization
|
||||||
|
* More yield instructions and extensions
|
||||||
|
|
||||||
###### Version 1.3.5
|
###### Version 1.3.5
|
||||||
* Fix sprite import problem
|
* Fix sprite import problem
|
||||||
|
|||||||
@@ -18,22 +18,25 @@ namespace FlashTools.Examples {
|
|||||||
|
|
||||||
IEnumerator StartCoro(SwfClipController ctrl) {
|
IEnumerator StartCoro(SwfClipController ctrl) {
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
ctrl.Play(_fadeInSequence);
|
yield return ctrl.PlayAndWaitStopOrRewind(_fadeInSequence);
|
||||||
yield return new SwfWaitStopPlaying(ctrl);
|
|
||||||
|
|
||||||
for ( var i = 0; i < 3; ++i ) {
|
for ( var i = 0; i < 3; ++i ) {
|
||||||
var last_seq = ctrl.clip.sequence;
|
var idle_seq = GetRandomIdleSequence(ctrl);
|
||||||
do {
|
yield return ctrl.PlayAndWaitStopOrRewind(idle_seq);
|
||||||
var seq_index = Random.Range(0, _idleSequences.Length);
|
|
||||||
ctrl.Play(_idleSequences[seq_index]);
|
|
||||||
} while ( last_seq == ctrl.clip.sequence );
|
|
||||||
yield return new SwfWaitStopPlaying(ctrl);
|
|
||||||
}
|
}
|
||||||
|
yield return ctrl.PlayAndWaitStopOrRewind(_fadeOutSequence);
|
||||||
ctrl.Play(_fadeOutSequence);
|
|
||||||
yield return new SwfWaitStopPlaying(ctrl);
|
|
||||||
yield return new WaitForSeconds(2.0f);
|
yield return new WaitForSeconds(2.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string GetRandomIdleSequence(SwfClipController ctrl) {
|
||||||
|
var cur_seq = ctrl.clip.sequence;
|
||||||
|
do {
|
||||||
|
var seq_index = Random.Range(0, _idleSequences.Length);
|
||||||
|
var new_sequence = _idleSequences[seq_index];
|
||||||
|
if ( new_sequence != cur_seq ) {
|
||||||
|
return new_sequence;
|
||||||
|
}
|
||||||
|
} while ( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
250
Assets/FlashTools/Scripts/FTRuntime/Yields/SwfWaitExtensions.cs
Normal file
250
Assets/FlashTools/Scripts/FTRuntime/Yields/SwfWaitExtensions.cs
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
namespace FTRuntime.Yields {
|
||||||
|
public static class SwfWaitExtensions {
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// WaitFor[Event]
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>Yield instruction for wait animation stop event</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop event</returns>
|
||||||
|
/// <param name="ctrl">The controller</param>
|
||||||
|
public static SwfWaitStopPlaying WaitForStopPlaying(
|
||||||
|
this SwfClipController ctrl)
|
||||||
|
{
|
||||||
|
return new SwfWaitStopPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Yield instruction for wait animation rewind event</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation rewind event</returns>
|
||||||
|
/// <param name="ctrl">The controller</param>
|
||||||
|
public static SwfWaitRewindPlaying WaitForRewindPlaying(
|
||||||
|
this SwfClipController ctrl)
|
||||||
|
{
|
||||||
|
return new SwfWaitRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Yield instruction for wait animation stop or rewind event</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop or rewind event</returns>
|
||||||
|
/// <param name="ctrl">The controller</param>
|
||||||
|
public static SwfWaitStopOrRewindPlaying WaitForStopOrRewindPlaying(
|
||||||
|
this SwfClipController ctrl)
|
||||||
|
{
|
||||||
|
return new SwfWaitStopOrRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Yield instruction for wait animation play event</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation play event</returns>
|
||||||
|
/// <param name="ctrl">The controller</param>
|
||||||
|
public static SwfWaitPlayStopped WaitForPlayStopped(
|
||||||
|
this SwfClipController ctrl)
|
||||||
|
{
|
||||||
|
return new SwfWaitPlayStopped(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// PlayAndWait[Event]
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>Play with specified rewind action</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="rewind">If set to <c>true</c> rewind animation to begin frame</param>
|
||||||
|
public static SwfWaitStopPlaying PlayAndWaitStop(
|
||||||
|
this SwfClipController ctrl, bool rewind)
|
||||||
|
{
|
||||||
|
ctrl.Play(rewind);
|
||||||
|
return WaitForStopPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and play controller with rewind</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
public static SwfWaitStopPlaying PlayAndWaitStop(
|
||||||
|
this SwfClipController ctrl, string sequence)
|
||||||
|
{
|
||||||
|
ctrl.Play(sequence);
|
||||||
|
return WaitForStopPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Play with specified rewind action</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="rewind">If set to <c>true</c> rewind animation to begin frame</param>
|
||||||
|
public static SwfWaitRewindPlaying PlayAndWaitRewind(
|
||||||
|
this SwfClipController ctrl, bool rewind)
|
||||||
|
{
|
||||||
|
ctrl.Play(rewind);
|
||||||
|
return WaitForRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and play controller with rewind</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
public static SwfWaitRewindPlaying PlayAndWaitRewind(
|
||||||
|
this SwfClipController ctrl, string sequence)
|
||||||
|
{
|
||||||
|
ctrl.Play(sequence);
|
||||||
|
return WaitForRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Play with specified rewind action</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop or rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="rewind">If set to <c>true</c> rewind animation to begin frame</param>
|
||||||
|
public static SwfWaitStopOrRewindPlaying PlayAndWaitStopOrRewind(
|
||||||
|
this SwfClipController ctrl, bool rewind)
|
||||||
|
{
|
||||||
|
ctrl.Play(rewind);
|
||||||
|
return WaitForStopOrRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and play controller with rewind</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop or rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
public static SwfWaitStopOrRewindPlaying PlayAndWaitStopOrRewind(
|
||||||
|
this SwfClipController ctrl, string sequence)
|
||||||
|
{
|
||||||
|
ctrl.Play(sequence);
|
||||||
|
return WaitForStopOrRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// GotoAndPlayAndWait[Event]
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>Changes the animation frame with plays it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitStopPlaying GotoAndPlayAndWaitStop(
|
||||||
|
this SwfClipController ctrl, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndPlay(frame);
|
||||||
|
return WaitForStopPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and frame with plays it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitStopPlaying GotoAndPlayAndWaitStop(
|
||||||
|
this SwfClipController ctrl, string sequence, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndPlay(sequence, frame);
|
||||||
|
return WaitForStopPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation frame with plays it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitRewindPlaying GotoAndPlayAndWaitRewind(
|
||||||
|
this SwfClipController ctrl, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndPlay(frame);
|
||||||
|
return WaitForRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and frame with plays it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitRewindPlaying GotoAndPlayAndWaitRewind(
|
||||||
|
this SwfClipController ctrl, string sequence, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndPlay(sequence, frame);
|
||||||
|
return WaitForRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation frame with plays it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop and rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitStopOrRewindPlaying GotoAndPlayAndWaitStopOrRewind(
|
||||||
|
this SwfClipController ctrl, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndPlay(frame);
|
||||||
|
return WaitForStopOrRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and frame with plays it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation stop and rewind event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitStopOrRewindPlaying GotoAndPlayAndWaitStopOrRewind(
|
||||||
|
this SwfClipController ctrl, string sequence, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndPlay(sequence, frame);
|
||||||
|
return WaitForStopOrRewindPlaying(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// StopAndWait[Event]
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>Stop with specified rewind action</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation play event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="rewind">If set to <c>true</c> rewind animation to begin frame</param>
|
||||||
|
public static SwfWaitPlayStopped StopAndWaitPlay(
|
||||||
|
this SwfClipController ctrl, bool rewind)
|
||||||
|
{
|
||||||
|
ctrl.Stop(rewind);
|
||||||
|
return WaitForPlayStopped(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and stop controller with rewind</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation play event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
public static SwfWaitPlayStopped StopAndWaitPlay(
|
||||||
|
this SwfClipController ctrl, string sequence)
|
||||||
|
{
|
||||||
|
ctrl.Stop(sequence);
|
||||||
|
return WaitForPlayStopped(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// GotoAndStopAndWait[Event]
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>Changes the animation frame with stops it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation play event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitPlayStopped GotoAndStopAndWaitPlay(
|
||||||
|
this SwfClipController ctrl, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndStop(frame);
|
||||||
|
return WaitForPlayStopped(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Changes the animation sequence and frame with stops it</summary>
|
||||||
|
/// <returns>Yield instruction for wait animation play event</returns>
|
||||||
|
/// <param name="ctrl">The clip controller</param>
|
||||||
|
/// <param name="sequence">The new sequence</param>
|
||||||
|
/// <param name="frame">The new current frame</param>
|
||||||
|
public static SwfWaitPlayStopped GotoAndStopAndWaitPlay(
|
||||||
|
this SwfClipController ctrl, string sequence, int frame)
|
||||||
|
{
|
||||||
|
ctrl.GotoAndStop(sequence, frame);
|
||||||
|
return WaitForPlayStopped(ctrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da7412b1ce89b4952869f7a85515b954
|
||||||
|
timeCreated: 1487268103
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace FTRuntime.Yields {
|
namespace FTRuntime.Yields {
|
||||||
public class SwfWaitPlayStopped : IEnumerator {
|
public class SwfWaitPlayStopped : CustomYieldInstruction {
|
||||||
SwfClipController _waitCtrl;
|
SwfClipController _waitCtrl;
|
||||||
|
|
||||||
public SwfWaitPlayStopped(SwfClipController ctrl) {
|
public SwfWaitPlayStopped(SwfClipController ctrl) {
|
||||||
@@ -12,12 +12,20 @@ namespace FTRuntime.Yields {
|
|||||||
return Subscribe(ctrl);
|
return Subscribe(ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool keepWaiting {
|
||||||
|
get {
|
||||||
|
return _waitCtrl != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Private
|
// Internal
|
||||||
//
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
SwfWaitPlayStopped Subscribe(SwfClipController ctrl) {
|
SwfWaitPlayStopped Subscribe(SwfClipController ctrl) {
|
||||||
(this as IEnumerator).Reset();
|
Unsubscribe();
|
||||||
if ( ctrl ) {
|
if ( ctrl ) {
|
||||||
_waitCtrl = ctrl;
|
_waitCtrl = ctrl;
|
||||||
ctrl.OnPlayStoppedEvent += OnPlayStopped;
|
ctrl.OnPlayStoppedEvent += OnPlayStopped;
|
||||||
@@ -25,27 +33,15 @@ namespace FTRuntime.Yields {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPlayStopped(SwfClipController ctrl) {
|
void Unsubscribe() {
|
||||||
(this as IEnumerator).Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IEnumerator
|
|
||||||
//
|
|
||||||
|
|
||||||
bool IEnumerator.MoveNext() {
|
|
||||||
return _waitCtrl != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IEnumerator.Reset() {
|
|
||||||
if ( _waitCtrl != null ) {
|
if ( _waitCtrl != null ) {
|
||||||
_waitCtrl.OnPlayStoppedEvent -= OnPlayStopped;
|
_waitCtrl.OnPlayStoppedEvent -= OnPlayStopped;
|
||||||
_waitCtrl = null;
|
_waitCtrl = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object IEnumerator.Current {
|
void OnPlayStopped(SwfClipController ctrl) {
|
||||||
get { return null; }
|
Unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace FTRuntime.Yields {
|
namespace FTRuntime.Yields {
|
||||||
public class SwfWaitRewindPlaying : IEnumerator {
|
public class SwfWaitRewindPlaying : CustomYieldInstruction {
|
||||||
SwfClipController _waitCtrl;
|
SwfClipController _waitCtrl;
|
||||||
|
|
||||||
public SwfWaitRewindPlaying(SwfClipController ctrl) {
|
public SwfWaitRewindPlaying(SwfClipController ctrl) {
|
||||||
@@ -12,12 +12,20 @@ namespace FTRuntime.Yields {
|
|||||||
return Subscribe(ctrl);
|
return Subscribe(ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool keepWaiting {
|
||||||
|
get {
|
||||||
|
return _waitCtrl != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Private
|
// Internal
|
||||||
//
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
SwfWaitRewindPlaying Subscribe(SwfClipController ctrl) {
|
SwfWaitRewindPlaying Subscribe(SwfClipController ctrl) {
|
||||||
(this as IEnumerator).Reset();
|
Unsubscribe();
|
||||||
if ( ctrl ) {
|
if ( ctrl ) {
|
||||||
_waitCtrl = ctrl;
|
_waitCtrl = ctrl;
|
||||||
ctrl.OnRewindPlayingEvent += OnRewindPlaying;
|
ctrl.OnRewindPlayingEvent += OnRewindPlaying;
|
||||||
@@ -25,27 +33,15 @@ namespace FTRuntime.Yields {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnRewindPlaying(SwfClipController ctrl) {
|
void Unsubscribe() {
|
||||||
(this as IEnumerator).Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IEnumerator
|
|
||||||
//
|
|
||||||
|
|
||||||
bool IEnumerator.MoveNext() {
|
|
||||||
return _waitCtrl != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IEnumerator.Reset() {
|
|
||||||
if ( _waitCtrl != null ) {
|
if ( _waitCtrl != null ) {
|
||||||
_waitCtrl.OnRewindPlayingEvent -= OnRewindPlaying;
|
_waitCtrl.OnRewindPlayingEvent -= OnRewindPlaying;
|
||||||
_waitCtrl = null;
|
_waitCtrl = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object IEnumerator.Current {
|
void OnRewindPlaying(SwfClipController ctrl) {
|
||||||
get { return null; }
|
Unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e7fb55d9b749a4fae9c1598651878ea9
|
||||||
|
timeCreated: 1487272051
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Collections;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace FTRuntime.Yields {
|
namespace FTRuntime.Yields {
|
||||||
public class SwfWaitStopPlaying : IEnumerator {
|
public class SwfWaitStopPlaying : CustomYieldInstruction {
|
||||||
SwfClipController _waitCtrl;
|
SwfClipController _waitCtrl;
|
||||||
|
|
||||||
public SwfWaitStopPlaying(SwfClipController ctrl) {
|
public SwfWaitStopPlaying(SwfClipController ctrl) {
|
||||||
@@ -12,12 +12,20 @@ namespace FTRuntime.Yields {
|
|||||||
return Subscribe(ctrl);
|
return Subscribe(ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool keepWaiting {
|
||||||
|
get {
|
||||||
|
return _waitCtrl != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Private
|
// Internal
|
||||||
//
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
SwfWaitStopPlaying Subscribe(SwfClipController ctrl) {
|
SwfWaitStopPlaying Subscribe(SwfClipController ctrl) {
|
||||||
(this as IEnumerator).Reset();
|
Unsubscribe();
|
||||||
if ( ctrl ) {
|
if ( ctrl ) {
|
||||||
_waitCtrl = ctrl;
|
_waitCtrl = ctrl;
|
||||||
ctrl.OnStopPlayingEvent += OnStopPlaying;
|
ctrl.OnStopPlayingEvent += OnStopPlaying;
|
||||||
@@ -25,27 +33,15 @@ namespace FTRuntime.Yields {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnStopPlaying(SwfClipController ctrl) {
|
void Unsubscribe() {
|
||||||
(this as IEnumerator).Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// IEnumerator
|
|
||||||
//
|
|
||||||
|
|
||||||
bool IEnumerator.MoveNext() {
|
|
||||||
return _waitCtrl != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IEnumerator.Reset() {
|
|
||||||
if ( _waitCtrl != null ) {
|
if ( _waitCtrl != null ) {
|
||||||
_waitCtrl.OnStopPlayingEvent -= OnStopPlaying;
|
_waitCtrl.OnStopPlayingEvent -= OnStopPlaying;
|
||||||
_waitCtrl = null;
|
_waitCtrl = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object IEnumerator.Current {
|
void OnStopPlaying(SwfClipController ctrl) {
|
||||||
get { return null; }
|
Unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,4 @@ EditorBuildSettings:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/DevTests/Scenes/Scene.unity
|
path: Assets/DevTests/Scene.unity
|
||||||
|
|||||||
Reference in New Issue
Block a user