Update ResMgr

Update ResMgr
This commit is contained in:
ALEXTANG
2022-05-25 23:50:15 +08:00
parent 83f59b66a2
commit 73a8fcf0bd
2 changed files with 15 additions and 2 deletions

View File

@@ -344,11 +344,14 @@ namespace TEngine
if (_assetPath2BundleDatas.TryGetValue(path, out bundleName)) if (_assetPath2BundleDatas.TryGetValue(path, out bundleName))
{ {
if (!_bundleDatas.TryGetValue(bundleName, out assetBundleData)) if (!_bundleDatas.TryGetValue(bundleName, out assetBundleData))
{
TLogger.LogError($"Can not get AssetBundleData with AssetBundle '{bundleName}'!"); TLogger.LogError($"Can not get AssetBundleData with AssetBundle '{bundleName}'!");
}
} }
else else
{
TLogger.LogError($"Can not find '{path}' in any AssetBundle!"); TLogger.LogError($"Can not find '{path}' in any AssetBundle!");
}
return assetBundleData; return assetBundleData;
} }
} }

View File

@@ -72,7 +72,9 @@ namespace TEngine
assetData.AddRef(); assetData.AddRef();
result = assetData.AssetObject as T; result = assetData.AssetObject as T;
if (result != null && !_scriptableObjects.ContainsKey(result)) if (result != null && !_scriptableObjects.ContainsKey(result))
{
_scriptableObjects.Add(result, assetData); _scriptableObjects.Add(result, assetData);
}
} }
} }
@@ -82,7 +84,9 @@ namespace TEngine
public T Load<T>(string path) where T:UnityEngine.Object public T Load<T>(string path) where T:UnityEngine.Object
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{
return null; return null;
}
T result = null; T result = null;
AssetData assetData = _assetConfig.GetAssetAtPath(path); AssetData assetData = _assetConfig.GetAssetAtPath(path);
@@ -112,7 +116,9 @@ namespace TEngine
public GameObject GetGameObject(string path) public GameObject GetGameObject(string path)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{
return null; return null;
}
GameObject go = null; GameObject go = null;
AssetData assetData = _assetConfig.GetAssetAtPath(path); AssetData assetData = _assetConfig.GetAssetAtPath(path);
@@ -120,7 +126,9 @@ namespace TEngine
if (assetData != null) if (assetData != null)
{ {
go = Object.Instantiate(assetData.AssetObject) as GameObject; go = Object.Instantiate(assetData.AssetObject) as GameObject;
BindAssetData(go, assetData); {
BindAssetData(go, assetData);
}
} }
return go; return go;
@@ -139,7 +147,9 @@ namespace TEngine
public byte[] GetBytesFromAsset(string path) public byte[] GetBytesFromAsset(string path)
{ {
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{
return null; return null;
}
byte[] result = null; byte[] result = null;
AssetData assetData = _assetConfig.GetAssetAtPath(path); AssetData assetData = _assetConfig.GetAssetAtPath(path);