CSharpSceneInfosManifest.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. namespace XGame.Framework.Asset
  4. {
  5. public class CSharpSceneInfosManifest : ISceneInfosManifest, IDisposable
  6. {
  7. /// <summary>
  8. /// <sceneName, assetName>
  9. /// </summary>
  10. private Dictionary<string, string> _sceneInfoMap;
  11. public CSharpSceneInfosManifest(SceneInfosSo manifest)
  12. {
  13. _sceneInfoMap = new Dictionary<string, string>();
  14. Init(manifest);
  15. }
  16. private void Init(SceneInfosSo manifest)
  17. {
  18. if (manifest == null || manifest.sceneInfos == null)
  19. return;
  20. foreach (var info in manifest.sceneInfos)
  21. {
  22. _sceneInfoMap.Add(info.sceneName, info.assetName);
  23. }
  24. }
  25. public string GetSceneAssetName(string sceneName)
  26. {
  27. _sceneInfoMap.TryGetValue(sceneName, out var assetName);
  28. return assetName;
  29. }
  30. void IDisposable.Dispose()
  31. {
  32. _sceneInfoMap.Clear();
  33. }
  34. }
  35. }