|
|
@@ -1,56 +0,0 @@
|
|
|
-using UnityEngine.SceneManagement;
|
|
|
-
|
|
|
-namespace ET.Client
|
|
|
-{
|
|
|
- [FriendOf(typeof(SceneChangeComponent))]
|
|
|
- public static class SceneChangeComponentSystem
|
|
|
- {
|
|
|
- public class SceneChangeComponentUpdateSystem: UpdateSystem<SceneChangeComponent>
|
|
|
- {
|
|
|
- public override void Update(SceneChangeComponent self)
|
|
|
- {
|
|
|
- if (!self.loadMapOperation.isDone)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (self.tcs == null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- ETTask tcs = self.tcs;
|
|
|
- self.tcs = null;
|
|
|
- tcs.SetResult();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public class SceneChangeComponentDestroySystem: DestroySystem<SceneChangeComponent>
|
|
|
- {
|
|
|
- public override void Destroy(SceneChangeComponent self)
|
|
|
- {
|
|
|
- self.loadMapOperation = null;
|
|
|
- self.tcs = null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static async ETTask ChangeSceneAsync(this SceneChangeComponent self, string sceneName)
|
|
|
- {
|
|
|
- self.tcs = ETTask.Create(true);
|
|
|
- // 加载map
|
|
|
- self.loadMapOperation = SceneManager.LoadSceneAsync(sceneName);
|
|
|
- //this.loadMapOperation.allowSceneActivation = false;
|
|
|
- await self.tcs;
|
|
|
- }
|
|
|
-
|
|
|
- public static int Process(this SceneChangeComponent self)
|
|
|
- {
|
|
|
- if (self.loadMapOperation == null)
|
|
|
- {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- return (int)(self.loadMapOperation.progress * 100);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|