mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
* Failed type checks return null * Bad dependency numbers return null * Remove GetAsset methods * Make asset processing more lenient about null references
38 lines
730 B
C#
38 lines
730 B
C#
using AssetRipper.Assets;
|
|
|
|
namespace AssetRipper.SourceGenerated.Extensions
|
|
{
|
|
public static class UnityObjectBaseExtensions
|
|
{
|
|
public static string GetOriginalName(this IUnityObjectBase _this)
|
|
{
|
|
if (_this is INamed named)
|
|
{
|
|
return named.Name;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception($"Unable to get name for {_this.ClassID}");
|
|
}
|
|
}
|
|
|
|
public static string? TryGetName(this IUnityObjectBase _this)
|
|
{
|
|
return (_this as INamed)?.Name;
|
|
}
|
|
|
|
public static string GetLogString(this IUnityObjectBase asset)
|
|
{
|
|
string? name = asset.TryGetName();
|
|
if (name == null)
|
|
{
|
|
return $"{asset.ClassID}_{asset.PathID}";
|
|
}
|
|
else
|
|
{
|
|
return $"{asset.ClassID}_{asset.PathID}({name})";
|
|
}
|
|
}
|
|
}
|
|
}
|