-
Notifications
You must be signed in to change notification settings - Fork 2
/
AssetSystem.cs
154 lines (137 loc) · 4.5 KB
/
AssetSystem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#region
using System;
using System.Collections;
using System.Diagnostics;
using System.Threading.Tasks;
using AIO.UEngine;
#endregion
namespace AIO
{
/// <summary>
/// 资源管理系统
/// </summary>
public static partial class AssetSystem
{
internal static void ExceptionEvent(ASException ex)
{
_Exception = ex;
if (OnException is null)
{
#if UNITY_EDITOR
LogException($"Asset System Exception : {ex}");
#else
throw new Exception($"Asset System Exception : {ex}");
#endif
}
else
{
OnException.Invoke(ex);
}
}
/// <summary>
/// 系统初始化
/// </summary>
[DebuggerNonUserCode, DebuggerHidden]
public static IOperationAction Initialize<T>(ASConfig config)
where T : ASProxy, new()
{
return ASHandleActionInitializeTask.Create(Activator.CreateInstance<T>(), config);
}
/// <summary>
/// 系统初始化
/// </summary>
[DebuggerNonUserCode, DebuggerHidden]
public static IOperationAction Initialize()
{
return Initialize(ASConfig.GetOrCreate());
}
/// <summary>
/// 系统初始化
/// </summary>
[DebuggerNonUserCode, DebuggerHidden]
public static IOperationAction Initialize(ASConfig config)
{
return ASHandleActionInitializeTask.Create(config);
}
/// <summary>
/// 系统初始化
/// </summary>
[DebuggerNonUserCode, DebuggerHidden]
public static IOperationAction Initialize<T>(T proxy)
where T : ASProxy
{
return ASHandleActionInitializeTask.Create(proxy, ASConfig.GetOrCreate());
}
/// <summary>
/// 系统初始化
/// </summary>
[DebuggerNonUserCode, DebuggerHidden]
public static IOperationAction Initialize<T>()
where T : ASProxy, new()
{
return ASHandleActionInitializeTask.Create(Activator.CreateInstance<T>(), ASConfig.GetOrCreate());
}
/// <summary>
/// 系统初始化
/// </summary>
[DebuggerNonUserCode, DebuggerHidden]
public static IOperationAction Initialize<T>(T proxy, ASConfig config)
where T : ASProxy
{
return ASHandleActionInitializeTask.Create(proxy, config);
}
/// <summary>
/// 销毁资源管理系统
/// </summary>
/// <returns></returns>
[DebuggerNonUserCode, DebuggerHidden]
public static Task DestroyTask()
{
Destroy();
return Task.CompletedTask;
}
/// <summary>
/// 销毁资源管理系统
/// </summary>
/// <returns></returns>
[DebuggerNonUserCode, DebuggerHidden]
public static IEnumerator DestroyCO()
{
Destroy();
yield break;
}
/// <summary>
/// 销毁资源管理系统
/// </summary>
/// <returns></returns>
[DebuggerNonUserCode, DebuggerHidden]
public static void Destroy()
{
#if UNITY_EDITOR
Parameter.SequenceRecord.Save();
#endif
Proxy.Dispose();
}
/// <summary>
/// 清理包裹未使用的缓存文件 (清空之后需要重新下载资源)
/// </summary>
public static async void ClearUnusedCache(Action<bool> completed = null)
=> await Proxy.ClearUnusedCacheTask(completed);
/// <summary>
/// 清理包裹未使用的缓存文件 (清空之后需要重新下载资源)
/// </summary>
/// <param name="completed">回调</param>
public static IOperationAction<bool> CleanUnusedCacheTask(Action<bool> completed = null)
=> Proxy.ClearUnusedCacheTask(completed);
/// <summary>
/// 清理包裹全部缓存文件 (清空之后需要重新下载资源)
/// </summary>
public static async void ClearAllCache(Action<bool> completed = null)
=> await Proxy.ClearAllCacheTask(completed);
/// <summary>
/// 清理包裹未使用的缓存文件 (清空之后需要重新下载资源)
/// </summary>
public static IOperationAction<bool> CleanAllCacheTask(Action<bool> completed = null)
=> Proxy.ClearAllCacheTask(completed);
}
}