mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Delete Unused Ref
Delete Unused Ref
This commit is contained in:
@@ -27,7 +27,7 @@ namespace TEngine
|
||||
{
|
||||
List<MemPoolBase> m_listPool = new List<MemPoolBase>();
|
||||
|
||||
[Conditional("TEngine_DEBUG")]
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
public void ShowCount()
|
||||
{
|
||||
int totalCnt = 0;
|
||||
|
@@ -117,7 +117,6 @@ namespace TEngine
|
||||
UnloadFalse();
|
||||
Load();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -5,9 +5,6 @@ using UnityEngine.U2D;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// 封装的AssetBundle
|
||||
/// </summary>
|
||||
public class AssetData
|
||||
{
|
||||
private AssetBundleData _refBundle;
|
||||
@@ -56,14 +53,8 @@ namespace TEngine
|
||||
|
||||
public string FullPath => _fPath;
|
||||
|
||||
/// <summary>
|
||||
/// Asset名
|
||||
/// </summary>
|
||||
public string Name => _name;
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作对象
|
||||
/// </summary>
|
||||
public AsyncOperation AsyncOp
|
||||
{
|
||||
get
|
||||
@@ -111,14 +102,11 @@ namespace TEngine
|
||||
_fPath = path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增引用计数
|
||||
/// </summary>
|
||||
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,12 +316,16 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载Asset
|
||||
|
@@ -2,36 +2,23 @@
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// GameObject与AssetData的绑定对象,用于管理对AssetData的引用计数
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent, AddComponentMenu("")]
|
||||
public sealed class AssetTag : MonoBehaviour
|
||||
{
|
||||
AssetData _assetData;
|
||||
[SerializeField, HideInInspector] private string _path;
|
||||
/// <summary>
|
||||
/// 对应的资源路径
|
||||
/// </summary>
|
||||
public string Path => _path;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存池中的归还时间戳
|
||||
/// </summary>
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GameObject绑定AssetData
|
||||
/// </summary>
|
||||
/// <param name="assetData">Asset数据</param>
|
||||
public void Bind(AssetData assetData)
|
||||
{
|
||||
_assetData = assetData;
|
||||
@@ -45,5 +32,4 @@ namespace TEngine
|
||||
_assetData.DecRef();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user