【m】更新后台
This commit is contained in:
52
Assets/Main/Script/Runtime/Init/Base/AppConfig.cs
Normal file
52
Assets/Main/Script/Runtime/Init/Base/AppConfig.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class AppConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// package name
|
||||
/// </summary>
|
||||
public static string PackageDomainName { get; set; }
|
||||
|
||||
|
||||
public static string IpConfig { get; set; }
|
||||
public static string UserName { get; set; }
|
||||
public static string PassWord { get; set; }
|
||||
public static string ProductName { get; set; }
|
||||
public static string Platform { get; set; }
|
||||
|
||||
public static string MainDomainVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主场景main实例物体
|
||||
/// </summary>
|
||||
private static GameObject _MainBaseModel;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 赋值默认的实例
|
||||
/// </summary>
|
||||
public static void SetDefaultMainInstance(GameObject mainbase)
|
||||
{
|
||||
_MainBaseModel = mainbase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 赋值默认的实例
|
||||
/// </summary>
|
||||
public static GameObject GetDefaultMainInstance()
|
||||
{
|
||||
return _MainBaseModel;
|
||||
}
|
||||
}
|
||||
|
||||
public class GlobalConfig
|
||||
{
|
||||
public const string RikidHandLeft = "LeftHandRender/RKHandVisual/Hand_L/left_wrist/left_palm";
|
||||
public const string RikidHandRight = "RightHandRender/RKHandVisual/Hand_R/right_wrist/right_palm";
|
||||
public const string RikidHandRightIndexTip = "RightHandRender/RKHandVisual/Hand_R/right_wrist/right_index_metacarpal/right_index_proximal/right_index_intermediate/right_index_distal/right_index_tip";
|
||||
}
|
||||
}
|
||||
3
Assets/Main/Script/Runtime/Init/Base/AppConfig.cs.meta
Normal file
3
Assets/Main/Script/Runtime/Init/Base/AppConfig.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43c9d32ba5934c65bf80d76e35074a1a
|
||||
timeCreated: 1741162242
|
||||
88
Assets/Main/Script/Runtime/Init/Base/DomainBase.cs
Normal file
88
Assets/Main/Script/Runtime/Init/Base/DomainBase.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Main;
|
||||
using Stary.Evo.AudioCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using YooAsset;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
/// <summary>
|
||||
/// 热更基类,应该继承的基类
|
||||
/// </summary>
|
||||
public class DomainBase : MonoBehaviour
|
||||
{
|
||||
public string DomainName { protected get; set; }
|
||||
|
||||
public Transform TransformInfo;
|
||||
protected bool isExit { private get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 触发Domain时,调用该方法
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
public virtual void OnEnter(string param)
|
||||
{
|
||||
TransformInfo = transform.Find("TransformInfo");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Domain被关闭时,会调该方法
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
public virtual void OnExit()
|
||||
{
|
||||
isExit = true;
|
||||
AudioCoreManager.StopMusic();
|
||||
MainArchitecture.Interface.GetSystem<IVideoSystem>().StopVideo();
|
||||
MainArchitecture.Interface.GetSystem<IDigitalHuman>().KillTalkState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual async Task OnEnterAsync(string param)
|
||||
{
|
||||
isExit = true;
|
||||
}
|
||||
|
||||
public virtual async Task OnExitAsync()
|
||||
{
|
||||
await ForceUnloadAllAssets();
|
||||
}
|
||||
|
||||
private async void OnDestroy()
|
||||
{
|
||||
// if (!isExit)
|
||||
// {
|
||||
// OnExit();
|
||||
// await OnExitAsync();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// 强制卸载所有资源包,该方法请在合适的时机调用。
|
||||
// 注意:Package在销毁的时候也会自动调用该方法。
|
||||
private async UniTask ForceUnloadAllAssets()
|
||||
{
|
||||
var package = YooAssets.TryGetPackage(DomainName);
|
||||
if (package != null)
|
||||
{
|
||||
var operation = package.UnloadAllAssetsAsync();
|
||||
await operation;
|
||||
await package.DestroyAsync();
|
||||
YooAssets.RemovePackage(DomainName);
|
||||
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
Debug.Log($"UnityEvo:{DomainName} 资源包已卸载...");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"UnityEvo:{DomainName} 资源包不存在,请检查是否已经卸载还是卸载异常...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Main/Script/Runtime/Init/Base/DomainBase.cs.meta
Normal file
3
Assets/Main/Script/Runtime/Init/Base/DomainBase.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8923efe3eb184e7f9283f71e2dc4ea10
|
||||
timeCreated: 1742540500
|
||||
Reference in New Issue
Block a user