Update AssetReference.cs

This commit is contained in:
ALEXTANG
2023-05-11 19:11:19 +08:00
parent 5c7223213b
commit c40391a65b

View File

@@ -22,7 +22,9 @@ namespace TEngine
/// </summary> /// </summary>
public AssetGroup AssetGroup => _assetGroup; public AssetGroup AssetGroup => _assetGroup;
#pragma warning disable CS0628
public AssetReference Parent { protected set; get; } public AssetReference Parent { protected set; get; }
#pragma warning restore CS0628
// ReSharper disable once ConvertToAutoPropertyWithPrivateSetter // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
@@ -179,8 +181,7 @@ namespace TEngine
/// <param name="parent">父级引用。</param> /// <param name="parent">父级引用。</param>
/// <returns>资源引用组件。</returns> /// <returns>资源引用组件。</returns>
/// <exception cref="GameFrameworkException">捕获异常。</exception> /// <exception cref="GameFrameworkException">捕获异常。</exception>
public static AssetReference BindAssetReference(GameObject go, AssetOperationHandle handle = null, public static AssetReference BindAssetReference(GameObject go, AssetOperationHandle handle, string location = "", AssetReference parent = null)
string location = "", AssetReference parent = null)
{ {
if (go == null) if (go == null)
{ {
@@ -199,6 +200,28 @@ namespace TEngine
return ret; return ret;
} }
/// <summary>
/// 绑定资源引用。
/// </summary>
/// <param name="go">游戏物体实例。</param>
/// <param name="location">资源定位地址。</param>
/// <param name="parent">父级引用。</param>
/// <returns>资源引用组件。</returns>
/// <exception cref="GameFrameworkException">捕获异常。</exception>
public static AssetReference BindAssetReference(GameObject go,string location = "", AssetReference parent = null)
{
if (go == null)
{
throw new GameFrameworkException($"BindAssetReference Failed => GameObject is null!");
}
var ret = go.AddComponent<AssetReference>();
ret.Bind(operation: null, assetLocation: location, parent: parent);
return ret;
}
#endregion #endregion
} }
} }