summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/AssetBundleLoader.cs
blob: e9ab225c326c259578be724f71978a2e20cabd0d (plain)
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
using System;
using UnityEngine;
using XUpdater;

namespace XUtliPoolLib
{
	public abstract class AssetBundleLoader
	{
		public virtual bool isComplete
		{
			get
			{
				return this.state == LoadState.State_Error || this.state == LoadState.State_Complete;
			}
		}

		internal AssetBundleManager.LoadAssetCompleteHandler onComplete;

		public int loadHandlerID;

		public uint bundleName;

		public AssetBundleData bundleData;

		public AssetBundleInfo bundleInfo;

		public AssetBundleManager bundleManager;

		public LoadState state = LoadState.State_None;

		protected AssetBundleLoader[] depLoaders;

		public virtual void Load()
		{
		}

		public virtual void LoadImm()
		{
		}

		public virtual void LoadBundle()
		{
		}

		public virtual void LoadBundleImm()
		{
		}

		protected virtual void Complete()
		{
			bool flag = this.onComplete != null;
			if (flag)
			{
				AssetBundleManager.LoadAssetCompleteHandler loadAssetCompleteHandler = this.onComplete;
				this.onComplete = null;
				loadAssetCompleteHandler(this.bundleInfo, this.loadHandlerID);
			}
			this.bundleManager.LoadComplete(this);
		}

		protected virtual void Error()
		{
			bool flag = this.onComplete != null;
			if (flag)
			{
				AssetBundleManager.LoadAssetCompleteHandler loadAssetCompleteHandler = this.onComplete;
				this.onComplete = null;
				loadAssetCompleteHandler(this.bundleInfo, this.loadHandlerID);
			}
			this.bundleManager.LoadError(this);
		}

		protected bool UnloadNotLoadingBundle(AssetBundle bundle)
		{
			bool flag = bundle == null;
			bool result;
			if (flag)
			{
				int bundleCount = XSingleton<XUpdater.XUpdater>.singleton.ABManager.BundleCount;
				XSingleton<XUpdater.XUpdater>.singleton.ABManager.UnloadNotUsedLoader();
				Resources.UnloadUnusedAssets();
				XSingleton<XDebug>.singleton.AddErrorLog("AssetBundle Count: ", bundleCount.ToString(), " , ", XSingleton<XUpdater.XUpdater>.singleton.ABManager.BundleCount.ToString(), null, null);
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}
	}
}