mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-25 02:00:16 +00:00
fix #625
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace YooAsset
|
|||||||
|
|
||||||
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(1000);
|
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(1000);
|
||||||
private static readonly List<AsyncOperationBase> _newList = new List<AsyncOperationBase>(1000);
|
private static readonly List<AsyncOperationBase> _newList = new List<AsyncOperationBase>(1000);
|
||||||
|
private static Action<string, AsyncOperationBase> _startCallback = null;
|
||||||
|
private static Action<string, AsyncOperationBase> _finishCallback = null;
|
||||||
|
|
||||||
// 计时器相关
|
// 计时器相关
|
||||||
private static Stopwatch _watch;
|
private static Stopwatch _watch;
|
||||||
@@ -58,7 +61,12 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
var operation = _operations[i];
|
var operation = _operations[i];
|
||||||
if (operation.IsFinish)
|
if (operation.IsFinish)
|
||||||
|
{
|
||||||
_operations.RemoveAt(i);
|
_operations.RemoveAt(i);
|
||||||
|
|
||||||
|
if (_finishCallback != null)
|
||||||
|
_finishCallback.Invoke(operation.PackageName, operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加新增的异步操作
|
// 添加新增的异步操作
|
||||||
@@ -105,6 +113,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_operations.Clear();
|
_operations.Clear();
|
||||||
_newList.Clear();
|
_newList.Clear();
|
||||||
|
_startCallback = null;
|
||||||
|
_finishCallback = null;
|
||||||
_watch = null;
|
_watch = null;
|
||||||
_frameTime = 0;
|
_frameTime = 0;
|
||||||
MaxTimeSlice = long.MaxValue;
|
MaxTimeSlice = long.MaxValue;
|
||||||
@@ -142,6 +152,25 @@ namespace YooAsset
|
|||||||
_newList.Add(operation);
|
_newList.Add(operation);
|
||||||
operation.SetPackageName(packageName);
|
operation.SetPackageName(packageName);
|
||||||
operation.StartOperation();
|
operation.StartOperation();
|
||||||
|
|
||||||
|
if (_startCallback != null)
|
||||||
|
_startCallback.Invoke(packageName, operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 监听任务开始
|
||||||
|
/// </summary>
|
||||||
|
public static void RegisterStartCallback(Action<string, AsyncOperationBase> callback)
|
||||||
|
{
|
||||||
|
_startCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 监听任务结束
|
||||||
|
/// </summary>
|
||||||
|
public static void RegisterFinishCallback(Action<string, AsyncOperationBase> callback)
|
||||||
|
{
|
||||||
|
_finishCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
|
|||||||
Reference in New Issue
Block a user