Compare commits
1 Commits
master
...
d2ea34aa38
| Author | SHA1 | Date | |
|---|---|---|---|
| d2ea34aa38 |
@@ -26,22 +26,30 @@ namespace Stary.Evo
|
||||
/// </summary>
|
||||
[Sirenix.OdinInspector.ReadOnly] public string className;
|
||||
|
||||
[InfoBox( "Prefab(仅加载预制体) Scene(加载场景)")]
|
||||
[OnValueChanged("SetLoadResType")]
|
||||
public LoadResType loadResType;
|
||||
|
||||
|
||||
[Sirenix.OdinInspector.ReadOnly] [ShowIf("loadResType", LoadResType.Prefab)]
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[ShowIf("loadResType", LoadResType.Scene)] [OnValueChanged("LoadScenePath")]
|
||||
[ValidateInput("ValidateScenePath", "只能使用 本Domain 目录下的场景!", InfoMessageType.Error)]
|
||||
public SceneAsset sceneAsset;
|
||||
#endif
|
||||
[InfoBox( "Static(持久化存在,不可手动卸载) Additive(叠加,可手动卸载) Single(下一个加载自动卸载) ")]
|
||||
[ShowIf("loadResType", LoadResType.Prefab)]
|
||||
public DomainLoadType domainLoadType;
|
||||
|
||||
[ShowIf("loadResType", LoadResType.Scene)]
|
||||
public LoadSceneMode loadSceneMode;
|
||||
/// <summary>
|
||||
/// 入口预制体
|
||||
/// </summary>
|
||||
[Sirenix.OdinInspector.ReadOnly] [ShowIf("loadResType", LoadResType.Prefab)]
|
||||
public string mainPrefab;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[ShowIf("loadResType", LoadResType.Scene)] [OnValueChanged("LoadScenePath")]
|
||||
public SceneAsset sceneAsset;
|
||||
#endif
|
||||
[ShowIf("loadResType", LoadResType.Scene)]
|
||||
public LoadSceneMode loadSceneMode;
|
||||
|
||||
[ShowIf("loadResType", LoadResType.Scene)] [ReadOnly]
|
||||
public string scenePath;
|
||||
|
||||
@@ -61,11 +69,43 @@ namespace Stary.Evo
|
||||
scenePath = AssetDatabase.GetAssetPath(sceneAsset);
|
||||
sceneIdentifier = $"Scenes_{sceneAsset.name}";
|
||||
}
|
||||
private bool ValidateScenePath(SceneAsset scene)
|
||||
{
|
||||
if (scene == null) return true;
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(scene);
|
||||
return path.StartsWith($"Assets/Domain/{domain}/AddressableRes/Scenes/");
|
||||
}
|
||||
#endif
|
||||
private void SetLoadResType()
|
||||
{
|
||||
if (loadResType == LoadResType.Prefab)
|
||||
{
|
||||
sceneAsset = null;
|
||||
scenePath = null;
|
||||
sceneIdentifier = null;
|
||||
}
|
||||
}
|
||||
public enum LoadResType
|
||||
{
|
||||
Prefab,
|
||||
Scene
|
||||
}
|
||||
|
||||
public enum DomainLoadType
|
||||
{
|
||||
/// <summary>
|
||||
/// 下一个加载自动卸载
|
||||
/// </summary>
|
||||
Single,
|
||||
/// <summary>
|
||||
/// 叠加,可手动卸载
|
||||
/// </summary>
|
||||
Additive,
|
||||
/// <summary>
|
||||
/// 持久化存在,不可手动卸载
|
||||
/// </summary>
|
||||
Static
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 194887e39d37cd742a57ffe4cfe1b21b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.main",
|
||||
"version": "2.1.5",
|
||||
"version": "2.1.6",
|
||||
"displayName": "00.StaryEvo",
|
||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||
"unity": "2021.3",
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ChangePointClondMode
|
||||
{
|
||||
public static PointClondMode PointClondMode
|
||||
{
|
||||
get => _pointClondMode;
|
||||
set => SetPoindClondMode(value);
|
||||
}
|
||||
|
||||
private static PointClondMode _pointClondMode;
|
||||
|
||||
private const string EditorNotMode = "Evo/Schema/ChangePointClond/NotPointClond";
|
||||
private const string EditorImmersalMode = "Evo/Schema/ChangePointClond/Immersal";
|
||||
|
||||
[MenuItem(EditorNotMode)]
|
||||
private static void SetNotMode() => SetPoindClondMode(PointClondMode.NotPointClond);
|
||||
|
||||
[MenuItem(EditorImmersalMode)]
|
||||
private static void SetImmersalMode() => SetPoindClondMode(PointClondMode.Immersal);
|
||||
|
||||
// [MenuItem(WebPlayMode)]
|
||||
// private static void SetWebMode() => SetPlayerMode(HotUpdateMode.WEB_PLAYMODE);
|
||||
|
||||
[MenuItem(EditorNotMode, true)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = CustomEditorPrefs.GetString("ChangePoindClondSchema");
|
||||
Menu.SetChecked(EditorNotMode, platform == PointClondMode.NotPointClond.ToString());
|
||||
Menu.SetChecked(EditorImmersalMode, platform == PointClondMode.Immersal.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
|
||||
Debug.Log($"ChangePoindClondSchema:{platform}");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void SetPoindClondMode(PointClondMode mode)
|
||||
{
|
||||
// 清除所有旧模式定义
|
||||
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
if (currentTarget == BuildTargetGroup.Unknown) return;
|
||||
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget)
|
||||
.Split(';')
|
||||
.Where(d => !Enum.GetNames(typeof(HotUpdateMode)).Contains(d))
|
||||
.ToList();
|
||||
|
||||
// 添加新模式
|
||||
defines.Add(mode.ToString());
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
_pointClondMode = mode;
|
||||
CustomEditorPrefs.SetString("ChangePoindClondSchema", _pointClondMode.ToString());
|
||||
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
// 添加解决方案文件重新生成逻辑
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum PointClondMode
|
||||
{
|
||||
//非点云模式,
|
||||
NotPointClond,
|
||||
//Immersal模式
|
||||
Immersal,
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 076111eb4cfd413287c1d7f299fe5a1f
|
||||
timeCreated: 1757471872
|
||||
@@ -13,6 +13,7 @@ namespace Stary.Evo
|
||||
public static string PackageDomainName { get; set; }
|
||||
|
||||
|
||||
public static bool IsLogin { get; set; }
|
||||
public static string IpConfig { get; set; }
|
||||
public static string UserName { get; set; }
|
||||
public static string PassWord { get; set; }
|
||||
@@ -21,37 +22,13 @@ namespace Stary.Evo
|
||||
|
||||
public static string MainDomainVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主场景main实例物体
|
||||
/// </summary>
|
||||
private static GameObject _MainBaseModel;
|
||||
|
||||
|
||||
|
||||
public static bool DeveloperMode
|
||||
{
|
||||
get { return HybridClREntrance.Global.stage == StageType.Developer || PackageDomainName == "Main"; }
|
||||
}
|
||||
|
||||
public static bool MainPackageMode
|
||||
{
|
||||
get { return PackageDomainName == "Main"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 赋值默认的实例
|
||||
/// </summary>
|
||||
public static void SetDefaultMainInstance(GameObject mainbase)
|
||||
{
|
||||
_MainBaseModel = mainbase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 赋值默认的实例
|
||||
/// </summary>
|
||||
public static GameObject GetDefaultMainInstance()
|
||||
{
|
||||
return _MainBaseModel;
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalConfig
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class AnimClipData
|
||||
{
|
||||
public string AnimName;
|
||||
public AnimationClip AnimClip;
|
||||
public AnimMode AnimMode;
|
||||
}
|
||||
|
||||
public enum AnimMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 入场1
|
||||
/// </summary>
|
||||
Entrance1,
|
||||
|
||||
/// <summary>
|
||||
/// 入场2
|
||||
/// </summary>
|
||||
Entrance2,
|
||||
|
||||
/// <summary>
|
||||
/// 退出1
|
||||
/// </summary>
|
||||
Exit1,
|
||||
|
||||
/// <summary>
|
||||
/// 退出2
|
||||
/// </summary>
|
||||
Exit2,
|
||||
|
||||
/// <summary>
|
||||
/// 空闲
|
||||
/// </summary>
|
||||
Idle,
|
||||
|
||||
/// <summary>
|
||||
/// 飞行
|
||||
/// </summary>
|
||||
Flying,
|
||||
|
||||
/// <summary>
|
||||
/// 引导
|
||||
/// </summary>
|
||||
Guide,
|
||||
|
||||
/// <summary>
|
||||
/// 反馈
|
||||
/// </summary>
|
||||
Feedback,
|
||||
|
||||
/// <summary>
|
||||
/// 对话空闲
|
||||
/// </summary>
|
||||
TalkIdle,
|
||||
|
||||
/// <summary>
|
||||
/// 对话
|
||||
/// </summary>
|
||||
Talking,
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46ff0818b37d41c4beea00d1081610f7
|
||||
timeCreated: 1767948662
|
||||
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Main;
|
||||
using Stary.Evo.InformationSave;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using YooAsset;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class DomainAssetSystem : IDisposable
|
||||
{
|
||||
private static OpenDomainType _openDomainType { get; set; }
|
||||
private static TransformCtor _transformCtor { get; set; }
|
||||
public static ProgressBarPanel ProgressBarPanel { get; set; }
|
||||
|
||||
|
||||
private static readonly List<DomainConfig> _domainStaticNameEntities = new List<DomainConfig>();
|
||||
private static List<DomainConfig> _domainNameEntities = new List<DomainConfig>();
|
||||
|
||||
public static void LoadDoaminAsset()
|
||||
{
|
||||
}
|
||||
|
||||
public static void AddDomainNameEntity(DomainConfig domainName)
|
||||
{
|
||||
_domainNameEntities.Add(domainName);
|
||||
}
|
||||
|
||||
public static void AddDomainStaticNameEntity(DomainConfig domainName)
|
||||
{
|
||||
_domainStaticNameEntities.Add(domainName);
|
||||
}
|
||||
|
||||
public static void DeleteDomainNameEntity(DomainConfig domainName)
|
||||
{
|
||||
_domainNameEntities.Remove(domainName);
|
||||
}
|
||||
|
||||
public static void DeleteDomainStaticNameEntity(DomainConfig domainName)
|
||||
{
|
||||
_domainStaticNameEntities.Remove(domainName);
|
||||
}
|
||||
|
||||
public static async UniTask<GameObject> LoadDomainPrefab(DomainConfig domainConfig)
|
||||
{
|
||||
var package = YooAssets.GetPackage(domainConfig.domain);
|
||||
// 加载热更资源
|
||||
var loadOperation = package.LoadAssetAsync<GameObject>(domainConfig.mainPrefab);
|
||||
|
||||
await loadOperation;
|
||||
if (loadOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
var gameObject = loadOperation.InstantiateSync();
|
||||
gameObject.name = domainConfig.domain;
|
||||
return gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogErrorFormat("加载热更资源失败,资源路径为--【{0}】--", loadOperation.LastError);
|
||||
throw new System.Exception(loadOperation.LastError);
|
||||
}
|
||||
}
|
||||
|
||||
public static async UniTask SetTransformInfo(GameObject gameObject)
|
||||
{
|
||||
LocalTransformInfo info = gameObject.GetOrAddComponent<LocalTransformInfo>();
|
||||
|
||||
if (info._list.Count >= 2)
|
||||
{
|
||||
if (_openDomainType == OpenDomainType.PointCloud)
|
||||
{
|
||||
info.Switch(1);
|
||||
}
|
||||
else if (_openDomainType == OpenDomainType.VIOICE)
|
||||
{
|
||||
info.Switch(0);
|
||||
}
|
||||
else if (_openDomainType == OpenDomainType.ImageTracked)
|
||||
{
|
||||
info.transform.position = _transformCtor.position;
|
||||
info.transform.rotation = Quaternion.Euler(_transformCtor.rotation);
|
||||
info.transform.localScale = _transformCtor.scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.Switch(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{gameObject.name}的TransformInfo长度小于2,无法继续运行,请排查");
|
||||
}
|
||||
}
|
||||
|
||||
public static async UniTask BindableProperty(DomainConfig domainConfig, GameObject gameObject, Type type)
|
||||
{
|
||||
DomainBase hotfixInstance = gameObject.GetComponent(type) as DomainBase;
|
||||
if (hotfixInstance == null)
|
||||
{
|
||||
hotfixInstance = gameObject.AddComponent(type) as DomainBase;
|
||||
}
|
||||
|
||||
if (hotfixInstance == null)
|
||||
{
|
||||
Debug.LogError($"热更类{type.Name}实例创建失败!必须继承MonoBehaviour");
|
||||
return;
|
||||
}
|
||||
|
||||
hotfixInstance.DomainName = domainConfig.domain;
|
||||
hotfixInstance.DomainNameRaw = $"{domainConfig.domain}_RawFile";
|
||||
|
||||
|
||||
// 原有调用逻辑修改为使用实例
|
||||
hotfixInstance.OnEnter("");
|
||||
hotfixInstance.OnEnterAsync("");
|
||||
}
|
||||
|
||||
public static async UniTask UnloadDomainAsset()
|
||||
{
|
||||
foreach (var entity in _domainNameEntities)
|
||||
{
|
||||
if (HybridClREntrance.Global.stage == StageType.Developer)
|
||||
{
|
||||
var mainPrefab = GameObject.Find(entity.domain);
|
||||
if (mainPrefab == null)
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{entity.domain}不存在,无法卸载");
|
||||
return;
|
||||
}
|
||||
|
||||
DomainBase domainBase = mainPrefab.GetOrAddComponent<DomainBase>();
|
||||
if (domainBase == null)
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{mainPrefab.name}的DomainBase为空,无法退出,请排查");
|
||||
}
|
||||
else
|
||||
{
|
||||
domainBase.OnExit();
|
||||
await domainBase.OnExitAsync();
|
||||
|
||||
GameObject.Destroy(domainBase.gameObject);
|
||||
|
||||
await ForceUnloadAllAssets(domainBase.DomainName);
|
||||
await ForceUnloadAllAssets(domainBase.DomainNameRaw);
|
||||
}
|
||||
|
||||
Debug.Log($"UnityEvo:{entity.domain} 退出成功...");
|
||||
}
|
||||
else if (HybridClREntrance.Global.stage == StageType.Originality)
|
||||
{
|
||||
await ForceUnloadAllAssets(entity.domain);
|
||||
AppConfig.PackageDomainName = "";
|
||||
Debug.Log("UnityEvo:Domain退出...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async UniTask UnloadSceneAsset(DomainConfig config)
|
||||
{
|
||||
if (config.loadResType == DomainConfig.LoadResType.Scene)
|
||||
{
|
||||
string sceneName = config.sceneIdentifier;
|
||||
if (sceneName == "")
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{config.domain} 未配置场景名称,无法卸载");
|
||||
return;
|
||||
}
|
||||
|
||||
// 匹配开头到下划线的所有内容,替换为空
|
||||
sceneName = Regex.Replace(sceneName, @"^[^_]*_", "");
|
||||
await SceneManager.UnloadSceneAsync(sceneName);
|
||||
await ForceUnloadAllAssets(config.domain);
|
||||
AppConfig.PackageDomainName = "";
|
||||
Debug.Log("UnityEvo:Domain退出...");
|
||||
}
|
||||
}
|
||||
|
||||
// 强制卸载所有资源包,该方法请在合适的时机调用。
|
||||
// 注意:Package在销毁的时候也会自动调用该方法。
|
||||
private static async UniTask ForceUnloadAllAssets(string packageName)
|
||||
{
|
||||
var package = YooAssets.TryGetPackage(packageName);
|
||||
if (package != null && package.InitializeStatus == EOperationStatus.Succeed)
|
||||
{
|
||||
var operation = package.UnloadAllAssetsAsync();
|
||||
await operation;
|
||||
await package.DestroyAsync();
|
||||
YooAssets.RemovePackage(packageName);
|
||||
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
Debug.Log($"UnityEvo:{packageName} 资源包已卸载...");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:{packageName} 资源包不存在,请检查是否已经卸载还是卸载异常...");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var entity in _domainStaticNameEntities)
|
||||
{
|
||||
DeleteDomainStaticNameEntity(entity);
|
||||
}
|
||||
|
||||
_domainStaticNameEntities.Clear();
|
||||
foreach (var entity in _domainNameEntities)
|
||||
{
|
||||
DeleteDomainNameEntity(entity);
|
||||
}
|
||||
|
||||
_domainNameEntities.Clear();
|
||||
|
||||
if (ProgressBarPanel != null)
|
||||
{
|
||||
GameObject.Destroy(ProgressBarPanel);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetOpenDomainType(OpenDomainType type)
|
||||
{
|
||||
_openDomainType = type;
|
||||
}
|
||||
|
||||
|
||||
public static void SetTransformCtor(Transform transform)
|
||||
{
|
||||
_transformCtor = transform.GetTransformCtor();
|
||||
}
|
||||
|
||||
public static void SetTransformCtor(TransformCtor transformCtor)
|
||||
{
|
||||
transformCtor = transformCtor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ce99f5715d04b79accf946894f192eb
|
||||
timeCreated: 1775976286
|
||||
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Main;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class FsmLoadSystem : FsmSystemAsync , IFsmSystemAsync
|
||||
{
|
||||
private OpenDomainType OpenDomainType { get; set; }
|
||||
|
||||
private TransformCtor transformCtor;
|
||||
|
||||
public ProgressBarPanel ProgressBarPanel { get; set; }
|
||||
|
||||
public bool IsLogin = false;
|
||||
public void SetOpenDomainType(OpenDomainType type)
|
||||
{
|
||||
this.OpenDomainType = type;
|
||||
}
|
||||
public void SetTransformCtor(Transform transform)
|
||||
{
|
||||
this.transformCtor = transform.GetTransformCtor();
|
||||
}
|
||||
public void SetTransformCtor(TransformCtor transformCtor)
|
||||
{
|
||||
this.transformCtor = transformCtor;
|
||||
}
|
||||
public OpenDomainType GetOpenDomainType()
|
||||
{
|
||||
return this.OpenDomainType;
|
||||
}
|
||||
|
||||
public TransformCtor GetTransformCtor()
|
||||
{
|
||||
return this.transformCtor;
|
||||
}
|
||||
|
||||
// 强制卸载所有资源包,该方法请在合适的时机调用。
|
||||
// 注意:Package在销毁的时候也会自动调用该方法。
|
||||
public async UniTask ForceUnloadAllAssets(string packageName)
|
||||
{
|
||||
var package = YooAssets.TryGetPackage(packageName);
|
||||
if (package != null&&package.InitializeStatus == EOperationStatus.Succeed)
|
||||
{
|
||||
var operation = package.UnloadAllAssetsAsync();
|
||||
await operation;
|
||||
await package.DestroyAsync();
|
||||
YooAssets.RemovePackage(packageName);
|
||||
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
Debug.Log($"UnityEvo:{packageName} 资源包已卸载...");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:{packageName} 资源包不存在,请检查是否已经卸载还是卸载异常...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f012ae5832b467a802b8d775b1dae1e
|
||||
timeCreated: 1744710396
|
||||
@@ -235,11 +235,6 @@ namespace Stary.Evo
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
private Type IsAssetLoaded(string assemblyName)
|
||||
{
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
@@ -256,10 +251,6 @@ namespace Stary.Evo
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
base.OnUpdate();
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Stary.Evo
|
||||
await FsmSystem.SetCurState(nameof(ResEditorSimulateState));
|
||||
#elif HOST_PLAYMODE
|
||||
//登录
|
||||
if (((FsmLoadSystem)FsmSystem).IsLogin)
|
||||
if ((AppConfig.IsLogin))
|
||||
{
|
||||
await GetServerVersion();
|
||||
await HOST_PLAYMODE(package);
|
||||
@@ -99,16 +99,6 @@ namespace Stary.Evo
|
||||
#endif
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync<T>(T param)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
@@ -431,11 +421,9 @@ namespace Stary.Evo
|
||||
// // 等一帧,让系统真正释放句柄
|
||||
// await UniTask.DelayFrame(1);
|
||||
// }
|
||||
|
||||
FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
|
||||
if (loadSystem != null && loadSystem.ProgressBarPanel == null)
|
||||
if (DomainAssetSystem.ProgressBarPanel == null)
|
||||
{
|
||||
loadSystem.ProgressBarPanel = Object.Instantiate(Resources.Load<GameObject>("ProgressBarPanel"),
|
||||
DomainAssetSystem.ProgressBarPanel = Object.Instantiate(Resources.Load<GameObject>("ProgressBarPanel"),
|
||||
Camera.main.transform).GetOrAddComponent<ProgressBarPanel>();
|
||||
}
|
||||
|
||||
@@ -445,17 +433,15 @@ namespace Stary.Evo
|
||||
private void DownLoadProgress(float progress)
|
||||
{
|
||||
Debug.Log($"下载进度:{progress:P0}");
|
||||
FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
|
||||
if (loadSystem != null)
|
||||
loadSystem.ProgressBarPanel.SetProgressBarValue("下载中", progress);
|
||||
|
||||
DomainAssetSystem.ProgressBarPanel.SetProgressBarValue("下载中", progress);
|
||||
}
|
||||
|
||||
private void UnzipProgress(float progress)
|
||||
{
|
||||
Debug.Log($"解压进度:{progress:P0}");
|
||||
FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
|
||||
if (loadSystem != null)
|
||||
loadSystem.ProgressBarPanel.SetProgressBarValue("解压中", progress);
|
||||
|
||||
DomainAssetSystem.ProgressBarPanel.SetProgressBarValue("解压中", progress);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -111,20 +111,6 @@ namespace Stary.Evo
|
||||
}
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync<T>(T param)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
base.OnUpdate();
|
||||
}
|
||||
|
||||
|
||||
public override UniTask OnExitAsync()
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
#if Immersal
|
||||
using Immersal.AR;
|
||||
#endif
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.InformationSave;
|
||||
using UnityEngine;
|
||||
@@ -14,45 +10,41 @@ namespace Stary.Evo
|
||||
{
|
||||
public class ResStartState : AbstractFSMIStateAsync
|
||||
{
|
||||
private DomainConfig.LoadResType loadResType;
|
||||
public GameObject mainPrefab;
|
||||
private DomainConfig domainConfig;
|
||||
private string _packageName;
|
||||
private string _sceneName;
|
||||
|
||||
public ResStartState(IFsmSystemAsync system) : base(system)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override UniTask OnEnterAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override UniTask OnEnterAsync<T>(T param)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override async UniTask OnEnterAsync<T1, T2>(T1 param1, T2 param2)
|
||||
{
|
||||
if (AppConfig.DeveloperMode)
|
||||
{
|
||||
domainConfig = param1 as DomainConfig;
|
||||
loadResType = domainConfig.loadResType;
|
||||
_packageName = domainConfig.domain;
|
||||
Type type = param2 as Type;
|
||||
var package = YooAssets.GetPackage(domainConfig.domain);
|
||||
switch (loadResType)
|
||||
|
||||
GameObject mainPrefab = null;
|
||||
switch (domainConfig.loadResType)
|
||||
{
|
||||
case DomainConfig.LoadResType.Prefab:
|
||||
|
||||
await LoadDomainPrefab(package);
|
||||
|
||||
mainPrefab = await DomainAssetSystem.LoadDomainPrefab(domainConfig);
|
||||
await DomainAssetSystem.SetTransformInfo(mainPrefab);
|
||||
if (domainConfig.domainLoadType != DomainConfig.DomainLoadType.Static)
|
||||
{
|
||||
DomainAssetSystem.AddDomainNameEntity(domainConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
DomainAssetSystem.AddDomainStaticNameEntity(domainConfig);
|
||||
}
|
||||
break;
|
||||
case DomainConfig.LoadResType.Scene:
|
||||
|
||||
var package = YooAssets.GetPackage(domainConfig.domain);
|
||||
var sceneMode = domainConfig.loadSceneMode;
|
||||
var physicsMode = LocalPhysicsMode.None;
|
||||
SceneHandle handle =
|
||||
@@ -60,142 +52,28 @@ namespace Stary.Evo
|
||||
await handle;
|
||||
|
||||
Scene targetScene = SceneManager.GetSceneByName(handle.SceneName);
|
||||
// targetScene.name = domainConfig.mainScene;
|
||||
// 设置为 active scene 或者后续 Move 到该 scene
|
||||
SceneManager.SetActiveScene(targetScene);
|
||||
_sceneName = targetScene.name;
|
||||
mainPrefab = GameObject.Find(domainConfig.mainPrefab);
|
||||
if (mainPrefab == null)
|
||||
{
|
||||
await LoadDomainPrefab(package);
|
||||
}
|
||||
|
||||
mainPrefab = await DomainAssetSystem.LoadDomainPrefab(domainConfig);
|
||||
SceneManager.MoveGameObjectToScene(mainPrefab, targetScene);
|
||||
break;
|
||||
}
|
||||
|
||||
if (domainConfig.domain != "Main")
|
||||
{
|
||||
LocalTransformInfo info = mainPrefab.GetOrAddComponent<LocalTransformInfo>();
|
||||
FsmLoadSystem fsmLoadSystem = FsmSystem as FsmLoadSystem;
|
||||
|
||||
if (info._list.Count >= 2)
|
||||
{
|
||||
if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.PointCloud)
|
||||
{
|
||||
info.Switch(1);
|
||||
}
|
||||
else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.VIOICE)
|
||||
{
|
||||
info.Switch(0);
|
||||
}
|
||||
else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.ImageTracked)
|
||||
{
|
||||
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
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{mainPrefab.name}的TransformInfo长度小于2,无法继续运行,请排查");
|
||||
}
|
||||
}
|
||||
|
||||
if (mainPrefab != null)
|
||||
{
|
||||
DomainBase hotfixInstance = mainPrefab.GetComponent(type) as DomainBase;
|
||||
if (hotfixInstance == null)
|
||||
{
|
||||
hotfixInstance = mainPrefab.AddComponent(type) as DomainBase;
|
||||
}
|
||||
|
||||
if (hotfixInstance == null)
|
||||
{
|
||||
Debug.LogError($"热更类{type.Name}实例创建失败!必须继承MonoBehaviour");
|
||||
return;
|
||||
}
|
||||
|
||||
hotfixInstance.DomainName = domainConfig.domain;
|
||||
hotfixInstance.DomainNameRaw = $"{domainConfig.domain}_RawFile";
|
||||
|
||||
|
||||
// 原有调用逻辑修改为使用实例
|
||||
hotfixInstance.OnEnter("");
|
||||
hotfixInstance.OnEnterAsync("");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_packageName = AppConfig.PackageDomainName;
|
||||
await DomainAssetSystem.BindableProperty(domainConfig, mainPrefab, type);
|
||||
}
|
||||
}
|
||||
|
||||
private async UniTask 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()
|
||||
{
|
||||
if (_packageName=="Main")
|
||||
return;
|
||||
|
||||
if (HybridClREntrance.Global.stage == StageType.Developer)
|
||||
if (domainConfig.loadResType == DomainConfig.LoadResType.Prefab &&
|
||||
domainConfig.domainLoadType == DomainConfig.DomainLoadType.Single)
|
||||
{
|
||||
DomainBase domainBase = mainPrefab.GetOrAddComponent<DomainBase>();
|
||||
if (domainBase == null)
|
||||
{
|
||||
Debug.LogError($"UnityEvo:{mainPrefab.name}的DomainBase为空,无法退出,请排查");
|
||||
}
|
||||
else
|
||||
{
|
||||
domainBase.OnExit();
|
||||
await domainBase.OnExitAsync();
|
||||
|
||||
GameObject.Destroy(domainBase.gameObject);
|
||||
|
||||
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainName);
|
||||
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainNameRaw);
|
||||
}
|
||||
|
||||
Debug.Log("UnityEvo:Domain退出...");
|
||||
|
||||
if (loadResType == DomainConfig.LoadResType.Scene)
|
||||
{
|
||||
await SceneManager.UnloadSceneAsync(_sceneName);
|
||||
}
|
||||
await DomainAssetSystem.UnloadDomainAsset();
|
||||
}
|
||||
else if (HybridClREntrance.Global.stage == StageType.Originality)
|
||||
else if (domainConfig.loadResType == DomainConfig.LoadResType.Scene)
|
||||
{
|
||||
await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(_packageName);
|
||||
AppConfig.PackageDomainName = "";
|
||||
Debug.Log("UnityEvo:Domain退出...");
|
||||
await DomainAssetSystem.UnloadSceneAsset(domainConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Stary.Evo
|
||||
public StageType stage;
|
||||
public string domain;
|
||||
|
||||
private FsmLoadSystem _loadSystem;
|
||||
private IFsmSystemAsync _loadSystem;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -30,7 +30,7 @@ namespace Stary.Evo
|
||||
return;
|
||||
}
|
||||
|
||||
_loadSystem = new FsmLoadSystem();
|
||||
_loadSystem = new FsmSystemAsync();
|
||||
// 初始化日志
|
||||
_loadSystem.AddState(new HotFixStartState(_loadSystem));
|
||||
_loadSystem.AddState(new ResEditorSimulateState(_loadSystem));
|
||||
@@ -51,7 +51,7 @@ namespace Stary.Evo
|
||||
Debug.Log($"UnityEvo:读取资源配置表成功...{AppConfig.IpConfig}{AppConfig.UserName}{AppConfig.PassWord}");
|
||||
//登录
|
||||
string url = AppConfig.IpConfig + "/Authentication/login";
|
||||
_loadSystem.IsLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
|
||||
AppConfig.IsLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -91,7 +91,7 @@ namespace Stary.Evo
|
||||
public async void OpenDomain(string domain, OpenDomainType openDomainType)
|
||||
{
|
||||
this.domain = domain;
|
||||
_loadSystem.SetOpenDomainType(openDomainType);
|
||||
DomainAssetSystem.SetOpenDomainType(openDomainType);
|
||||
if (this.domain != AppConfig.PackageDomainName)
|
||||
{
|
||||
AppConfig.PackageDomainName = domain;
|
||||
@@ -106,8 +106,8 @@ namespace Stary.Evo
|
||||
public void OpenDomain(string domain, TransformCtor transformCtor)
|
||||
{
|
||||
this.domain = domain;
|
||||
_loadSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
|
||||
_loadSystem.SetTransformCtor(transformCtor);
|
||||
DomainAssetSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
|
||||
DomainAssetSystem.SetTransformCtor(transformCtor);
|
||||
if (this.domain != AppConfig.PackageDomainName)
|
||||
{
|
||||
AppConfig.PackageDomainName = domain;
|
||||
@@ -122,8 +122,8 @@ namespace Stary.Evo
|
||||
public void OpenDomain(string domain, Transform transform)
|
||||
{
|
||||
this.domain = domain;
|
||||
_loadSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
|
||||
_loadSystem.SetTransformCtor(transform);
|
||||
DomainAssetSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
|
||||
DomainAssetSystem.SetTransformCtor(transform);
|
||||
if (this.domain != AppConfig.PackageDomainName)
|
||||
{
|
||||
AppConfig.PackageDomainName = domain;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class VideoSystem : AbstractSystem, IVideoSystem
|
||||
public async void PlayVideo(VideoPanel.VideoInfo info)
|
||||
{
|
||||
AudioCoreManager.SetMusicVolume(2f, 0f);
|
||||
await this.GetSystem<IPanelSystem>().PushQueue<VideoPanel>(parent:AppConfig.GetDefaultMainInstance().transform,packageName:"Main");
|
||||
await this.GetSystem<IPanelSystem>().PushQueue<VideoPanel>(packageName:"Main");
|
||||
this.GetSystem<IPanelSystem>().SendPanelEvent(ModeType.VideoStart,info);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.tools",
|
||||
"version": "1.3.36",
|
||||
"version": "1.4.0",
|
||||
"displayName": "00.StaryEvo.Tools",
|
||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||
"unity": "2021.3",
|
||||
|
||||
Reference in New Issue
Block a user