-
Notifications
You must be signed in to change notification settings - Fork 62
/
TextureItemObject.cs
59 lines (54 loc) · 1.68 KB
/
TextureItemObject.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
using GameFramework;
using GameFramework.ObjectPool;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace UGFExtensions.Texture
{
public class TextureItemObject : ObjectBase
{
private TextureLoad m_TextureLoad;
private ResourceComponent m_ResourceComponent;
public static TextureItemObject Create(string collectionPath, UnityEngine.Texture target,TextureLoad textureLoad,ResourceComponent resourceComponent = null)
{
TextureItemObject item = ReferencePool.Acquire<TextureItemObject>();
item.Initialize(collectionPath, target);
item.m_TextureLoad = textureLoad;
item.m_ResourceComponent = resourceComponent;
return item;
}
protected override void Release(bool isShutdown)
{
UnityEngine.Texture texture = (UnityEngine.Texture)Target;
if (texture == null)
{
return;
}
switch (m_TextureLoad)
{
case TextureLoad.FromResource:
m_ResourceComponent.UnloadAsset(texture);
m_ResourceComponent = null;
break;
case TextureLoad.FromNet:
case TextureLoad.FromFileSystem:
Object.Destroy(texture);
break;
}
}
}
public enum TextureLoad
{
/// <summary>
/// 从文件系统
/// </summary>
FromFileSystem,
/// <summary>
/// 从网络
/// </summary>
FromNet,
/// <summary>
/// 从资源包
/// </summary>
FromResource
}
}