自动在关闭程序时Kill已启动的DoTween动画
食用方法
把脚本放到文件夹内即可,会在运行时自动加入到场景中
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ZYFLongLive;
namespace ZYF
{
public class KillAllTweenOnApplicationStop : MonoBehaviour
{
private void OnDestroy()
{
DG.Tweening.DOTween.KillAll();
Debug.Log($"Kill All Tween");
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
public static void AutoAddGo()
{
var go = new GameObject($"{
nameof(KillAllTweenOnApplicationStop)}");
var comp = go.AddComponent<KillAllTweenOnApplicationStop>();
DontDestroyOnLoad( go );
go.hideFlags = HideFlags.HideInHierarchy;
}
}
}