2024年6月12日发(作者:)
Unity之可寻址资源之初始化,下载
以下代码实现了Addressable Assets的初始化,登陆时下载,静默下载,如下:
1 using ClientData;
2 using Common;
3 using System;
4 using tions;
5 using c;
6 using ;
7 using ;
8 using UnityEngine;
9 using sableAssets;
10 using perations;
11 using ceLocations;
12 using ceProviders;
13
14 namespace FashionBeat
15 {
16 public class AddressableABManager : GameBehaviour
17 {
18 public static int
19 MaxLoginDownloadingThread = 10,
20 MinHotPatchMB = 10;
21 public static float
22 ProgressBarSpeed = 0.05f;
23 public static bool
24 //IsOpenLoginDownload = true,
25 IsOpenQuietlyDownload = true;
26
27 const string
28 DefaultRampName = "model_ramp_default",
29 LoginDownloadKeysFile = "Address/t_download_login",
30 QuietlyDownloadKeysFile = "Address/t_download_quietly";
31
32 const float SizeScale = 1f / 1024 / 1024;
33 static readonly StringBuilder s_sb = new StringBuilder();
34
35 string m_mainABFolder, m_localABFolder;
36 float m_loginDownloadedMB, m_timerLoginDownloading, m_quietlyDownloadedMB, m_timerQuietlyDownloading;
37 Queue
38 List
39 float m_completeProgressWhenInit;
40
41 // Singleton
42 static AddressableABManager s_singleton;
43 public static AddressableABManager Singleton
44 {
45 get
46 {
47 if (!s_singleton)
48 {
49 GameObject go = new GameObject(typeof(AddressableABManager).ToString());
50 = orm;
51 s_singleton = ponent
52 }
53 return s_singleton;
54 }
55 }
56
57
58 public enum Stage
59 {
60 None,
61 Initializing,
62 Initialized,
63
64 StartLoginDownload,
65 LoginDownloading,
66 LoginDownloaded,
67
68 QuietlyDownloading,
69 QuietlyDownloadPause,
70 QuietlyDownloaded,
71 }
72
73
74 #region Property
75
76 static string PlatformFolder
77 {
78 get
79 {
80 #if UNITY_IPHONE
81 return "iOS";
82 #else
83 return "Android";
84 #endif
85 }
86 }
发布评论