diff --git a/Assets/TEngine/Runtime/Core/MemPoolMgr.cs b/Assets/TEngine/Runtime/Core/MemPoolMgr.cs index ba084aeb..7d6fcd3a 100644 --- a/Assets/TEngine/Runtime/Core/MemPoolMgr.cs +++ b/Assets/TEngine/Runtime/Core/MemPoolMgr.cs @@ -27,7 +27,7 @@ namespace TEngine { List m_listPool = new List(); - [Conditional("TEngine_DEBUG")] + [Conditional("UNITY_EDITOR")] public void ShowCount() { int totalCnt = 0; diff --git a/Assets/TEngine/Runtime/Res/AssetConfig.cs b/Assets/TEngine/Runtime/Res/AssetConfig.cs index 2ccd2636..b8a60647 100644 --- a/Assets/TEngine/Runtime/Res/AssetConfig.cs +++ b/Assets/TEngine/Runtime/Res/AssetConfig.cs @@ -117,7 +117,6 @@ namespace TEngine UnloadFalse(); Load(); } - } /// diff --git a/Assets/TEngine/Runtime/Res/AssetData.cs b/Assets/TEngine/Runtime/Res/AssetData.cs index a0643143..19d38dcc 100644 --- a/Assets/TEngine/Runtime/Res/AssetData.cs +++ b/Assets/TEngine/Runtime/Res/AssetData.cs @@ -5,9 +5,6 @@ using UnityEngine.U2D; namespace TEngine { - /// - /// 封装的AssetBundle - /// public class AssetData { private AssetBundleData _refBundle; @@ -56,14 +53,8 @@ namespace TEngine public string FullPath => _fPath; - /// - /// Asset名 - /// public string Name => _name; - /// - /// 异步操作对象 - /// public AsyncOperation AsyncOp { get @@ -111,14 +102,11 @@ namespace TEngine _fPath = path; } - /// - /// 增引用计数 - /// public void AddRef() { ++_refCount; #if UNITY_EDITOR - //TLogger.LogInfo($"Add AssetData {_fPath} _refCount = {_refCount}"); + TLogger.LogInfoSuccessd($"Add AssetData {_fPath} _refCount = {_refCount}"); #endif } @@ -129,7 +117,7 @@ namespace TEngine { --_refCount; #if UNITY_EDITOR - //TLogger.LogInfo($"Dec AssetData {_fPath} _refCount = {_refCount}"); + TLogger.LogInfoSuccessd($"Dec AssetData {_fPath} _refCount = {_refCount}"); #endif if (_refCount <= 0) { @@ -328,11 +316,15 @@ namespace TEngine public void LoadScene(LoadSceneMode mode) { if (_refBundle != null && _refBundle.Bundle == null) + { _refBundle.Load(); + } _asyncLoadRequest = SceneManager.LoadSceneAsync(_name, mode); if (_asyncLoadRequest != null) + { _asyncLoadRequest.allowSceneActivation = false; + } } /// diff --git a/Assets/TEngine/Runtime/Res/AssetTag.cs b/Assets/TEngine/Runtime/Res/AssetTag.cs index b224ff10..e013f3fd 100644 --- a/Assets/TEngine/Runtime/Res/AssetTag.cs +++ b/Assets/TEngine/Runtime/Res/AssetTag.cs @@ -2,36 +2,23 @@ namespace TEngine { - /// - /// GameObject与AssetData的绑定对象,用于管理对AssetData的引用计数 - /// [DisallowMultipleComponent, AddComponentMenu("")] public sealed class AssetTag : MonoBehaviour { AssetData _assetData; [SerializeField, HideInInspector] private string _path; - /// - /// 对应的资源路径 - /// public string Path => _path; - /// - /// 缓存池中的归还时间戳 - /// - public float PoolReturnTimestamp { get; set; } - private int _instanceID = 0; + private void Awake() { - // 处理Cloned GameObject上引用计数不正确的问题 if (_path != null && (_instanceID == -1 || _instanceID != gameObject.GetInstanceID())) + { Bind(ResMgr.Instance.GetAsset(_path, false)); + } } - /// - /// GameObject绑定AssetData - /// - /// Asset数据 public void Bind(AssetData assetData) { _assetData = assetData; @@ -45,5 +32,4 @@ namespace TEngine _assetData.DecRef(); } } - } \ No newline at end of file