EditorResourceComponent.cs 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework;
  8. using GameFramework.Download;
  9. using GameFramework.FileSystem;
  10. using GameFramework.ObjectPool;
  11. using GameFramework.Resource;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.IO;
  15. using System.Runtime.InteropServices;
  16. using UnityEngine;
  17. using UnityEngine.SceneManagement;
  18. namespace UnityGameFramework.Runtime
  19. {
  20. /// <summary>
  21. /// 编辑器资源组件。
  22. /// </summary>
  23. [DisallowMultipleComponent]
  24. public sealed class EditorResourceComponent : MonoBehaviour, IResourceManager
  25. {
  26. private const int DefaultPriority = 0;
  27. private static readonly int AssetsStringLength = "Assets".Length;
  28. [SerializeField]
  29. private bool m_EnableCachedAssets = true;
  30. [SerializeField]
  31. private int m_LoadAssetCountPerFrame = 1;
  32. [SerializeField]
  33. private float m_MinLoadAssetRandomDelaySeconds = 0f;
  34. [SerializeField]
  35. private float m_MaxLoadAssetRandomDelaySeconds = 0f;
  36. private string m_ReadOnlyPath = null;
  37. private string m_ReadWritePath = null;
  38. private Dictionary<string, UnityEngine.Object> m_CachedAssets = null;
  39. private GameFrameworkLinkedList<LoadAssetInfo> m_LoadAssetInfos = null;
  40. private GameFrameworkLinkedList<LoadSceneInfo> m_LoadSceneInfos = null;
  41. private GameFrameworkLinkedList<UnloadSceneInfo> m_UnloadSceneInfos = null;
  42. /// <summary>
  43. /// 获取资源只读区路径。
  44. /// </summary>
  45. public string ReadOnlyPath
  46. {
  47. get
  48. {
  49. return m_ReadOnlyPath;
  50. }
  51. }
  52. /// <summary>
  53. /// 获取资源读写区路径。
  54. /// </summary>
  55. public string ReadWritePath
  56. {
  57. get
  58. {
  59. return m_ReadWritePath;
  60. }
  61. }
  62. /// <summary>
  63. /// 获取资源模式。
  64. /// </summary>
  65. public ResourceMode ResourceMode
  66. {
  67. get
  68. {
  69. return ResourceMode.Unspecified;
  70. }
  71. }
  72. /// <summary>
  73. /// 获取当前变体。
  74. /// </summary>
  75. public string CurrentVariant
  76. {
  77. get
  78. {
  79. return null;
  80. }
  81. }
  82. /// <summary>
  83. /// 获取单机模式版本资源列表序列化器。
  84. /// </summary>
  85. public PackageVersionListSerializer PackageVersionListSerializer
  86. {
  87. get
  88. {
  89. throw new NotSupportedException("ReadWriteVersionListSerializer");
  90. }
  91. }
  92. /// <summary>
  93. /// 获取可更新模式版本资源列表序列化器。
  94. /// </summary>
  95. public UpdatableVersionListSerializer UpdatableVersionListSerializer
  96. {
  97. get
  98. {
  99. throw new NotSupportedException("ReadWriteVersionListSerializer");
  100. }
  101. }
  102. /// <summary>
  103. /// 获取本地只读区版本资源列表序列化器。
  104. /// </summary>
  105. public ReadOnlyVersionListSerializer ReadOnlyVersionListSerializer
  106. {
  107. get
  108. {
  109. throw new NotSupportedException("ReadWriteVersionListSerializer");
  110. }
  111. }
  112. /// <summary>
  113. /// 获取本地读写区版本资源列表序列化器。
  114. /// </summary>
  115. public ReadWriteVersionListSerializer ReadWriteVersionListSerializer
  116. {
  117. get
  118. {
  119. throw new NotSupportedException("ReadWriteVersionListSerializer");
  120. }
  121. }
  122. /// <summary>
  123. /// 获取资源包版本资源列表序列化器。
  124. /// </summary>
  125. public ResourcePackVersionListSerializer ResourcePackVersionListSerializer
  126. {
  127. get
  128. {
  129. throw new NotSupportedException("ResourcePackVersionListSerializer");
  130. }
  131. }
  132. /// <summary>
  133. /// 获取当前资源适用的游戏版本号。
  134. /// </summary>
  135. public string ApplicableGameVersion
  136. {
  137. get
  138. {
  139. throw new NotSupportedException("ApplicableGameVersion");
  140. }
  141. }
  142. /// <summary>
  143. /// 获取当前内部资源版本号。
  144. /// </summary>
  145. public int InternalResourceVersion
  146. {
  147. get
  148. {
  149. throw new NotSupportedException("InternalResourceVersion");
  150. }
  151. }
  152. /// <summary>
  153. /// 获取已准备完毕资源数量。
  154. /// </summary>
  155. public int AssetCount
  156. {
  157. get
  158. {
  159. throw new NotSupportedException("AssetCount");
  160. }
  161. }
  162. /// <summary>
  163. /// 获取已准备完毕资源数量。
  164. /// </summary>
  165. public int ResourceCount
  166. {
  167. get
  168. {
  169. throw new NotSupportedException("ResourceCount");
  170. }
  171. }
  172. /// <summary>
  173. /// 获取资源组个数。
  174. /// </summary>
  175. public int ResourceGroupCount
  176. {
  177. get
  178. {
  179. throw new NotSupportedException("ResourceGroupCount");
  180. }
  181. }
  182. /// <summary>
  183. /// 获取或设置资源更新下载地址。
  184. /// </summary>
  185. public string UpdatePrefixUri
  186. {
  187. get
  188. {
  189. throw new NotSupportedException("UpdatePrefixUri");
  190. }
  191. set
  192. {
  193. throw new NotSupportedException("UpdatePrefixUri");
  194. }
  195. }
  196. /// <summary>
  197. /// 获取或设置每更新多少字节的资源,重新生成一次版本资源列表。
  198. /// </summary>
  199. public int GenerateReadWriteVersionListLength
  200. {
  201. get
  202. {
  203. throw new NotSupportedException("GenerateReadWriteVersionListLength");
  204. }
  205. set
  206. {
  207. throw new NotSupportedException("GenerateReadWriteVersionListLength");
  208. }
  209. }
  210. /// <summary>
  211. /// 获取正在应用的资源包路径。
  212. /// </summary>
  213. public string ApplyingResourcePackPath
  214. {
  215. get
  216. {
  217. throw new NotSupportedException("ApplyingResourcePackPath");
  218. }
  219. }
  220. /// <summary>
  221. /// 获取等待应用资源数量。
  222. /// </summary>
  223. public int ApplyWaitingCount
  224. {
  225. get
  226. {
  227. throw new NotSupportedException("ApplyWaitingCount");
  228. }
  229. }
  230. /// <summary>
  231. /// 获取或设置资源更新重试次数。
  232. /// </summary>
  233. public int UpdateRetryCount
  234. {
  235. get
  236. {
  237. throw new NotSupportedException("UpdateRetryCount");
  238. }
  239. set
  240. {
  241. throw new NotSupportedException("UpdateRetryCount");
  242. }
  243. }
  244. /// <summary>
  245. /// 获取正在更新的资源组。
  246. /// </summary>
  247. public IResourceGroup UpdatingResourceGroup
  248. {
  249. get
  250. {
  251. throw new NotSupportedException("UpdatingResourceGroup");
  252. }
  253. }
  254. /// <summary>
  255. /// 获取等待更新资源个数。
  256. /// </summary>
  257. public int UpdateWaitingCount
  258. {
  259. get
  260. {
  261. throw new NotSupportedException("UpdateWaitingCount");
  262. }
  263. }
  264. /// <summary>
  265. /// 获取使用时下载的等待更新资源数量。
  266. /// </summary>
  267. public int UpdateWaitingWhilePlayingCount
  268. {
  269. get
  270. {
  271. throw new NotSupportedException("UpdateWaitingWhilePlayingCount");
  272. }
  273. }
  274. /// <summary>
  275. /// 获取候选更新资源数量。
  276. /// </summary>
  277. public int UpdateCandidateCount
  278. {
  279. get
  280. {
  281. throw new NotSupportedException("UpdateCandidateCount");
  282. }
  283. }
  284. /// <summary>
  285. /// 获取加载资源代理总个数。
  286. /// </summary>
  287. public int LoadTotalAgentCount
  288. {
  289. get
  290. {
  291. throw new NotSupportedException("LoadTotalAgentCount");
  292. }
  293. }
  294. /// <summary>
  295. /// 获取可用加载资源代理个数。
  296. /// </summary>
  297. public int LoadFreeAgentCount
  298. {
  299. get
  300. {
  301. throw new NotSupportedException("LoadFreeAgentCount");
  302. }
  303. }
  304. /// <summary>
  305. /// 获取工作中加载资源代理个数。
  306. /// </summary>
  307. public int LoadWorkingAgentCount
  308. {
  309. get
  310. {
  311. throw new NotSupportedException("LoadWorkingAgentCount");
  312. }
  313. }
  314. /// <summary>
  315. /// 获取等待加载资源任务个数。
  316. /// </summary>
  317. public int LoadWaitingTaskCount
  318. {
  319. get
  320. {
  321. throw new NotSupportedException("LoadWaitingTaskCount");
  322. }
  323. }
  324. /// <summary>
  325. /// 获取或设置资源对象池自动释放可释放对象的间隔秒数。
  326. /// </summary>
  327. public float AssetAutoReleaseInterval
  328. {
  329. get
  330. {
  331. throw new NotSupportedException("AssetAutoReleaseInterval");
  332. }
  333. set
  334. {
  335. throw new NotSupportedException("AssetAutoReleaseInterval");
  336. }
  337. }
  338. /// <summary>
  339. /// 获取或设置资源对象池的容量。
  340. /// </summary>
  341. public int AssetCapacity
  342. {
  343. get
  344. {
  345. throw new NotSupportedException("AssetCapacity");
  346. }
  347. set
  348. {
  349. throw new NotSupportedException("AssetCapacity");
  350. }
  351. }
  352. /// <summary>
  353. /// 获取或设置资源对象池对象过期秒数。
  354. /// </summary>
  355. public float AssetExpireTime
  356. {
  357. get
  358. {
  359. throw new NotSupportedException("AssetExpireTime");
  360. }
  361. set
  362. {
  363. throw new NotSupportedException("AssetExpireTime");
  364. }
  365. }
  366. /// <summary>
  367. /// 获取或设置资源对象池的优先级。
  368. /// </summary>
  369. public int AssetPriority
  370. {
  371. get
  372. {
  373. throw new NotSupportedException("AssetPriority");
  374. }
  375. set
  376. {
  377. throw new NotSupportedException("AssetPriority");
  378. }
  379. }
  380. /// <summary>
  381. /// 获取或设置资源对象池自动释放可释放对象的间隔秒数。
  382. /// </summary>
  383. public float ResourceAutoReleaseInterval
  384. {
  385. get
  386. {
  387. throw new NotSupportedException("ResourceAutoReleaseInterval");
  388. }
  389. set
  390. {
  391. throw new NotSupportedException("ResourceAutoReleaseInterval");
  392. }
  393. }
  394. /// <summary>
  395. /// 获取或设置资源对象池的容量。
  396. /// </summary>
  397. public int ResourceCapacity
  398. {
  399. get
  400. {
  401. throw new NotSupportedException("ResourceCapacity");
  402. }
  403. set
  404. {
  405. throw new NotSupportedException("ResourceCapacity");
  406. }
  407. }
  408. /// <summary>
  409. /// 获取或设置资源对象池对象过期秒数。
  410. /// </summary>
  411. public float ResourceExpireTime
  412. {
  413. get
  414. {
  415. throw new NotSupportedException("ResourceExpireTime");
  416. }
  417. set
  418. {
  419. throw new NotSupportedException("ResourceExpireTime");
  420. }
  421. }
  422. /// <summary>
  423. /// 获取或设置资源对象池的优先级。
  424. /// </summary>
  425. public int ResourcePriority
  426. {
  427. get
  428. {
  429. throw new NotSupportedException("ResourcePriority");
  430. }
  431. set
  432. {
  433. throw new NotSupportedException("ResourcePriority");
  434. }
  435. }
  436. /// <summary>
  437. /// 获取等待编辑器加载的资源数量。
  438. /// </summary>
  439. public int LoadWaitingAssetCount
  440. {
  441. get
  442. {
  443. return m_LoadAssetInfos.Count;
  444. }
  445. }
  446. string IResourceManager.ReadOnlyPath => throw new NotImplementedException();
  447. string IResourceManager.ReadWritePath => throw new NotImplementedException();
  448. ResourceMode IResourceManager.ResourceMode => throw new NotImplementedException();
  449. string IResourceManager.CurrentVariant => throw new NotImplementedException();
  450. PackageVersionListSerializer IResourceManager.PackageVersionListSerializer => throw new NotImplementedException();
  451. UpdatableVersionListSerializer IResourceManager.UpdatableVersionListSerializer => throw new NotImplementedException();
  452. ReadOnlyVersionListSerializer IResourceManager.ReadOnlyVersionListSerializer => throw new NotImplementedException();
  453. ReadWriteVersionListSerializer IResourceManager.ReadWriteVersionListSerializer => throw new NotImplementedException();
  454. ResourcePackVersionListSerializer IResourceManager.ResourcePackVersionListSerializer => throw new NotImplementedException();
  455. string IResourceManager.ApplicableGameVersion => throw new NotImplementedException();
  456. int IResourceManager.InternalResourceVersion => throw new NotImplementedException();
  457. int IResourceManager.AssetCount => throw new NotImplementedException();
  458. int IResourceManager.ResourceCount => throw new NotImplementedException();
  459. int IResourceManager.ResourceGroupCount => throw new NotImplementedException();
  460. string IResourceManager.UpdatePrefixUri { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  461. int IResourceManager.GenerateReadWriteVersionListLength { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  462. string IResourceManager.ApplyingResourcePackPath => throw new NotImplementedException();
  463. int IResourceManager.ApplyWaitingCount => throw new NotImplementedException();
  464. int IResourceManager.UpdateRetryCount { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  465. IResourceGroup IResourceManager.UpdatingResourceGroup => throw new NotImplementedException();
  466. int IResourceManager.UpdateWaitingCount => throw new NotImplementedException();
  467. int IResourceManager.UpdateWaitingWhilePlayingCount => throw new NotImplementedException();
  468. int IResourceManager.UpdateCandidateCount => throw new NotImplementedException();
  469. int IResourceManager.LoadTotalAgentCount => throw new NotImplementedException();
  470. int IResourceManager.LoadFreeAgentCount => throw new NotImplementedException();
  471. int IResourceManager.LoadWorkingAgentCount => throw new NotImplementedException();
  472. int IResourceManager.LoadWaitingTaskCount => throw new NotImplementedException();
  473. float IResourceManager.AssetAutoReleaseInterval { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  474. int IResourceManager.AssetCapacity { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  475. float IResourceManager.AssetExpireTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  476. int IResourceManager.AssetPriority { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  477. float IResourceManager.ResourceAutoReleaseInterval { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  478. int IResourceManager.ResourceCapacity { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  479. float IResourceManager.ResourceExpireTime { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  480. int IResourceManager.ResourcePriority { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
  481. #pragma warning disable 0067, 0414
  482. /// <summary>
  483. /// 资源应用成功事件。
  484. /// </summary>
  485. public event EventHandler<GameFramework.Resource.ResourceApplySuccessEventArgs> ResourceApplySuccess = null;
  486. /// <summary>
  487. /// 资源应用失败事件。
  488. /// </summary>
  489. public event EventHandler<GameFramework.Resource.ResourceApplyFailureEventArgs> ResourceApplyFailure = null;
  490. /// <summary>
  491. /// 资源更新开始事件。
  492. /// </summary>
  493. public event EventHandler<GameFramework.Resource.ResourceUpdateStartEventArgs> ResourceUpdateStart = null;
  494. /// <summary>
  495. /// 资源更新改变事件。
  496. /// </summary>
  497. public event EventHandler<GameFramework.Resource.ResourceUpdateChangedEventArgs> ResourceUpdateChanged = null;
  498. /// <summary>
  499. /// 资源更新成功事件。
  500. /// </summary>
  501. public event EventHandler<GameFramework.Resource.ResourceUpdateSuccessEventArgs> ResourceUpdateSuccess = null;
  502. /// <summary>
  503. /// 资源更新失败事件。
  504. /// </summary>
  505. public event EventHandler<GameFramework.Resource.ResourceUpdateFailureEventArgs> ResourceUpdateFailure = null;
  506. /// <summary>
  507. /// 资源更新全部完成事件。
  508. /// </summary>
  509. public event EventHandler<GameFramework.Resource.ResourceUpdateAllCompleteEventArgs> ResourceUpdateAllComplete = null;
  510. event EventHandler<GameFramework.Resource.ResourceApplySuccessEventArgs> IResourceManager.ResourceApplySuccess
  511. {
  512. add
  513. {
  514. // throw new NotImplementedException();
  515. }
  516. remove
  517. {
  518. // throw new NotImplementedException();
  519. }
  520. }
  521. event EventHandler<GameFramework.Resource.ResourceApplyFailureEventArgs> IResourceManager.ResourceApplyFailure
  522. {
  523. add
  524. {
  525. throw new NotImplementedException();
  526. }
  527. remove
  528. {
  529. throw new NotImplementedException();
  530. }
  531. }
  532. event EventHandler<GameFramework.Resource.ResourceUpdateStartEventArgs> IResourceManager.ResourceUpdateStart
  533. {
  534. add
  535. {
  536. throw new NotImplementedException();
  537. }
  538. remove
  539. {
  540. throw new NotImplementedException();
  541. }
  542. }
  543. event EventHandler<GameFramework.Resource.ResourceUpdateChangedEventArgs> IResourceManager.ResourceUpdateChanged
  544. {
  545. add
  546. {
  547. throw new NotImplementedException();
  548. }
  549. remove
  550. {
  551. throw new NotImplementedException();
  552. }
  553. }
  554. event EventHandler<GameFramework.Resource.ResourceUpdateSuccessEventArgs> IResourceManager.ResourceUpdateSuccess
  555. {
  556. add
  557. {
  558. throw new NotImplementedException();
  559. }
  560. remove
  561. {
  562. throw new NotImplementedException();
  563. }
  564. }
  565. event EventHandler<GameFramework.Resource.ResourceUpdateFailureEventArgs> IResourceManager.ResourceUpdateFailure
  566. {
  567. add
  568. {
  569. throw new NotImplementedException();
  570. }
  571. remove
  572. {
  573. throw new NotImplementedException();
  574. }
  575. }
  576. event EventHandler<GameFramework.Resource.ResourceUpdateAllCompleteEventArgs> IResourceManager.ResourceUpdateAllComplete
  577. {
  578. add
  579. {
  580. throw new NotImplementedException();
  581. }
  582. remove
  583. {
  584. throw new NotImplementedException();
  585. }
  586. }
  587. #pragma warning restore 0067, 0414
  588. private void Awake()
  589. {
  590. m_ReadOnlyPath = null;
  591. m_ReadWritePath = null;
  592. m_CachedAssets = new Dictionary<string, UnityEngine.Object>(StringComparer.Ordinal);
  593. m_LoadAssetInfos = new GameFrameworkLinkedList<LoadAssetInfo>();
  594. m_LoadSceneInfos = new GameFrameworkLinkedList<LoadSceneInfo>();
  595. m_UnloadSceneInfos = new GameFrameworkLinkedList<UnloadSceneInfo>();
  596. BaseComponent baseComponent = GetComponent<BaseComponent>();
  597. if (baseComponent == null)
  598. {
  599. Log.Error("Can not find base component.");
  600. return;
  601. }
  602. if (baseComponent.EditorResourceMode)
  603. {
  604. baseComponent.EditorResourceHelper = this;
  605. enabled = true;
  606. }
  607. else
  608. {
  609. enabled = false;
  610. }
  611. }
  612. private void Update()
  613. {
  614. if (m_LoadAssetInfos.Count > 0)
  615. {
  616. int count = 0;
  617. LinkedListNode<LoadAssetInfo> current = m_LoadAssetInfos.First;
  618. while (current != null && count < m_LoadAssetCountPerFrame)
  619. {
  620. LoadAssetInfo loadAssetInfo = current.Value;
  621. float elapseSeconds = (float)(DateTime.UtcNow - loadAssetInfo.StartTime).TotalSeconds;
  622. if (elapseSeconds >= loadAssetInfo.DelaySeconds)
  623. {
  624. UnityEngine.Object asset = GetCachedAsset(loadAssetInfo.AssetName);
  625. if (asset == null)
  626. {
  627. #if UNITY_EDITOR
  628. if (loadAssetInfo.AssetType != null)
  629. {
  630. asset = UnityEditor.AssetDatabase.LoadAssetAtPath(loadAssetInfo.AssetName, loadAssetInfo.AssetType);
  631. }
  632. else
  633. {
  634. asset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(loadAssetInfo.AssetName);
  635. }
  636. if (m_EnableCachedAssets && asset != null)
  637. {
  638. m_CachedAssets.Add(loadAssetInfo.AssetName, asset);
  639. }
  640. #endif
  641. }
  642. if (asset != null)
  643. {
  644. if (loadAssetInfo.LoadAssetCallbacks.LoadAssetSuccessCallback != null)
  645. {
  646. loadAssetInfo.LoadAssetCallbacks.LoadAssetSuccessCallback(loadAssetInfo.AssetName, asset, elapseSeconds, loadAssetInfo.UserData);
  647. }
  648. }
  649. else
  650. {
  651. if (loadAssetInfo.LoadAssetCallbacks.LoadAssetFailureCallback != null)
  652. {
  653. loadAssetInfo.LoadAssetCallbacks.LoadAssetFailureCallback(loadAssetInfo.AssetName, LoadResourceStatus.AssetError, "Can not load this asset from asset database.", loadAssetInfo.UserData);
  654. }
  655. }
  656. LinkedListNode<LoadAssetInfo> next = current.Next;
  657. m_LoadAssetInfos.Remove(loadAssetInfo);
  658. current = next;
  659. count++;
  660. }
  661. else
  662. {
  663. if (loadAssetInfo.LoadAssetCallbacks.LoadAssetUpdateCallback != null)
  664. {
  665. loadAssetInfo.LoadAssetCallbacks.LoadAssetUpdateCallback(loadAssetInfo.AssetName, elapseSeconds / loadAssetInfo.DelaySeconds, loadAssetInfo.UserData);
  666. }
  667. current = current.Next;
  668. }
  669. }
  670. }
  671. if (m_LoadSceneInfos.Count > 0)
  672. {
  673. LinkedListNode<LoadSceneInfo> current = m_LoadSceneInfos.First;
  674. while (current != null)
  675. {
  676. LoadSceneInfo loadSceneInfo = current.Value;
  677. if (loadSceneInfo.AsyncOperation.isDone)
  678. {
  679. if (loadSceneInfo.AsyncOperation.allowSceneActivation)
  680. {
  681. if (loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback != null)
  682. {
  683. loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback(loadSceneInfo.SceneAssetName, (float)(DateTime.UtcNow - loadSceneInfo.StartTime).TotalSeconds, loadSceneInfo.UserData);
  684. }
  685. }
  686. else
  687. {
  688. if (loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback != null)
  689. {
  690. loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback(loadSceneInfo.SceneAssetName, LoadResourceStatus.AssetError, "Can not load this scene from asset database.", loadSceneInfo.UserData);
  691. }
  692. }
  693. LinkedListNode<LoadSceneInfo> next = current.Next;
  694. m_LoadSceneInfos.Remove(loadSceneInfo);
  695. current = next;
  696. }
  697. else
  698. {
  699. if (loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback != null)
  700. {
  701. loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback(loadSceneInfo.SceneAssetName, loadSceneInfo.AsyncOperation.progress, loadSceneInfo.UserData);
  702. }
  703. current = current.Next;
  704. }
  705. }
  706. }
  707. if (m_UnloadSceneInfos.Count > 0)
  708. {
  709. LinkedListNode<UnloadSceneInfo> current = m_UnloadSceneInfos.First;
  710. while (current != null)
  711. {
  712. UnloadSceneInfo unloadSceneInfo = current.Value;
  713. if (unloadSceneInfo.AsyncOperation.isDone)
  714. {
  715. if (unloadSceneInfo.AsyncOperation.allowSceneActivation)
  716. {
  717. if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback != null)
  718. {
  719. unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
  720. }
  721. }
  722. else
  723. {
  724. if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback != null)
  725. {
  726. unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
  727. }
  728. }
  729. LinkedListNode<UnloadSceneInfo> next = current.Next;
  730. m_UnloadSceneInfos.Remove(unloadSceneInfo);
  731. current = next;
  732. }
  733. else
  734. {
  735. current = current.Next;
  736. }
  737. }
  738. }
  739. }
  740. /// <summary>
  741. /// 设置资源只读区路径。
  742. /// </summary>
  743. /// <param name="readOnlyPath">资源只读区路径。</param>
  744. public void SetReadOnlyPath(string readOnlyPath)
  745. {
  746. if (string.IsNullOrEmpty(readOnlyPath))
  747. {
  748. Log.Error("Read-only path is invalid.");
  749. return;
  750. }
  751. m_ReadOnlyPath = readOnlyPath;
  752. }
  753. /// <summary>
  754. /// 设置资源读写区路径。
  755. /// </summary>
  756. /// <param name="readWritePath">资源读写区路径。</param>
  757. public void SetReadWritePath(string readWritePath)
  758. {
  759. if (string.IsNullOrEmpty(readWritePath))
  760. {
  761. Log.Error("Read-write path is invalid.");
  762. return;
  763. }
  764. m_ReadWritePath = readWritePath;
  765. }
  766. /// <summary>
  767. /// 设置资源模式。
  768. /// </summary>
  769. /// <param name="resourceMode">资源模式。</param>
  770. public void SetResourceMode(ResourceMode resourceMode)
  771. {
  772. throw new NotSupportedException("SetResourceMode");
  773. }
  774. /// <summary>
  775. /// 设置当前变体。
  776. /// </summary>
  777. /// <param name="currentVariant">当前变体。</param>
  778. public void SetCurrentVariant(string currentVariant)
  779. {
  780. throw new NotSupportedException("SetCurrentVariant");
  781. }
  782. /// <summary>
  783. /// 设置对象池管理器。
  784. /// </summary>
  785. /// <param name="objectPoolManager">对象池管理器。</param>
  786. public void SetObjectPoolManager(IObjectPoolManager objectPoolManager)
  787. {
  788. throw new NotSupportedException("SetObjectPoolManager");
  789. }
  790. /// <summary>
  791. /// 设置文件系统管理器。
  792. /// </summary>
  793. /// <param name="fileSystemManager">文件系统管理器。</param>
  794. public void SetFileSystemManager(IFileSystemManager fileSystemManager)
  795. {
  796. throw new NotSupportedException("SetFileSystemManager");
  797. }
  798. /// <summary>
  799. /// 设置下载管理器。
  800. /// </summary>
  801. /// <param name="downloadManager">下载管理器。</param>
  802. public void SetDownloadManager(IDownloadManager downloadManager)
  803. {
  804. throw new NotSupportedException("SetDownloadManager");
  805. }
  806. /// <summary>
  807. /// 设置解密资源回调函数。
  808. /// </summary>
  809. /// <param name="decryptResourceCallback">要设置的解密资源回调函数。</param>
  810. /// <remarks>如果不设置,将使用默认的解密资源回调函数。</remarks>
  811. public void SetDecryptResourceCallback(DecryptResourceCallback decryptResourceCallback)
  812. {
  813. throw new NotSupportedException("SetDecryptResourceCallback");
  814. }
  815. /// <summary>
  816. /// 设置资源辅助器。
  817. /// </summary>
  818. /// <param name="resourceHelper">资源辅助器。</param>
  819. public void SetResourceHelper(IResourceHelper resourceHelper)
  820. {
  821. throw new NotSupportedException("SetResourceHelper");
  822. }
  823. /// <summary>
  824. /// 增加加载资源代理辅助器。
  825. /// </summary>
  826. /// <param name="loadResourceAgentHelper">要增加的加载资源代理辅助器。</param>
  827. public void AddLoadResourceAgentHelper(ILoadResourceAgentHelper loadResourceAgentHelper)
  828. {
  829. throw new NotSupportedException("AddLoadResourceAgentHelper");
  830. }
  831. /// <summary>
  832. /// 使用单机模式并初始化资源。
  833. /// </summary>
  834. /// <param name="initResourcesCompleteCallback">使用单机模式并初始化资源完成时的回调函数。</param>
  835. public void InitResources(InitResourcesCompleteCallback initResourcesCompleteCallback)
  836. {
  837. throw new NotSupportedException("InitResources");
  838. }
  839. /// <summary>
  840. /// 检查版本资源列表。
  841. /// </summary>
  842. /// <param name="latestInternalResourceVersion">最新的内部资源版本号。</param>
  843. /// <returns>检查版本资源列表结果。</returns>
  844. public CheckVersionListResult CheckVersionList(int latestInternalResourceVersion)
  845. {
  846. throw new NotSupportedException("CheckVersionList");
  847. }
  848. /// <summary>
  849. /// 使用可更新模式并更新版本资源列表。
  850. /// </summary>
  851. /// <param name="versionListLength">版本资源列表大小。</param>
  852. /// <param name="versionListHashCode">版本资源列表哈希值。</param>
  853. /// <param name="versionListCompressedLength">版本资源列表压缩后大小。</param>
  854. /// <param name="versionListCompressedHashCode">版本资源列表压缩后哈希值。</param>
  855. /// <param name="updateVersionListCallbacks">版本资源列表更新回调函数集。</param>
  856. public void UpdateVersionList(int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode, UpdateVersionListCallbacks updateVersionListCallbacks)
  857. {
  858. throw new NotSupportedException("UpdateVersionList");
  859. }
  860. /// <summary>
  861. /// 使用可更新模式并检查资源。
  862. /// </summary>
  863. /// <param name="ignoreOtherVariant">是否忽略处理其它变体的资源,若不忽略,将会移除其它变体的资源。</param>
  864. /// <param name="checkResourcesCompleteCallback">使用可更新模式并检查资源完成时的回调函数。</param>
  865. public void CheckResources(bool ignoreOtherVariant, CheckResourcesCompleteCallback checkResourcesCompleteCallback)
  866. {
  867. throw new NotSupportedException("CheckResources");
  868. }
  869. /// <summary>
  870. /// 使用可更新模式并应用资源包资源。
  871. /// </summary>
  872. /// <param name="resourcePackPath">要应用的资源包路径。</param>
  873. /// <param name="applyResourcesCompleteCallback">使用可更新模式并应用资源包资源完成时的回调函数。</param>
  874. public void ApplyResources(string resourcePackPath, ApplyResourcesCompleteCallback applyResourcesCompleteCallback)
  875. {
  876. throw new NotSupportedException("ApplyResources");
  877. }
  878. /// <summary>
  879. /// 使用可更新模式并更新所有资源。
  880. /// </summary>
  881. /// <param name="updateResourcesCompleteCallback">使用可更新模式并更新默认资源组完成时的回调函数。</param>
  882. public void UpdateResources(UpdateResourcesCompleteCallback updateResourcesCompleteCallback)
  883. {
  884. throw new NotSupportedException("UpdateResources");
  885. }
  886. /// <summary>
  887. /// 使用可更新模式并更新指定资源组的资源。
  888. /// </summary>
  889. /// <param name="resourceGroupName">要更新的资源组名称。</param>
  890. /// <param name="updateResourcesCompleteCallback">使用可更新模式并更新指定资源组完成时的回调函数。</param>
  891. public void UpdateResources(string resourceGroupName, UpdateResourcesCompleteCallback updateResourcesCompleteCallback)
  892. {
  893. throw new NotSupportedException("UpdateResources");
  894. }
  895. /// <summary>
  896. /// 停止更新资源。
  897. /// </summary>
  898. public void StopUpdateResources()
  899. {
  900. throw new NotSupportedException("StopUpdateResources");
  901. }
  902. /// <summary>
  903. /// 校验资源包。
  904. /// </summary>
  905. /// <param name="resourcePackPath">要校验的资源包路径。</param>
  906. /// <returns>是否校验资源包成功。</returns>
  907. public bool VerifyResourcePack(string resourcePackPath)
  908. {
  909. throw new NotSupportedException("VerifyResourcePack");
  910. }
  911. /// <summary>
  912. /// 获取所有加载资源任务的信息。
  913. /// </summary>
  914. /// <returns>所有加载资源任务的信息。</returns>
  915. public TaskInfo[] GetAllLoadAssetInfos()
  916. {
  917. throw new NotSupportedException("GetAllLoadAssetInfos");
  918. }
  919. /// <summary>
  920. /// 获取所有加载资源任务的信息。
  921. /// </summary>
  922. /// <param name="results">所有加载资源任务的信息。</param>
  923. public void GetAllLoadAssetInfos(List<TaskInfo> results)
  924. {
  925. throw new NotSupportedException("GetAllLoadAssetInfos");
  926. }
  927. /// <summary>
  928. /// 检查资源是否存在。
  929. /// </summary>
  930. /// <param name="assetName">要检查资源的名称。</param>
  931. /// <returns>检查资源是否存在的结果。</returns>
  932. public HasAssetResult HasAsset(string assetName)
  933. {
  934. #if UNITY_EDITOR
  935. UnityEngine.Object obj = UnityEditor.AssetDatabase.LoadMainAssetAtPath(assetName);
  936. if (obj == null)
  937. {
  938. return HasAssetResult.NotExist;
  939. }
  940. HasAssetResult result = obj.GetType() == typeof(UnityEditor.DefaultAsset) ? HasAssetResult.BinaryOnDisk : HasAssetResult.AssetOnDisk;
  941. obj = null;
  942. UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();
  943. return result;
  944. #else
  945. return HasAssetResult.NotExist;
  946. #endif
  947. }
  948. /// <summary>
  949. /// 异步加载资源。
  950. /// </summary>
  951. /// <param name="assetName">要加载资源的名称。</param>
  952. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  953. public void LoadAsset(string assetName, LoadAssetCallbacks loadAssetCallbacks)
  954. {
  955. LoadAsset(assetName, null, DefaultPriority, loadAssetCallbacks, null);
  956. }
  957. /// <summary>
  958. /// 异步加载资源。
  959. /// </summary>
  960. /// <param name="assetName">要加载资源的名称。</param>
  961. /// <param name="assetType">要加载资源的类型。</param>
  962. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  963. public void LoadAsset(string assetName, Type assetType, LoadAssetCallbacks loadAssetCallbacks)
  964. {
  965. LoadAsset(assetName, assetType, DefaultPriority, loadAssetCallbacks, null);
  966. }
  967. /// <summary>
  968. /// 异步加载资源。
  969. /// </summary>
  970. /// <param name="assetName">要加载资源的名称。</param>
  971. /// <param name="priority">加载资源的优先级。</param>
  972. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  973. public void LoadAsset(string assetName, int priority, LoadAssetCallbacks loadAssetCallbacks)
  974. {
  975. LoadAsset(assetName, null, priority, loadAssetCallbacks, null);
  976. }
  977. /// <summary>
  978. /// 异步加载资源。
  979. /// </summary>
  980. /// <param name="assetName">要加载资源的名称。</param>
  981. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  982. /// <param name="userData">用户自定义数据。</param>
  983. public void LoadAsset(string assetName, LoadAssetCallbacks loadAssetCallbacks, object userData)
  984. {
  985. LoadAsset(assetName, null, DefaultPriority, loadAssetCallbacks, userData);
  986. }
  987. /// <summary>
  988. /// 异步加载资源。
  989. /// </summary>
  990. /// <param name="assetName">要加载资源的名称。</param>
  991. /// <param name="assetType">要加载资源的类型。</param>
  992. /// <param name="priority">加载资源的优先级。</param>
  993. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  994. public void LoadAsset(string assetName, Type assetType, int priority, LoadAssetCallbacks loadAssetCallbacks)
  995. {
  996. LoadAsset(assetName, assetType, priority, loadAssetCallbacks, null);
  997. }
  998. /// <summary>
  999. /// 异步加载资源。
  1000. /// </summary>
  1001. /// <param name="assetName">要加载资源的名称。</param>
  1002. /// <param name="assetType">要加载资源的类型。</param>
  1003. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  1004. /// <param name="userData">用户自定义数据。</param>
  1005. public void LoadAsset(string assetName, Type assetType, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1006. {
  1007. LoadAsset(assetName, assetType, DefaultPriority, loadAssetCallbacks, userData);
  1008. }
  1009. /// <summary>
  1010. /// 异步加载资源。
  1011. /// </summary>
  1012. /// <param name="assetName">要加载资源的名称。</param>
  1013. /// <param name="priority">加载资源的优先级。</param>
  1014. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  1015. /// <param name="userData">用户自定义数据。</param>
  1016. public void LoadAsset(string assetName, int priority, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1017. {
  1018. LoadAsset(assetName, null, priority, loadAssetCallbacks, userData);
  1019. }
  1020. /// <summary>
  1021. /// 异步加载资源。
  1022. /// </summary>
  1023. /// <param name="assetName">要加载资源的名称。</param>
  1024. /// <param name="assetType">要加载资源的类型。</param>
  1025. /// <param name="priority">加载资源的优先级。</param>
  1026. /// <param name="loadAssetCallbacks">加载资源回调函数集。</param>
  1027. /// <param name="userData">用户自定义数据。</param>
  1028. public void LoadAsset(string assetName, Type assetType, int priority, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1029. {
  1030. if (loadAssetCallbacks == null)
  1031. {
  1032. Log.Error("Load asset callbacks is invalid.");
  1033. return;
  1034. }
  1035. if (string.IsNullOrEmpty(assetName))
  1036. {
  1037. if (loadAssetCallbacks.LoadAssetFailureCallback != null)
  1038. {
  1039. loadAssetCallbacks.LoadAssetFailureCallback(assetName, LoadResourceStatus.NotExist, "Asset name is invalid.", userData);
  1040. }
  1041. return;
  1042. }
  1043. if (!assetName.StartsWith("Assets/", StringComparison.Ordinal))
  1044. {
  1045. if (loadAssetCallbacks.LoadAssetFailureCallback != null)
  1046. {
  1047. loadAssetCallbacks.LoadAssetFailureCallback(assetName, LoadResourceStatus.NotExist, Utility.Text.Format("Asset name '{0}' is invalid.", assetName), userData);
  1048. }
  1049. return;
  1050. }
  1051. if (!HasFile(assetName))
  1052. {
  1053. if (loadAssetCallbacks.LoadAssetFailureCallback != null)
  1054. {
  1055. loadAssetCallbacks.LoadAssetFailureCallback(assetName, LoadResourceStatus.NotExist, Utility.Text.Format("Asset '{0}' is not exist.", assetName), userData);
  1056. }
  1057. return;
  1058. }
  1059. m_LoadAssetInfos.AddLast(new LoadAssetInfo(assetName, assetType, priority, DateTime.UtcNow, m_MinLoadAssetRandomDelaySeconds + (float)Utility.Random.GetRandomDouble() * (m_MaxLoadAssetRandomDelaySeconds - m_MinLoadAssetRandomDelaySeconds), loadAssetCallbacks, userData));
  1060. }
  1061. /// <summary>
  1062. /// 卸载资源。
  1063. /// </summary>
  1064. /// <param name="asset">要卸载的资源。</param>
  1065. public void UnloadAsset(object asset)
  1066. {
  1067. // Do nothing in editor resource mode.
  1068. }
  1069. /// <summary>
  1070. /// 异步加载场景。
  1071. /// </summary>
  1072. /// <param name="sceneAssetName">要加载场景资源的名称。</param>
  1073. /// <param name="loadSceneCallbacks">加载场景回调函数集。</param>
  1074. public void LoadScene(string sceneAssetName, LoadSceneCallbacks loadSceneCallbacks)
  1075. {
  1076. LoadScene(sceneAssetName, DefaultPriority, loadSceneCallbacks, null);
  1077. }
  1078. /// <summary>
  1079. /// 异步加载场景。
  1080. /// </summary>
  1081. /// <param name="sceneAssetName">要加载场景资源的名称。</param>
  1082. /// <param name="priority">加载场景资源的优先级。</param>
  1083. /// <param name="loadSceneCallbacks">加载场景回调函数集。</param>
  1084. public void LoadScene(string sceneAssetName, int priority, LoadSceneCallbacks loadSceneCallbacks)
  1085. {
  1086. LoadScene(sceneAssetName, priority, loadSceneCallbacks, null);
  1087. }
  1088. /// <summary>
  1089. /// 异步加载场景。
  1090. /// </summary>
  1091. /// <param name="sceneAssetName">要加载场景资源的名称。</param>
  1092. /// <param name="loadSceneCallbacks">加载场景回调函数集。</param>
  1093. /// <param name="userData">用户自定义数据。</param>
  1094. public void LoadScene(string sceneAssetName, LoadSceneCallbacks loadSceneCallbacks, object userData)
  1095. {
  1096. LoadScene(sceneAssetName, DefaultPriority, loadSceneCallbacks, userData);
  1097. }
  1098. /// <summary>
  1099. /// 异步加载场景。
  1100. /// </summary>
  1101. /// <param name="sceneAssetName">要加载场景资源的名称。</param>
  1102. /// <param name="priority">加载场景资源的优先级。</param>
  1103. /// <param name="loadSceneCallbacks">加载场景回调函数集。</param>
  1104. /// <param name="userData">用户自定义数据。</param>
  1105. public void LoadScene(string sceneAssetName, int priority, LoadSceneCallbacks loadSceneCallbacks, object userData)
  1106. {
  1107. if (loadSceneCallbacks == null)
  1108. {
  1109. Log.Error("Load scene callbacks is invalid.");
  1110. return;
  1111. }
  1112. if (string.IsNullOrEmpty(sceneAssetName))
  1113. {
  1114. if (loadSceneCallbacks.LoadSceneFailureCallback != null)
  1115. {
  1116. loadSceneCallbacks.LoadSceneFailureCallback(sceneAssetName, LoadResourceStatus.NotExist, "Scene asset name is invalid.", userData);
  1117. }
  1118. return;
  1119. }
  1120. if (!sceneAssetName.StartsWith("Assets/", StringComparison.Ordinal) || !sceneAssetName.EndsWith(".unity", StringComparison.Ordinal))
  1121. {
  1122. if (loadSceneCallbacks.LoadSceneFailureCallback != null)
  1123. {
  1124. loadSceneCallbacks.LoadSceneFailureCallback(sceneAssetName, LoadResourceStatus.NotExist, Utility.Text.Format("Scene asset name '{0}' is invalid.", sceneAssetName), userData);
  1125. }
  1126. return;
  1127. }
  1128. if (!HasFile(sceneAssetName))
  1129. {
  1130. if (loadSceneCallbacks.LoadSceneFailureCallback != null)
  1131. {
  1132. loadSceneCallbacks.LoadSceneFailureCallback(sceneAssetName, LoadResourceStatus.NotExist, Utility.Text.Format("Scene '{0}' is not exist.", sceneAssetName), userData);
  1133. }
  1134. return;
  1135. }
  1136. #if UNITY_5_5_OR_NEWER
  1137. AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(sceneAssetName, LoadSceneMode.Additive);
  1138. #else
  1139. AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(SceneComponent.GetSceneName(sceneAssetName), LoadSceneMode.Additive);
  1140. #endif
  1141. if (asyncOperation == null)
  1142. {
  1143. return;
  1144. }
  1145. m_LoadSceneInfos.AddLast(new LoadSceneInfo(asyncOperation, sceneAssetName, priority, DateTime.UtcNow, loadSceneCallbacks, userData));
  1146. }
  1147. /// <summary>
  1148. /// 异步卸载场景。
  1149. /// </summary>
  1150. /// <param name="sceneAssetName">要卸载场景资源的名称。</param>
  1151. /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param>
  1152. public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks)
  1153. {
  1154. UnloadScene(sceneAssetName, unloadSceneCallbacks, null);
  1155. }
  1156. /// <summary>
  1157. /// 异步卸载场景。
  1158. /// </summary>
  1159. /// <param name="sceneAssetName">要卸载场景资源的名称。</param>
  1160. /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param>
  1161. /// <param name="userData">用户自定义数据。</param>
  1162. public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)
  1163. {
  1164. if (string.IsNullOrEmpty(sceneAssetName))
  1165. {
  1166. Log.Error("Scene asset name is invalid.");
  1167. return;
  1168. }
  1169. if (!sceneAssetName.StartsWith("Assets/", StringComparison.Ordinal) || !sceneAssetName.EndsWith(".unity", StringComparison.Ordinal))
  1170. {
  1171. Log.Error("Scene asset name '{0}' is invalid.", sceneAssetName);
  1172. return;
  1173. }
  1174. if (unloadSceneCallbacks == null)
  1175. {
  1176. Log.Error("Unload scene callbacks is invalid.");
  1177. return;
  1178. }
  1179. if (!HasFile(sceneAssetName))
  1180. {
  1181. Log.Error("Scene '{0}' is not exist.", sceneAssetName);
  1182. return;
  1183. }
  1184. #if UNITY_5_5_OR_NEWER
  1185. AsyncOperation asyncOperation = SceneManager.UnloadSceneAsync(sceneAssetName);
  1186. if (asyncOperation == null)
  1187. {
  1188. return;
  1189. }
  1190. m_UnloadSceneInfos.AddLast(new UnloadSceneInfo(asyncOperation, sceneAssetName, unloadSceneCallbacks, userData));
  1191. #else
  1192. if (SceneManager.UnloadScene(SceneComponent.GetSceneName(sceneAssetName)))
  1193. {
  1194. if (unloadSceneCallbacks.UnloadSceneSuccessCallback != null)
  1195. {
  1196. unloadSceneCallbacks.UnloadSceneSuccessCallback(sceneAssetName, userData);
  1197. }
  1198. }
  1199. else
  1200. {
  1201. if (unloadSceneCallbacks.UnloadSceneFailureCallback != null)
  1202. {
  1203. unloadSceneCallbacks.UnloadSceneFailureCallback(sceneAssetName, userData);
  1204. }
  1205. }
  1206. #endif
  1207. }
  1208. /// <summary>
  1209. /// 获取二进制资源的实际路径。
  1210. /// </summary>
  1211. /// <param name="binaryAssetName">要获取实际路径的二进制资源的名称。</param>
  1212. /// <returns>二进制资源的实际路径。</returns>
  1213. /// <remarks>此方法仅适用于二进制资源存储在磁盘(而非文件系统)中的情况。若二进制资源存储在文件系统中时,返回值将始终为空。</remarks>
  1214. public string GetBinaryPath(string binaryAssetName)
  1215. {
  1216. if (!HasFile(binaryAssetName))
  1217. {
  1218. return null;
  1219. }
  1220. return Application.dataPath.Substring(0, Application.dataPath.Length - AssetsStringLength) + binaryAssetName;
  1221. }
  1222. /// <summary>
  1223. /// 获取二进制资源的实际路径。
  1224. /// </summary>
  1225. /// <param name="binaryAssetName">要获取实际路径的二进制资源的名称。</param>
  1226. /// <param name="storageInReadOnly">二进制资源是否存储在只读区中。</param>
  1227. /// <param name="storageInFileSystem">二进制资源是否存储在文件系统中。</param>
  1228. /// <param name="relativePath">二进制资源或存储二进制资源的文件系统,相对于只读区或者读写区的相对路径。</param>
  1229. /// <param name="fileName">若二进制资源存储在文件系统中,则指示二进制资源在文件系统中的名称,否则此参数返回空。</param>
  1230. /// <returns>是否获取二进制资源的实际路径成功。</returns>
  1231. public bool GetBinaryPath(string binaryAssetName, out bool storageInReadOnly, out bool storageInFileSystem, out string relativePath, out string fileName)
  1232. {
  1233. throw new NotSupportedException("GetBinaryPath");
  1234. }
  1235. /// <summary>
  1236. /// 获取二进制资源的长度。
  1237. /// </summary>
  1238. /// <param name="binaryAssetName">要获取长度的二进制资源的名称。</param>
  1239. /// <returns>二进制资源的长度。</returns>
  1240. public int GetBinaryLength(string binaryAssetName)
  1241. {
  1242. string binaryPath = GetBinaryPath(binaryAssetName);
  1243. if (string.IsNullOrEmpty(binaryPath))
  1244. {
  1245. return -1;
  1246. }
  1247. return (int)new System.IO.FileInfo(binaryPath).Length;
  1248. }
  1249. /// <summary>
  1250. /// 异步加载二进制资源。
  1251. /// </summary>
  1252. /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
  1253. /// <param name="loadBinaryCallbacks">加载二进制资源回调函数集。</param>
  1254. public void LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks)
  1255. {
  1256. LoadBinary(binaryAssetName, loadBinaryCallbacks, null);
  1257. }
  1258. /// <summary>
  1259. /// 异步加载二进制资源。
  1260. /// </summary>
  1261. /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
  1262. /// <param name="loadBinaryCallbacks">加载二进制资源回调函数集。</param>
  1263. /// <param name="userData">用户自定义数据。</param>
  1264. public void LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks, object userData)
  1265. {
  1266. if (loadBinaryCallbacks == null)
  1267. {
  1268. Log.Error("Load binary callbacks is invalid.");
  1269. return;
  1270. }
  1271. if (string.IsNullOrEmpty(binaryAssetName))
  1272. {
  1273. if (loadBinaryCallbacks.LoadBinaryFailureCallback != null)
  1274. {
  1275. loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.NotExist, "Binary asset name is invalid.", userData);
  1276. }
  1277. return;
  1278. }
  1279. if (!binaryAssetName.StartsWith("Assets/", StringComparison.Ordinal))
  1280. {
  1281. if (loadBinaryCallbacks.LoadBinaryFailureCallback != null)
  1282. {
  1283. loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.NotExist, Utility.Text.Format("Binary asset name '{0}' is invalid.", binaryAssetName), userData);
  1284. }
  1285. return;
  1286. }
  1287. string binaryPath = GetBinaryPath(binaryAssetName);
  1288. if (binaryPath == null)
  1289. {
  1290. if (loadBinaryCallbacks.LoadBinaryFailureCallback != null)
  1291. {
  1292. loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.NotExist, Utility.Text.Format("Binary asset '{0}' is not exist.", binaryAssetName), userData);
  1293. }
  1294. return;
  1295. }
  1296. try
  1297. {
  1298. byte[] binaryBytes = File.ReadAllBytes(binaryPath);
  1299. loadBinaryCallbacks.LoadBinarySuccessCallback(binaryAssetName, binaryBytes, 0f, userData);
  1300. }
  1301. catch (Exception exception)
  1302. {
  1303. if (loadBinaryCallbacks.LoadBinaryFailureCallback != null)
  1304. {
  1305. loadBinaryCallbacks.LoadBinaryFailureCallback(binaryAssetName, LoadResourceStatus.AssetError, exception.ToString(), userData);
  1306. }
  1307. }
  1308. }
  1309. /// <summary>
  1310. /// 从文件系统中加载二进制资源。
  1311. /// </summary>
  1312. /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
  1313. /// <returns>存储加载二进制资源的二进制流。</returns>
  1314. public byte[] LoadBinaryFromFileSystem(string binaryAssetName)
  1315. {
  1316. throw new NotSupportedException("LoadBinaryFromFileSystem");
  1317. }
  1318. /// <summary>
  1319. /// 从文件系统中加载二进制资源。
  1320. /// </summary>
  1321. /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
  1322. /// <param name="buffer">存储加载二进制资源的二进制流。</param>
  1323. /// <returns>实际加载了多少字节。</returns>
  1324. public int LoadBinaryFromFileSystem(string binaryAssetName, byte[] buffer)
  1325. {
  1326. throw new NotSupportedException("LoadBinaryFromFileSystem");
  1327. }
  1328. /// <summary>
  1329. /// 从文件系统中加载二进制资源。
  1330. /// </summary>
  1331. /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
  1332. /// <param name="buffer">存储加载二进制资源的二进制流。</param>
  1333. /// <param name="startIndex">存储加载二进制资源的二进制流的起始位置。</param>
  1334. /// <returns>实际加载了多少字节。</returns>
  1335. public int LoadBinaryFromFileSystem(string binaryAssetName, byte[] buffer, int startIndex)
  1336. {
  1337. throw new NotSupportedException("LoadBinaryFromFileSystem");
  1338. }
  1339. /// <summary>
  1340. /// 从文件系统中加载二进制资源。
  1341. /// </summary>
  1342. /// <param name="binaryAssetName">要加载二进制资源的名称。</param>
  1343. /// <param name="buffer">存储加载二进制资源的二进制流。</param>
  1344. /// <param name="startIndex">存储加载二进制资源的二进制流的起始位置。</param>
  1345. /// <param name="length">存储加载二进制资源的二进制流的长度。</param>
  1346. /// <returns>实际加载了多少字节。</returns>
  1347. public int LoadBinaryFromFileSystem(string binaryAssetName, byte[] buffer, int startIndex, int length)
  1348. {
  1349. throw new NotSupportedException("LoadBinaryFromFileSystem");
  1350. }
  1351. /// <summary>
  1352. /// 从文件系统中加载二进制资源的片段。
  1353. /// </summary>
  1354. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1355. /// <param name="length">要加载片段的长度。</param>
  1356. /// <returns>存储加载二进制资源片段内容的二进制流。</returns>
  1357. public byte[] LoadBinarySegmentFromFileSystem(string binaryAssetName, int length)
  1358. {
  1359. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1360. }
  1361. /// <summary>
  1362. /// 从文件系统中加载二进制资源的片段。
  1363. /// </summary>
  1364. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1365. /// <param name="offset">要加载片段的偏移。</param>
  1366. /// <param name="length">要加载片段的长度。</param>
  1367. /// <returns>存储加载二进制资源片段内容的二进制流。</returns>
  1368. public byte[] LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, int length)
  1369. {
  1370. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1371. }
  1372. /// <summary>
  1373. /// 从文件系统中加载二进制资源的片段。
  1374. /// </summary>
  1375. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1376. /// <param name="buffer">存储加载二进制资源片段内容的二进制流。</param>
  1377. /// <returns>实际加载了多少字节。</returns>
  1378. public int LoadBinarySegmentFromFileSystem(string binaryAssetName, byte[] buffer)
  1379. {
  1380. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1381. }
  1382. /// <summary>
  1383. /// 从文件系统中加载二进制资源的片段。
  1384. /// </summary>
  1385. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1386. /// <param name="buffer">存储加载二进制资源片段内容的二进制流。</param>
  1387. /// <param name="length">要加载片段的长度。</param>
  1388. /// <returns>实际加载了多少字节。</returns>
  1389. public int LoadBinarySegmentFromFileSystem(string binaryAssetName, byte[] buffer, int length)
  1390. {
  1391. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1392. }
  1393. /// <summary>
  1394. /// 从文件系统中加载二进制资源的片段。
  1395. /// </summary>
  1396. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1397. /// <param name="buffer">存储加载二进制资源片段内容的二进制流。</param>
  1398. /// <param name="startIndex">存储加载二进制资源片段内容的二进制流的起始位置。</param>
  1399. /// <param name="length">要加载片段的长度。</param>
  1400. /// <returns>实际加载了多少字节。</returns>
  1401. public int LoadBinarySegmentFromFileSystem(string binaryAssetName, byte[] buffer, int startIndex, int length)
  1402. {
  1403. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1404. }
  1405. /// <summary>
  1406. /// 从文件系统中加载二进制资源的片段。
  1407. /// </summary>
  1408. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1409. /// <param name="offset">要加载片段的偏移。</param>
  1410. /// <param name="buffer">存储加载二进制资源片段内容的二进制流。</param>
  1411. /// <returns>实际加载了多少字节。</returns>
  1412. public int LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, byte[] buffer)
  1413. {
  1414. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1415. }
  1416. /// <summary>
  1417. /// 从文件系统中加载二进制资源的片段。
  1418. /// </summary>
  1419. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1420. /// <param name="offset">要加载片段的偏移。</param>
  1421. /// <param name="buffer">存储加载二进制资源片段内容的二进制流。</param>
  1422. /// <param name="length">要加载片段的长度。</param>
  1423. /// <returns>实际加载了多少字节。</returns>
  1424. public int LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, byte[] buffer, int length)
  1425. {
  1426. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1427. }
  1428. /// <summary>
  1429. /// 从文件系统中加载二进制资源的片段。
  1430. /// </summary>
  1431. /// <param name="binaryAssetName">要加载片段的二进制资源的名称。</param>
  1432. /// <param name="offset">要加载片段的偏移。</param>
  1433. /// <param name="buffer">存储加载二进制资源片段内容的二进制流。</param>
  1434. /// <param name="startIndex">存储加载二进制资源片段内容的二进制流的起始位置。</param>
  1435. /// <param name="length">要加载片段的长度。</param>
  1436. /// <returns>实际加载了多少字节。</returns>
  1437. public int LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, byte[] buffer, int startIndex, int length)
  1438. {
  1439. throw new NotSupportedException("LoadBinarySegmentFromFileSystem");
  1440. }
  1441. /// <summary>
  1442. /// 检查资源组是否存在。
  1443. /// </summary>
  1444. /// <param name="resourceGroupName">要检查资源组的名称。</param>
  1445. /// <returns>资源组是否存在。</returns>
  1446. public bool HasResourceGroup(string resourceGroupName)
  1447. {
  1448. throw new NotSupportedException("HasResourceGroup");
  1449. }
  1450. /// <summary>
  1451. /// 获取默认资源组。
  1452. /// </summary>
  1453. /// <returns>默认资源组。</returns>
  1454. public IResourceGroup GetResourceGroup()
  1455. {
  1456. throw new NotSupportedException("GetResourceGroup");
  1457. }
  1458. /// <summary>
  1459. /// 获取资源组。
  1460. /// </summary>
  1461. /// <param name="resourceGroupName">要获取的资源组名称。</param>
  1462. /// <returns>要获取的资源组。</returns>
  1463. public IResourceGroup GetResourceGroup(string resourceGroupName)
  1464. {
  1465. throw new NotSupportedException("GetResourceGroup");
  1466. }
  1467. /// <summary>
  1468. /// 获取所有资源组。
  1469. /// </summary>
  1470. /// <returns>所有资源组。</returns>
  1471. public IResourceGroup[] GetAllResourceGroups()
  1472. {
  1473. throw new NotSupportedException("GetAllResourceGroups");
  1474. }
  1475. /// <summary>
  1476. /// 获取所有资源组。
  1477. /// </summary>
  1478. /// <param name="results">所有资源组。</param>
  1479. public void GetAllResourceGroups(List<IResourceGroup> results)
  1480. {
  1481. throw new NotSupportedException("GetAllResourceGroups");
  1482. }
  1483. /// <summary>
  1484. /// 获取资源组集合。
  1485. /// </summary>
  1486. /// <param name="resourceGroupNames">要获取的资源组名称的集合。</param>
  1487. /// <returns>要获取的资源组集合。</returns>
  1488. public IResourceGroupCollection GetResourceGroupCollection(params string[] resourceGroupNames)
  1489. {
  1490. throw new NotSupportedException("GetResourceGroupCollection");
  1491. }
  1492. /// <summary>
  1493. /// 获取资源组集合。
  1494. /// </summary>
  1495. /// <param name="resourceGroupNames">要获取的资源组名称的集合。</param>
  1496. /// <returns>要获取的资源组集合。</returns>
  1497. public IResourceGroupCollection GetResourceGroupCollection(List<string> resourceGroupNames)
  1498. {
  1499. throw new NotSupportedException("GetResourceGroupCollection");
  1500. }
  1501. private bool HasFile(string assetName)
  1502. {
  1503. if (string.IsNullOrEmpty(assetName))
  1504. {
  1505. return false;
  1506. }
  1507. if (HasCachedAsset(assetName))
  1508. {
  1509. return true;
  1510. }
  1511. string assetFullName = Application.dataPath.Substring(0, Application.dataPath.Length - AssetsStringLength) + assetName;
  1512. if (string.IsNullOrEmpty(assetFullName))
  1513. {
  1514. return false;
  1515. }
  1516. string[] splitedAssetFullName = assetFullName.Split('/');
  1517. string currentPath = Path.GetPathRoot(assetFullName);
  1518. for (int i = 1; i < splitedAssetFullName.Length - 1; i++)
  1519. {
  1520. string[] directoryNames = Directory.GetDirectories(currentPath, splitedAssetFullName[i]);
  1521. if (directoryNames.Length != 1)
  1522. {
  1523. return false;
  1524. }
  1525. currentPath = directoryNames[0];
  1526. }
  1527. string[] fileNames = Directory.GetFiles(currentPath, splitedAssetFullName[splitedAssetFullName.Length - 1]);
  1528. if (fileNames.Length != 1)
  1529. {
  1530. return false;
  1531. }
  1532. string fileFullName = Utility.Path.GetRegularPath(fileNames[0]);
  1533. if (fileFullName == null)
  1534. {
  1535. return false;
  1536. }
  1537. if (assetFullName != fileFullName)
  1538. {
  1539. if (assetFullName.ToLowerInvariant() == fileFullName.ToLowerInvariant())
  1540. {
  1541. Log.Warning("The real path of the specific asset '{0}' is '{1}'. Check the case of letters in the path.", assetName, "Assets" + fileFullName.Substring(Application.dataPath.Length));
  1542. }
  1543. return false;
  1544. }
  1545. return true;
  1546. }
  1547. private bool HasCachedAsset(string assetName)
  1548. {
  1549. if (!m_EnableCachedAssets)
  1550. {
  1551. return false;
  1552. }
  1553. if (string.IsNullOrEmpty(assetName))
  1554. {
  1555. return false;
  1556. }
  1557. return m_CachedAssets.ContainsKey(assetName);
  1558. }
  1559. private UnityEngine.Object GetCachedAsset(string assetName)
  1560. {
  1561. if (!m_EnableCachedAssets)
  1562. {
  1563. return null;
  1564. }
  1565. if (string.IsNullOrEmpty(assetName))
  1566. {
  1567. return null;
  1568. }
  1569. UnityEngine.Object asset = null;
  1570. if (m_CachedAssets.TryGetValue(assetName, out asset))
  1571. {
  1572. return asset;
  1573. }
  1574. return null;
  1575. }
  1576. void IResourceManager.SetReadOnlyPath(string readOnlyPath)
  1577. {
  1578. throw new NotImplementedException();
  1579. }
  1580. void IResourceManager.SetReadWritePath(string readWritePath)
  1581. {
  1582. throw new NotImplementedException();
  1583. }
  1584. void IResourceManager.SetResourceMode(ResourceMode resourceMode)
  1585. {
  1586. throw new NotImplementedException();
  1587. }
  1588. void IResourceManager.SetCurrentVariant(string currentVariant)
  1589. {
  1590. throw new NotImplementedException();
  1591. }
  1592. void IResourceManager.SetObjectPoolManager(IObjectPoolManager objectPoolManager)
  1593. {
  1594. throw new NotImplementedException();
  1595. }
  1596. void IResourceManager.SetFileSystemManager(IFileSystemManager fileSystemManager)
  1597. {
  1598. throw new NotImplementedException();
  1599. }
  1600. void IResourceManager.SetDownloadManager(IDownloadManager downloadManager)
  1601. {
  1602. throw new NotImplementedException();
  1603. }
  1604. void IResourceManager.SetDecryptResourceCallback(DecryptResourceCallback decryptResourceCallback)
  1605. {
  1606. throw new NotImplementedException();
  1607. }
  1608. void IResourceManager.SetResourceHelper(IResourceHelper resourceHelper)
  1609. {
  1610. throw new NotImplementedException();
  1611. }
  1612. void IResourceManager.AddLoadResourceAgentHelper(ILoadResourceAgentHelper loadResourceAgentHelper)
  1613. {
  1614. throw new NotImplementedException();
  1615. }
  1616. void IResourceManager.InitResources(InitResourcesCompleteCallback initResourcesCompleteCallback)
  1617. {
  1618. throw new NotImplementedException();
  1619. }
  1620. CheckVersionListResult IResourceManager.CheckVersionList(int latestInternalResourceVersion)
  1621. {
  1622. throw new NotImplementedException();
  1623. }
  1624. void IResourceManager.UpdateVersionList(int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode, UpdateVersionListCallbacks updateVersionListCallbacks)
  1625. {
  1626. throw new NotImplementedException();
  1627. }
  1628. void IResourceManager.CheckResources(bool ignoreOtherVariant, CheckResourcesCompleteCallback checkResourcesCompleteCallback)
  1629. {
  1630. throw new NotImplementedException();
  1631. }
  1632. void IResourceManager.ApplyResources(string resourcePackPath, ApplyResourcesCompleteCallback applyResourcesCompleteCallback)
  1633. {
  1634. throw new NotImplementedException();
  1635. }
  1636. void IResourceManager.UpdateResources(UpdateResourcesCompleteCallback updateResourcesCompleteCallback)
  1637. {
  1638. throw new NotImplementedException();
  1639. }
  1640. void IResourceManager.UpdateResources(string resourceGroupName, UpdateResourcesCompleteCallback updateResourcesCompleteCallback)
  1641. {
  1642. throw new NotImplementedException();
  1643. }
  1644. void IResourceManager.StopUpdateResources()
  1645. {
  1646. throw new NotImplementedException();
  1647. }
  1648. bool IResourceManager.VerifyResourcePack(string resourcePackPath)
  1649. {
  1650. throw new NotImplementedException();
  1651. }
  1652. GameFramework.TaskInfo[] IResourceManager.GetAllLoadAssetInfos()
  1653. {
  1654. throw new NotImplementedException();
  1655. }
  1656. void IResourceManager.GetAllLoadAssetInfos(List<GameFramework.TaskInfo> results)
  1657. {
  1658. throw new NotImplementedException();
  1659. }
  1660. HasAssetResult IResourceManager.HasAsset(string assetName)
  1661. {
  1662. throw new NotImplementedException();
  1663. }
  1664. void IResourceManager.LoadAsset(string assetName, LoadAssetCallbacks loadAssetCallbacks)
  1665. {
  1666. throw new NotImplementedException();
  1667. }
  1668. void IResourceManager.LoadAsset(string assetName, Type assetType, LoadAssetCallbacks loadAssetCallbacks)
  1669. {
  1670. throw new NotImplementedException();
  1671. }
  1672. void IResourceManager.LoadAsset(string assetName, int priority, LoadAssetCallbacks loadAssetCallbacks)
  1673. {
  1674. throw new NotImplementedException();
  1675. }
  1676. void IResourceManager.LoadAsset(string assetName, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1677. {
  1678. throw new NotImplementedException();
  1679. }
  1680. void IResourceManager.LoadAsset(string assetName, Type assetType, int priority, LoadAssetCallbacks loadAssetCallbacks)
  1681. {
  1682. throw new NotImplementedException();
  1683. }
  1684. void IResourceManager.LoadAsset(string assetName, Type assetType, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1685. {
  1686. throw new NotImplementedException();
  1687. }
  1688. void IResourceManager.LoadAsset(string assetName, int priority, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1689. {
  1690. throw new NotImplementedException();
  1691. }
  1692. void IResourceManager.LoadAsset(string assetName, Type assetType, int priority, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1693. {
  1694. throw new NotImplementedException();
  1695. }
  1696. void IResourceManager.UnloadAsset(object asset)
  1697. {
  1698. throw new NotImplementedException();
  1699. }
  1700. void IResourceManager.LoadScene(string sceneAssetName, LoadSceneCallbacks loadSceneCallbacks)
  1701. {
  1702. throw new NotImplementedException();
  1703. }
  1704. void IResourceManager.LoadScene(string sceneAssetName, int priority, LoadSceneCallbacks loadSceneCallbacks)
  1705. {
  1706. throw new NotImplementedException();
  1707. }
  1708. void IResourceManager.LoadScene(string sceneAssetName, LoadSceneCallbacks loadSceneCallbacks, object userData)
  1709. {
  1710. throw new NotImplementedException();
  1711. }
  1712. void IResourceManager.LoadScene(string sceneAssetName, int priority, LoadSceneCallbacks loadSceneCallbacks, object userData)
  1713. {
  1714. throw new NotImplementedException();
  1715. }
  1716. void IResourceManager.UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks)
  1717. {
  1718. throw new NotImplementedException();
  1719. }
  1720. void IResourceManager.UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)
  1721. {
  1722. throw new NotImplementedException();
  1723. }
  1724. string IResourceManager.GetBinaryPath(string binaryAssetName)
  1725. {
  1726. throw new NotImplementedException();
  1727. }
  1728. bool IResourceManager.GetBinaryPath(string binaryAssetName, out bool storageInReadOnly, out bool storageInFileSystem, out string relativePath, out string fileName)
  1729. {
  1730. throw new NotImplementedException();
  1731. }
  1732. int IResourceManager.GetBinaryLength(string binaryAssetName)
  1733. {
  1734. throw new NotImplementedException();
  1735. }
  1736. void IResourceManager.LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks)
  1737. {
  1738. throw new NotImplementedException();
  1739. }
  1740. void IResourceManager.LoadBinary(string binaryAssetName, LoadBinaryCallbacks loadBinaryCallbacks, object userData)
  1741. {
  1742. throw new NotImplementedException();
  1743. }
  1744. byte[] IResourceManager.LoadBinaryFromFileSystem(string binaryAssetName)
  1745. {
  1746. throw new NotImplementedException();
  1747. }
  1748. int IResourceManager.LoadBinaryFromFileSystem(string binaryAssetName, byte[] buffer)
  1749. {
  1750. throw new NotImplementedException();
  1751. }
  1752. int IResourceManager.LoadBinaryFromFileSystem(string binaryAssetName, byte[] buffer, int startIndex)
  1753. {
  1754. throw new NotImplementedException();
  1755. }
  1756. int IResourceManager.LoadBinaryFromFileSystem(string binaryAssetName, byte[] buffer, int startIndex, int length)
  1757. {
  1758. throw new NotImplementedException();
  1759. }
  1760. byte[] IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, int length)
  1761. {
  1762. throw new NotImplementedException();
  1763. }
  1764. byte[] IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, int length)
  1765. {
  1766. throw new NotImplementedException();
  1767. }
  1768. int IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, byte[] buffer)
  1769. {
  1770. throw new NotImplementedException();
  1771. }
  1772. int IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, byte[] buffer, int length)
  1773. {
  1774. throw new NotImplementedException();
  1775. }
  1776. int IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, byte[] buffer, int startIndex, int length)
  1777. {
  1778. throw new NotImplementedException();
  1779. }
  1780. int IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, byte[] buffer)
  1781. {
  1782. throw new NotImplementedException();
  1783. }
  1784. int IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, byte[] buffer, int length)
  1785. {
  1786. throw new NotImplementedException();
  1787. }
  1788. int IResourceManager.LoadBinarySegmentFromFileSystem(string binaryAssetName, int offset, byte[] buffer, int startIndex, int length)
  1789. {
  1790. throw new NotImplementedException();
  1791. }
  1792. bool IResourceManager.HasResourceGroup(string resourceGroupName)
  1793. {
  1794. throw new NotImplementedException();
  1795. }
  1796. IResourceGroup IResourceManager.GetResourceGroup()
  1797. {
  1798. throw new NotImplementedException();
  1799. }
  1800. IResourceGroup IResourceManager.GetResourceGroup(string resourceGroupName)
  1801. {
  1802. throw new NotImplementedException();
  1803. }
  1804. IResourceGroup[] IResourceManager.GetAllResourceGroups()
  1805. {
  1806. throw new NotImplementedException();
  1807. }
  1808. void IResourceManager.GetAllResourceGroups(List<IResourceGroup> results)
  1809. {
  1810. throw new NotImplementedException();
  1811. }
  1812. IResourceGroupCollection IResourceManager.GetResourceGroupCollection(params string[] resourceGroupNames)
  1813. {
  1814. throw new NotImplementedException();
  1815. }
  1816. IResourceGroupCollection IResourceManager.GetResourceGroupCollection(List<string> resourceGroupNames)
  1817. {
  1818. throw new NotImplementedException();
  1819. }
  1820. [StructLayout(LayoutKind.Auto)]
  1821. private struct LoadAssetInfo
  1822. {
  1823. private readonly string m_AssetName;
  1824. private readonly Type m_AssetType;
  1825. private readonly int m_Priority;
  1826. private readonly DateTime m_StartTime;
  1827. private readonly float m_DelaySeconds;
  1828. private readonly LoadAssetCallbacks m_LoadAssetCallbacks;
  1829. private readonly object m_UserData;
  1830. public LoadAssetInfo(string assetName, Type assetType, int priority, DateTime startTime, float delaySeconds, LoadAssetCallbacks loadAssetCallbacks, object userData)
  1831. {
  1832. m_AssetName = assetName;
  1833. m_AssetType = assetType;
  1834. m_Priority = priority;
  1835. m_StartTime = startTime;
  1836. m_DelaySeconds = delaySeconds;
  1837. m_LoadAssetCallbacks = loadAssetCallbacks;
  1838. m_UserData = userData;
  1839. }
  1840. public string AssetName
  1841. {
  1842. get
  1843. {
  1844. return m_AssetName;
  1845. }
  1846. }
  1847. public Type AssetType
  1848. {
  1849. get
  1850. {
  1851. return m_AssetType;
  1852. }
  1853. }
  1854. public int Priority
  1855. {
  1856. get
  1857. {
  1858. return m_Priority;
  1859. }
  1860. }
  1861. public DateTime StartTime
  1862. {
  1863. get
  1864. {
  1865. return m_StartTime;
  1866. }
  1867. }
  1868. public float DelaySeconds
  1869. {
  1870. get
  1871. {
  1872. return m_DelaySeconds;
  1873. }
  1874. }
  1875. public LoadAssetCallbacks LoadAssetCallbacks
  1876. {
  1877. get
  1878. {
  1879. return m_LoadAssetCallbacks;
  1880. }
  1881. }
  1882. public object UserData
  1883. {
  1884. get
  1885. {
  1886. return m_UserData;
  1887. }
  1888. }
  1889. }
  1890. [StructLayout(LayoutKind.Auto)]
  1891. private struct LoadSceneInfo
  1892. {
  1893. private readonly AsyncOperation m_AsyncOperation;
  1894. private readonly string m_SceneAssetName;
  1895. private readonly int m_Priority;
  1896. private readonly DateTime m_StartTime;
  1897. private readonly LoadSceneCallbacks m_LoadSceneCallbacks;
  1898. private readonly object m_UserData;
  1899. public LoadSceneInfo(AsyncOperation asyncOperation, string sceneAssetName, int priority, DateTime startTime, LoadSceneCallbacks loadSceneCallbacks, object userData)
  1900. {
  1901. m_AsyncOperation = asyncOperation;
  1902. m_SceneAssetName = sceneAssetName;
  1903. m_Priority = priority;
  1904. m_StartTime = startTime;
  1905. m_LoadSceneCallbacks = loadSceneCallbacks;
  1906. m_UserData = userData;
  1907. }
  1908. public AsyncOperation AsyncOperation
  1909. {
  1910. get
  1911. {
  1912. return m_AsyncOperation;
  1913. }
  1914. }
  1915. public string SceneAssetName
  1916. {
  1917. get
  1918. {
  1919. return m_SceneAssetName;
  1920. }
  1921. }
  1922. public int Priority
  1923. {
  1924. get
  1925. {
  1926. return m_Priority;
  1927. }
  1928. }
  1929. public DateTime StartTime
  1930. {
  1931. get
  1932. {
  1933. return m_StartTime;
  1934. }
  1935. }
  1936. public LoadSceneCallbacks LoadSceneCallbacks
  1937. {
  1938. get
  1939. {
  1940. return m_LoadSceneCallbacks;
  1941. }
  1942. }
  1943. public object UserData
  1944. {
  1945. get
  1946. {
  1947. return m_UserData;
  1948. }
  1949. }
  1950. }
  1951. [StructLayout(LayoutKind.Auto)]
  1952. private struct UnloadSceneInfo
  1953. {
  1954. private readonly AsyncOperation m_AsyncOperation;
  1955. private readonly string m_SceneAssetName;
  1956. private readonly UnloadSceneCallbacks m_UnloadSceneCallbacks;
  1957. private readonly object m_UserData;
  1958. public UnloadSceneInfo(AsyncOperation asyncOperation, string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)
  1959. {
  1960. m_AsyncOperation = asyncOperation;
  1961. m_SceneAssetName = sceneAssetName;
  1962. m_UnloadSceneCallbacks = unloadSceneCallbacks;
  1963. m_UserData = userData;
  1964. }
  1965. public AsyncOperation AsyncOperation
  1966. {
  1967. get
  1968. {
  1969. return m_AsyncOperation;
  1970. }
  1971. }
  1972. public string SceneAssetName
  1973. {
  1974. get
  1975. {
  1976. return m_SceneAssetName;
  1977. }
  1978. }
  1979. public UnloadSceneCallbacks UnloadSceneCallbacks
  1980. {
  1981. get
  1982. {
  1983. return m_UnloadSceneCallbacks;
  1984. }
  1985. }
  1986. public object UserData
  1987. {
  1988. get
  1989. {
  1990. return m_UserData;
  1991. }
  1992. }
  1993. }
  1994. }
  1995. }