namespace YooAsset
{
public class AssetInfo
{
private readonly PackageAsset _packageAsset;
private string _providerGUID;
///
/// 所属包裹
///
public string PackageName { private set; get; }
///
/// 资源类型
///
public System.Type AssetType { private set; get; }
///
/// 错误信息
///
public string Error { private set; get; }
///
/// 唯一标识符
///
internal string GUID
{
get
{
if (string.IsNullOrEmpty(_providerGUID) == false)
return _providerGUID;
if (AssetType == null)
_providerGUID = $"[{AssetPath}][null]";
else
_providerGUID = $"[{AssetPath}][{AssetType.Name}]";
return _providerGUID;
}
}
///
/// 身份是否无效
///
public bool IsInvalid
{
get
{
return _packageAsset == null;
}
}
///
/// 可寻址地址
///
public string Address
{
get
{
if (_packageAsset == null)
return string.Empty;
return _packageAsset.Address;
}
}
///
/// 资源路径
///
public string AssetPath
{
get
{
if (_packageAsset == null)
return string.Empty;
return _packageAsset.AssetPath;
}
}
internal AssetInfo(string packageName, PackageAsset packageAsset, System.Type assetType)
{
if (packageAsset == null)
throw new System.Exception("Should never get here !");
_providerGUID = string.Empty;
_packageAsset = packageAsset;
PackageName = packageName;
AssetType = assetType;
Error = string.Empty;
}
internal AssetInfo(string packageName, string error)
{
_providerGUID = string.Empty;
_packageAsset = null;
PackageName = packageName;
AssetType = null;
Error = error;
}
}
}