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>();
|
List<MemPoolBase> m_listPool = new List<MemPoolBase>();
|
||||||
|
|
||||||
[Conditional("TEngine_DEBUG")]
|
[Conditional("UNITY_EDITOR")]
|
||||||
public void ShowCount()
|
public void ShowCount()
|
||||||
{
|
{
|
||||||
int totalCnt = 0;
|
int totalCnt = 0;
|
||||||
|
@@ -117,7 +117,6 @@ namespace TEngine
|
|||||||
UnloadFalse();
|
UnloadFalse();
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -5,9 +5,6 @@ using UnityEngine.U2D;
|
|||||||
|
|
||||||
namespace TEngine
|
namespace TEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 封装的AssetBundle
|
|
||||||
/// </summary>
|
|
||||||
public class AssetData
|
public class AssetData
|
||||||
{
|
{
|
||||||
private AssetBundleData _refBundle;
|
private AssetBundleData _refBundle;
|
||||||
@@ -56,14 +53,8 @@ namespace TEngine
|
|||||||
|
|
||||||
public string FullPath => _fPath;
|
public string FullPath => _fPath;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Asset名
|
|
||||||
/// </summary>
|
|
||||||
public string Name => _name;
|
public string Name => _name;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步操作对象
|
|
||||||
/// </summary>
|
|
||||||
public AsyncOperation AsyncOp
|
public AsyncOperation AsyncOp
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -111,14 +102,11 @@ namespace TEngine
|
|||||||
_fPath = path;
|
_fPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增引用计数
|
|
||||||
/// </summary>
|
|
||||||
public void AddRef()
|
public void AddRef()
|
||||||
{
|
{
|
||||||
++_refCount;
|
++_refCount;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
//TLogger.LogInfo($"Add AssetData {_fPath} _refCount = {_refCount}");
|
TLogger.LogInfoSuccessd($"Add AssetData {_fPath} _refCount = {_refCount}");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +117,7 @@ namespace TEngine
|
|||||||
{
|
{
|
||||||
--_refCount;
|
--_refCount;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
//TLogger.LogInfo($"Dec AssetData {_fPath} _refCount = {_refCount}");
|
TLogger.LogInfoSuccessd($"Dec AssetData {_fPath} _refCount = {_refCount}");
|
||||||
#endif
|
#endif
|
||||||
if (_refCount <= 0)
|
if (_refCount <= 0)
|
||||||
{
|
{
|
||||||
@@ -328,12 +316,16 @@ namespace TEngine
|
|||||||
public void LoadScene(LoadSceneMode mode)
|
public void LoadScene(LoadSceneMode mode)
|
||||||
{
|
{
|
||||||
if (_refBundle != null && _refBundle.Bundle == null)
|
if (_refBundle != null && _refBundle.Bundle == null)
|
||||||
|
{
|
||||||
_refBundle.Load();
|
_refBundle.Load();
|
||||||
|
}
|
||||||
|
|
||||||
_asyncLoadRequest = SceneManager.LoadSceneAsync(_name, mode);
|
_asyncLoadRequest = SceneManager.LoadSceneAsync(_name, mode);
|
||||||
if (_asyncLoadRequest != null)
|
if (_asyncLoadRequest != null)
|
||||||
|
{
|
||||||
_asyncLoadRequest.allowSceneActivation = false;
|
_asyncLoadRequest.allowSceneActivation = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 卸载Asset
|
/// 卸载Asset
|
||||||
|
@@ -2,36 +2,23 @@
|
|||||||
|
|
||||||
namespace TEngine
|
namespace TEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// GameObject与AssetData的绑定对象,用于管理对AssetData的引用计数
|
|
||||||
/// </summary>
|
|
||||||
[DisallowMultipleComponent, AddComponentMenu("")]
|
[DisallowMultipleComponent, AddComponentMenu("")]
|
||||||
public sealed class AssetTag : MonoBehaviour
|
public sealed class AssetTag : MonoBehaviour
|
||||||
{
|
{
|
||||||
AssetData _assetData;
|
AssetData _assetData;
|
||||||
[SerializeField, HideInInspector] private string _path;
|
[SerializeField, HideInInspector] private string _path;
|
||||||
/// <summary>
|
|
||||||
/// 对应的资源路径
|
|
||||||
/// </summary>
|
|
||||||
public string Path => _path;
|
public string Path => _path;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 缓存池中的归还时间戳
|
|
||||||
/// </summary>
|
|
||||||
public float PoolReturnTimestamp { get; set; }
|
|
||||||
|
|
||||||
private int _instanceID = 0;
|
private int _instanceID = 0;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
// 处理Cloned GameObject上引用计数不正确的问题
|
|
||||||
if (_path != null && (_instanceID == -1 || _instanceID != gameObject.GetInstanceID()))
|
if (_path != null && (_instanceID == -1 || _instanceID != gameObject.GetInstanceID()))
|
||||||
|
{
|
||||||
Bind(ResMgr.Instance.GetAsset(_path, false));
|
Bind(ResMgr.Instance.GetAsset(_path, false));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// GameObject绑定AssetData
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetData">Asset数据</param>
|
|
||||||
public void Bind(AssetData assetData)
|
public void Bind(AssetData assetData)
|
||||||
{
|
{
|
||||||
_assetData = assetData;
|
_assetData = assetData;
|
||||||
@@ -45,5 +32,4 @@ namespace TEngine
|
|||||||
_assetData.DecRef();
|
_assetData.DecRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user