mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 14:11:19 +07:00
31 lines
718 B
C#
31 lines
718 B
C#
using UnityEngine;
|
|
|
|
using FTRuntime;
|
|
|
|
namespace FTDevTests {
|
|
public class DeleteOnEnd : MonoBehaviour {
|
|
void Start () {
|
|
var clip = GetComponent<SwfClip>();
|
|
if ( clip ) {
|
|
clip.OnChangeCurrentFrameEvent += OnChangeCurrentFrameEvent;
|
|
}
|
|
}
|
|
|
|
void OnDestroy() {
|
|
Debug.Log("DeleteOnEnd::OnDestroy");
|
|
var clip = GetComponent<SwfClip>();
|
|
if ( clip ) {
|
|
clip.OnChangeCurrentFrameEvent -= OnChangeCurrentFrameEvent;
|
|
}
|
|
}
|
|
|
|
void OnChangeCurrentFrameEvent(SwfClip clip) {
|
|
Debug.LogFormat("OnChangeCurrentFrameEvent: {0}", clip.currentFrame);
|
|
if ( clip.currentFrame == clip.frameCount - 1 ) {
|
|
Debug.Log("Delete");
|
|
Destroy(gameObject);
|
|
Debug.Log("After Delete");
|
|
}
|
|
}
|
|
}
|
|
} |