UnitySceneModule.cs 880 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.SceneManagement;
  4. using KFADA = XGame.Framework.Asyncs;
  5. namespace XGame.Framework.Asset
  6. {
  7. public class UnitySceneModule : IUnitySceneModule
  8. {
  9. private IAssetModule _assetModule;
  10. public UnitySceneModule(IAssetModule assetModule)
  11. {
  12. _assetModule = assetModule;
  13. }
  14. public KFADA.IResultAsync<TResult> LoadSceneAsync<TResult>(string sceneName) where TResult : Component
  15. {
  16. var asyncOperation = new SceneAsyncOperation<TResult>(sceneName, _assetModule);
  17. return asyncOperation;
  18. }
  19. public void UnLoadScene(string sceneName)
  20. {
  21. _assetModule.UnLoadSceneBundle(sceneName);
  22. _assetModule.UnloadUnusedAssets();
  23. SceneManager.UnloadSceneAsync(sceneName);
  24. }
  25. }
  26. }