初始化
This commit is contained in:
85
Assets/Domain/Main/HotUpdate/DomainPanel.cs
Normal file
85
Assets/Domain/Main/HotUpdate/DomainPanel.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.UIFarme;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public class DomainPanel : BasePanel, IBasePanel
|
||||
{
|
||||
public override string UIPath => "/DomainPanel";
|
||||
public override UITweenType TweenType => UITweenType.Fade;
|
||||
|
||||
private string[] domains;
|
||||
|
||||
private GameObject[] _domainGrids;
|
||||
|
||||
public override async Task InitializeAsync(GameObject panelGo)
|
||||
{
|
||||
await base.InitializeAsync(panelGo);
|
||||
domains = await ArtLoadAssetServer.GetServerDomainAllName();
|
||||
_domainGrids = new GameObject[domains.Length];
|
||||
if (domains != null)
|
||||
{
|
||||
var package = YooAssets.TryGetPackage("Main");
|
||||
var handle = package.LoadAssetAsync<GameObject>(R.Res.Main.prefabs.viewbg_prefab);
|
||||
await handle.Task;
|
||||
// float count = domains.Length / 2f;
|
||||
// float x = (-70 * count) + 35;
|
||||
var grid = this.activePanel.transform.Find("Grid");
|
||||
for (int i = 0; i < domains.Length; i++)
|
||||
{
|
||||
// x += (70 * i);
|
||||
var viewBg =
|
||||
handle.InstantiateSync();
|
||||
viewBg.transform.SetParent(grid);
|
||||
viewBg.transform.localPosition = Vector3.zero;
|
||||
viewBg.transform.localRotation = Quaternion.identity;
|
||||
viewBg.transform.localScale = Vector3.one;
|
||||
viewBg.transform.Find("Text").GetComponent<Text>().text = domains[i];
|
||||
viewBg.name = domains[i];
|
||||
_domainGrids[i] = viewBg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEnter(Action complete = null)
|
||||
{
|
||||
StringEventSystem.Global.Send("X_ButtonHierarchyType",DeviceXEventHandler.HierarchyType.Domain);
|
||||
for (int i = 0; i < _domainGrids.Length; i++)
|
||||
{
|
||||
//_domainGrids[i].gameObject.ObjectAddTouchEvent(OnTouchComplete);
|
||||
}
|
||||
|
||||
base.OnEnter(complete);
|
||||
}
|
||||
|
||||
private async void OnTouchComplete(GameObject go)
|
||||
{
|
||||
for (int i = 0; i < _domainGrids.Length; i++)
|
||||
{
|
||||
// _domainGrids[i].gameObject.ObjectPauseTouchEvent();
|
||||
}
|
||||
|
||||
HybridClREntrance.Global.domain = go.name;
|
||||
await HybridClREntrance.Global.OpenDomain();
|
||||
|
||||
await this.GetSystem<IPanelSystem>()
|
||||
.PushStack<ScenePanel>(packageName: "Main");
|
||||
this.GetSystem<IPanelSystem>().SendEvent("SetSceneData", go.name);
|
||||
}
|
||||
|
||||
public override void OnExit(float delay = 0f)
|
||||
{
|
||||
for (int i = 0; i < _domainGrids.Length; i++)
|
||||
{
|
||||
//_domainGrids[i].gameObject.ObjectRemoveTouchEvent();
|
||||
}
|
||||
|
||||
base.OnExit(delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Domain/Main/HotUpdate/DomainPanel.cs.meta
Normal file
3
Assets/Domain/Main/HotUpdate/DomainPanel.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01931f9a55ce49a3964c3d35382b7ec0
|
||||
timeCreated: 1761728522
|
||||
22
Assets/Domain/Main/HotUpdate/HotUpdate_Main.asmdef
Normal file
22
Assets/Domain/Main/HotUpdate/HotUpdate_Main.asmdef
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "HotUpdate_Main",
|
||||
"rootNamespace": "HotUpdate_Main",
|
||||
"references": [
|
||||
"GUID:d1a793c2b6959e04ea45b972eaa369c8",
|
||||
"GUID:f3fa071c399c4383a9ff8115e53dfefc",
|
||||
"GUID:10c9b58b77ad42b4193e2a393b1a9899",
|
||||
"GUID:fad681b9bfe621d4fa07f4f69c311443",
|
||||
"GUID:8c6fa7c2cd7bf784e856d9adb3dc2ada",
|
||||
"GUID:a3794f8c932de3d47b12dc5eac703d09",
|
||||
"GUID:e34a5702dd353724aa315fb8011f08c3"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": true,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Domain/Main/HotUpdate/HotUpdate_Main.asmdef.meta
Normal file
7
Assets/Domain/Main/HotUpdate/HotUpdate_Main.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0215eccc3fbaadc478df17450740779c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
62
Assets/Domain/Main/HotUpdate/MainDomain.cs
Normal file
62
Assets/Domain/Main/HotUpdate/MainDomain.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.UIFarme;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
[Preserve]
|
||||
public class MainDomain : DomainBase, IController
|
||||
{
|
||||
public override void OnEnter(string param)
|
||||
{
|
||||
base.OnEnter(param);
|
||||
Debug.Log("UnityEvo: OnEnter进入成功");
|
||||
Camera.main.GetOrAddComponent<DeviceXEventHandler>();
|
||||
}
|
||||
|
||||
public override void OnExit()
|
||||
{
|
||||
base.OnExit();
|
||||
GetArchitecture().OnDispose();
|
||||
Debug.Log("UnityEvo: OnExit退出成功");
|
||||
}
|
||||
|
||||
public override async Task OnEnterAsync(string param)
|
||||
{
|
||||
await base.OnEnterAsync(param);
|
||||
Debug.Log("UnityEvo: OnEnterAsync进入成功");
|
||||
await this.GetSystem<IPanelSystem>().PushStack<DomainPanel>();
|
||||
StringEventSystem.Global.Register("Rollback", OnRollback);
|
||||
}
|
||||
|
||||
private void OnRollback()
|
||||
{
|
||||
this.GetSystem<IPanelSystem>().PopStack();
|
||||
HybridClREntrance.Global.CloseDomain();
|
||||
}
|
||||
|
||||
public override Task OnExitAsync()
|
||||
{
|
||||
Debug.Log("UnityEvo: OnEnterAsync退出成功");
|
||||
return base.OnExitAsync();
|
||||
}
|
||||
|
||||
public IArchitecture GetArchitecture()
|
||||
{
|
||||
return MainArchitecture.Interface;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MainArchitecture : Architecture<MainArchitecture>
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
//注册示例
|
||||
//RegisterSystem<IScoreSystem>(new ScoreSystem());
|
||||
RegisterSystem<IPanelSystem>(new PanelSystem(new YooAssetLoader()));
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Domain/Main/HotUpdate/MainDomain.cs.meta
Normal file
11
Assets/Domain/Main/HotUpdate/MainDomain.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5af776699c2b748418e595475046d0b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/Domain/Main/HotUpdate/Res.cs
Normal file
65
Assets/Domain/Main/HotUpdate/Res.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace R
|
||||
{
|
||||
public class Res
|
||||
{
|
||||
public class Main
|
||||
{
|
||||
public static class audios
|
||||
{
|
||||
}
|
||||
public static class config
|
||||
{
|
||||
public const string domainconfig_asset = "Config_DomainConfig";
|
||||
}
|
||||
public static class dll
|
||||
{
|
||||
public static class android
|
||||
{
|
||||
public const string com_stary_evo_runtime_dll_bytes = "Android_com.stary.evo.runtime.dll";
|
||||
public const string com_staryevo_tools_runtime_dll_bytes = "Android_com.staryevo.tools.runtime.dll";
|
||||
public const string dotween_dll_bytes = "Android_DOTween.dll";
|
||||
public const string hotupdate_main_dll_bytes = "Android_HotUpdate_Main.dll";
|
||||
public const string hotupdate_main_pdb_bytes = "Android_HotUpdate_Main.pdb";
|
||||
public const string mscorlib_dll_bytes = "Android_mscorlib.dll";
|
||||
public const string system_core_dll_bytes = "Android_System.Core.dll";
|
||||
public const string unitask_dll_bytes = "Android_UniTask.dll";
|
||||
public const string unityengine_coremodule_dll_bytes = "Android_UnityEngine.CoreModule.dll";
|
||||
public const string yooasset_dll_bytes = "Android_YooAsset.dll";
|
||||
}
|
||||
public static class webgl
|
||||
{
|
||||
public const string com_stary_evo_runtime_dll_bytes = "WebGL_com.stary.evo.runtime.dll";
|
||||
public const string com_staryevo_tools_runtime_dll_bytes = "WebGL_com.staryevo.tools.runtime.dll";
|
||||
public const string dotween_dll_bytes = "WebGL_DOTween.dll";
|
||||
public const string hotupdate_main_dll_bytes = "WebGL_HotUpdate_Main.dll";
|
||||
public const string hotupdate_main_pdb_bytes = "WebGL_HotUpdate_Main.pdb";
|
||||
public const string mscorlib_dll_bytes = "WebGL_mscorlib.dll";
|
||||
public const string system_core_dll_bytes = "WebGL_System.Core.dll";
|
||||
public const string unitask_dll_bytes = "WebGL_UniTask.dll";
|
||||
public const string unityengine_coremodule_dll_bytes = "WebGL_UnityEngine.CoreModule.dll";
|
||||
public const string yooasset_dll_bytes = "WebGL_YooAsset.dll";
|
||||
}
|
||||
}
|
||||
public static class prefabs
|
||||
{
|
||||
public const string domainpanel_prefab = "Prefabs_DomainPanel";
|
||||
public const string main_prefab = "Prefabs_Main";
|
||||
public const string scenepanel_prefab = "Prefabs_ScenePanel";
|
||||
public const string viewbg_prefab = "Prefabs_viewBg";
|
||||
}
|
||||
public static class scenes
|
||||
{
|
||||
}
|
||||
public static class spriteatlas
|
||||
{
|
||||
}
|
||||
public static class sprites
|
||||
{
|
||||
public const string bg_png = "Sprites_bg";
|
||||
}
|
||||
public static class video
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Domain/Main/HotUpdate/Res.cs.meta
Normal file
11
Assets/Domain/Main/HotUpdate/Res.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f05c2234bec229429d34025fa806c35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
145
Assets/Domain/Main/HotUpdate/ScenePanel.cs
Normal file
145
Assets/Domain/Main/HotUpdate/ScenePanel.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.UIFarme;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public class ScenePanel : BasePanel, IBasePanel
|
||||
{
|
||||
public override string UIPath => "/ScenePanel";
|
||||
public override UITweenType TweenType => UITweenType.Fade;
|
||||
|
||||
private ArtScene[] _scenesNames;
|
||||
private GameObject[] _sceneGrids;
|
||||
|
||||
private string _currentSceneName;
|
||||
|
||||
public override async Task InitializeAsync(GameObject panelGo)
|
||||
{
|
||||
await base.InitializeAsync(panelGo);
|
||||
}
|
||||
|
||||
public override void OnEnter(Action complete = null)
|
||||
{
|
||||
base.OnEnter(complete);
|
||||
StringEventSystem.Global.Send("X_ButtonHierarchyType",DeviceXEventHandler.HierarchyType.ScenePanel);
|
||||
this.RegisterEvent<string, string>("SetSceneData", SetSceneData);
|
||||
}
|
||||
|
||||
private async void SetSceneData(string name)
|
||||
{
|
||||
var handle = YooAssets.LoadAssetAsync<ArtSceneData>("Config_ArtSceneData");
|
||||
await handle.Task;
|
||||
var artSceneData = handle.GetAssetObject<ArtSceneData>();
|
||||
if (artSceneData == null)
|
||||
{
|
||||
Debug.LogError($"在domain:{name} ArtSceneData 资源不存在,请检查!");
|
||||
return;
|
||||
}
|
||||
|
||||
_scenesNames = artSceneData.artScenes.ToArray();
|
||||
_sceneGrids = new GameObject[_scenesNames.Length];
|
||||
SetSceneGrids();
|
||||
}
|
||||
|
||||
private async void SetSceneGrids()
|
||||
{
|
||||
if (_scenesNames != null && _scenesNames.Length > 0)
|
||||
{
|
||||
var package = YooAssets.TryGetPackage("Main");
|
||||
var handle = package.LoadAssetAsync<GameObject>(R.Res.Main.prefabs.viewbg_prefab);
|
||||
await handle.Task;
|
||||
var grid = this.activePanel.transform.Find("Grid");
|
||||
// float count = _scenesNames.Length / 2f;
|
||||
// float x = (-70 * count) + 35;
|
||||
for (int i = 0; i < _scenesNames.Length; i++)
|
||||
{
|
||||
//x += (70 * i);
|
||||
var viewBg =
|
||||
handle.InstantiateSync();
|
||||
viewBg.transform.SetParent(grid);
|
||||
viewBg.transform.localPosition = Vector3.zero;
|
||||
viewBg.transform.localRotation = Quaternion.identity;
|
||||
viewBg.transform.localScale = Vector3.one;
|
||||
viewBg.transform.Find("Text").GetComponent<Text>().text = _scenesNames[i].sceneName;
|
||||
viewBg.name = _scenesNames[i].sceneName;
|
||||
_sceneGrids[i] = viewBg;
|
||||
//viewBg.gameObject.ObjectAddTouchEvent(OnTouchComplete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnTouchComplete(GameObject obj)
|
||||
{
|
||||
for (int i = 0; i < _sceneGrids.Length; i++)
|
||||
{
|
||||
//_sceneGrids[i].gameObject.ObjectPauseTouchEvent();
|
||||
}
|
||||
|
||||
ArtScene artScene = null;
|
||||
for (int i = 0; i < _scenesNames.Length; i++)
|
||||
{
|
||||
if (_scenesNames[i].sceneName == obj.name)
|
||||
{
|
||||
artScene = _scenesNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
var sceneMode = LoadSceneMode.Additive;
|
||||
var physicsMode = LocalPhysicsMode.None;
|
||||
SceneHandle handle = YooAssets.LoadSceneAsync(artScene.sceneIdentifier, sceneMode, physicsMode);
|
||||
await handle.Task;
|
||||
Scene targetScene = SceneManager.GetSceneByName(handle.SceneName);
|
||||
// 设置为 active scene 或者后续 Move 到该 scene
|
||||
SceneManager.SetActiveScene(targetScene);
|
||||
GameObject.Destroy(GameObject.Find("RKCameraRigTest"));
|
||||
_currentSceneName = targetScene.name;
|
||||
//注册卸载当前场景事件
|
||||
StringEventSystem.Global.Register("UnloadCurrentScene", UnloadCurrentScene);
|
||||
StringEventSystem.Global.Send("X_ButtonHierarchyType",DeviceXEventHandler.HierarchyType.SceneActive);
|
||||
|
||||
// 场景加载完成后,Fade 出当前场景
|
||||
this.canvasGroup.DOFade(0, 1f).OnComplete(() =>
|
||||
{
|
||||
this.canvasGroup.alpha = 0;
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnExit(float delay = 0f)
|
||||
{
|
||||
base.OnExit(delay);
|
||||
this.UnRegisterEvent<string, string>("SetSceneData", SetSceneData);
|
||||
for (int i = 0; i < _sceneGrids.Length; i++)
|
||||
{
|
||||
//_sceneGrids[i].gameObject.ObjectRemoveTouchEvent();
|
||||
GameObject.Destroy(_sceneGrids[i].gameObject);
|
||||
}
|
||||
|
||||
_sceneGrids = null;
|
||||
}
|
||||
|
||||
private void UnloadCurrentScene()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_currentSceneName))
|
||||
{
|
||||
SceneManager.UnloadSceneAsync(_currentSceneName);
|
||||
this.canvasGroup.DOFade(1, 1f).OnComplete(() =>
|
||||
{
|
||||
this.canvasGroup.alpha = 1;
|
||||
for (int i = 0; i < _sceneGrids.Length; i++)
|
||||
{
|
||||
//_sceneGrids[i].gameObject.ObjectResumeTouchEvent();
|
||||
}
|
||||
});
|
||||
StringEventSystem.Global.Send("X_ButtonHierarchyType",DeviceXEventHandler.HierarchyType.ScenePanel);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Domain/Main/HotUpdate/ScenePanel.cs.meta
Normal file
3
Assets/Domain/Main/HotUpdate/ScenePanel.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 073c71c4fbe64e9db9458c80e4fa57ce
|
||||
timeCreated: 1761793277
|
||||
1
Assets/Domain/Main/HotUpdate/这里放所有参与热更的脚本文件.hint
Normal file
1
Assets/Domain/Main/HotUpdate/这里放所有参与热更的脚本文件.hint
Normal file
@@ -0,0 +1 @@
|
||||
该文件夹中的程序集定义文件,请勿删除,非常重要。
|
||||
7
Assets/Domain/Main/HotUpdate/这里放所有参与热更的脚本文件.hint.meta
Normal file
7
Assets/Domain/Main/HotUpdate/这里放所有参与热更的脚本文件.hint.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb66ef0ef7d474b48b429631484e9e31
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user