You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.7 KiB
63 lines
1.7 KiB
using UnityEngine.SceneManagement; |
|
|
|
namespace ET |
|
{ |
|
public class SceneChangeComponentUpdateSystem: UpdateSystem<SceneChangeComponent> |
|
{ |
|
public override void Update(SceneChangeComponent self) |
|
{ |
|
if (self.loadMapOperation == null) |
|
{ |
|
return; |
|
} |
|
|
|
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; |
|
} |
|
} |
|
|
|
[FriendClass(typeof(SceneChangeComponent))] |
|
public static class SceneChangeComponentSystem |
|
{ |
|
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 YooAssetComponent.Instance.LoadSceneAsync(sceneName.Split("_")[0]); |
|
// await self.tcs; |
|
} |
|
|
|
public static int Process(this SceneChangeComponent self) |
|
{ |
|
if (self.loadMapOperation == null) |
|
{ |
|
return 0; |
|
} |
|
return (int)(self.loadMapOperation.progress * 100); |
|
} |
|
} |
|
} |