111
This commit is contained in:
@@ -16,7 +16,8 @@ namespace Stary.Evo
|
||||
{
|
||||
private DomainConfig.LoadResType loadResType;
|
||||
public GameObject mainPrefab;
|
||||
private DomainConfig domainConfig;
|
||||
private DomainConfig domainConfig;
|
||||
|
||||
public LoadResState(IFsmSystemAsync system) : base(system)
|
||||
{
|
||||
}
|
||||
@@ -39,42 +40,33 @@ namespace Stary.Evo
|
||||
loadResType = domainConfig.loadResType;
|
||||
Type type = param2 as Type;
|
||||
var package = YooAssets.GetPackage(domainConfig.domain);
|
||||
if (loadResType == DomainConfig.LoadResType.Prefab)
|
||||
switch (loadResType)
|
||||
{
|
||||
// 加载热更资源
|
||||
var loadOperation = package.LoadAssetAsync<GameObject>(domainConfig.mainPrefab);
|
||||
case DomainConfig.LoadResType.Prefab:
|
||||
|
||||
await loadOperation;
|
||||
if (loadOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
LoadDomainPrefab(package);
|
||||
|
||||
#if Immersal
|
||||
ARSpace arSpace = GameObject.FindObjectOfType<ARSpace>();
|
||||
if (arSpace != null)
|
||||
break;
|
||||
case DomainConfig.LoadResType.Scene:
|
||||
|
||||
var sceneMode = domainConfig.loadSceneMode;
|
||||
var physicsMode = LocalPhysicsMode.None;
|
||||
SceneHandle handle = package.LoadSceneAsync(domainConfig.mainScene, sceneMode, physicsMode);
|
||||
await handle;
|
||||
Scene targetScene = SceneManager.GetSceneByName(domainConfig.mainScene);
|
||||
targetScene.name = domainConfig.mainScene;
|
||||
// 设置为 active scene 或者后续 Move 到该 scene
|
||||
SceneManager.SetActiveScene(targetScene);
|
||||
|
||||
mainPrefab = GameObject.Find(domainConfig.mainPrefab);
|
||||
if (mainPrefab == null)
|
||||
{
|
||||
Debug.Log("UnityEvo:找到ARSpace,开始加载点云运行环境...");
|
||||
mainPrefab = loadOperation.InstantiateSync(arSpace.transform);
|
||||
} else
|
||||
{
|
||||
Debug.Log("UnityEvo:未找到ARSpace,开始加载普通运行环境,通过语音唤醒...");
|
||||
mainPrefab = loadOperation.InstantiateSync();
|
||||
LoadDomainPrefab(package);
|
||||
}
|
||||
#elif NotPointClond
|
||||
mainPrefab = loadOperation.InstantiateSync();
|
||||
#endif
|
||||
if(domainConfig.domain =="Main")
|
||||
AppConfig.SetDefaultMainInstance(mainPrefab);
|
||||
}
|
||||
}
|
||||
else if (loadResType == DomainConfig.LoadResType.Scene)
|
||||
{
|
||||
var sceneMode = domainConfig.loadSceneMode;
|
||||
var physicsMode = LocalPhysicsMode.None;
|
||||
SceneHandle handle = package.LoadSceneAsync(domainConfig.mainScene, sceneMode, physicsMode);
|
||||
await handle;
|
||||
mainPrefab = GameObject.Find(domainConfig.mainPrefab);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
LocalTransformInfo info = mainPrefab.GetOrAddComponent<LocalTransformInfo>();
|
||||
FsmLoadSystem fsmLoadSystem = FsmSystem as FsmLoadSystem;
|
||||
|
||||
@@ -93,10 +85,11 @@ namespace Stary.Evo
|
||||
info.transform.position = fsmLoadSystem.GetTransformCtor().position;
|
||||
info.transform.rotation = Quaternion.Euler(fsmLoadSystem.GetTransformCtor().rotation);
|
||||
info.transform.localScale = fsmLoadSystem.GetTransformCtor().scale;
|
||||
}else{
|
||||
info.Switch(0);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
info.Switch(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -130,6 +123,32 @@ namespace Stary.Evo
|
||||
base.OnUpdate();
|
||||
}
|
||||
|
||||
private async void LoadDomainPrefab(ResourcePackage package)
|
||||
{
|
||||
// 加载热更资源
|
||||
var loadOperation = package.LoadAssetAsync<GameObject>(domainConfig.mainPrefab);
|
||||
|
||||
await loadOperation;
|
||||
if (loadOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
#if Immersal
|
||||
ARSpace arSpace = GameObject.FindObjectOfType<ARSpace>();
|
||||
if (arSpace != null)
|
||||
{
|
||||
Debug.Log("UnityEvo:找到ARSpace,开始加载点云运行环境...");
|
||||
mainPrefab = loadOperation.InstantiateSync(arSpace.transform);
|
||||
} else
|
||||
{
|
||||
Debug.Log("UnityEvo:未找到ARSpace,开始加载普通运行环境,通过语音唤醒...");
|
||||
mainPrefab = loadOperation.InstantiateSync();
|
||||
}
|
||||
#elif NotPointClond
|
||||
mainPrefab = loadOperation.InstantiateSync();
|
||||
#endif
|
||||
if (domainConfig.domain == "Main")
|
||||
AppConfig.SetDefaultMainInstance(mainPrefab);
|
||||
}
|
||||
}
|
||||
|
||||
public override async UniTask OnExitAsync()
|
||||
{
|
||||
@@ -149,7 +168,7 @@ namespace Stary.Evo
|
||||
|
||||
if (loadResType == DomainConfig.LoadResType.Scene)
|
||||
{
|
||||
await SceneManager.UnloadSceneAsync("server");
|
||||
await SceneManager.UnloadSceneAsync(domainConfig.mainScene);
|
||||
}
|
||||
|
||||
if (domainBase != null)
|
||||
@@ -158,7 +177,6 @@ namespace Stary.Evo
|
||||
|
||||
await ForceUnloadAllAssets(domainBase.DomainName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,17 +58,12 @@ namespace Stary.Evo
|
||||
// 初始化资源包
|
||||
#if EDITOR_SIMULATEMODE
|
||||
await EDITOR_SIMULATEMODE(package);
|
||||
FsmSystem.SetCurState(nameof(ResUpdateServerState));
|
||||
FsmSystem.SetCurState(nameof(ResUpdateServerState));
|
||||
#elif OFFLINE_PLAYMODE
|
||||
await OFFLINE_PLAYMODE(package);
|
||||
FsmSystem.SetCurState(nameof(ResUpdateLocalState));
|
||||
#elif HOST_PLAYMODE
|
||||
// if (package.PackageName.Equals("Main"))
|
||||
// {
|
||||
// await OFFLINE_PLAYMODE(package);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
//登录
|
||||
string url = AppConfig.IpConfig + "/Authentication/login";
|
||||
bool isLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
|
||||
@@ -76,7 +71,7 @@ namespace Stary.Evo
|
||||
await HOST_PLAYMODE(package);
|
||||
else
|
||||
await Chche_PLAYMODE(package);
|
||||
// }
|
||||
|
||||
|
||||
FsmSystem.SetCurState(nameof(ResUpdateLocalState));
|
||||
|
||||
@@ -125,6 +120,7 @@ namespace Stary.Evo
|
||||
|
||||
private async UniTask EDITOR_SIMULATEMODE(ResourcePackage package)
|
||||
{
|
||||
|
||||
var initParams=YooAssetFileSystem.EditorSimulateInitializeParameter(package.PackageName);
|
||||
var initialization = package.InitializeAsync(initParams);
|
||||
await initialization;
|
||||
|
||||
Reference in New Issue
Block a user