mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Fix an exception when calling GetPacking
This also refactors classes to use extension properties for ISpriteAtlasData and ISpriteRenderData
This commit is contained in:
parent
1362f35200
commit
3124e0599a
@ -97,7 +97,7 @@ public class TextureExportCollection : AssetsExportCollection<ITexture2D>
|
||||
importer.TextureTypeE = TextureImporterType.Sprite;
|
||||
}
|
||||
importer.SpriteExtrude = sprite.Extrude;
|
||||
importer.SpriteMeshType = (int)sprite.RD.GetMeshType();
|
||||
importer.SpriteMeshType = (int)sprite.RD.MeshType;
|
||||
importer.Alignment = (int)SpriteAlignment.Custom;
|
||||
if (importer.Has_SpritePivot() && sprite.Has_Pivot())
|
||||
{
|
||||
@ -121,7 +121,7 @@ public class TextureExportCollection : AssetsExportCollection<ITexture2D>
|
||||
importer.TextureTypeE = TextureImporterType.Sprite;
|
||||
importer.SpriteModeE = SpriteImportMode.Multiple;
|
||||
importer.SpriteExtrude = sprite.Extrude;
|
||||
importer.SpriteMeshType = (int)sprite.RD.GetMeshType();
|
||||
importer.SpriteMeshType = (int)sprite.RD.MeshType;
|
||||
importer.Alignment = (int)SpriteAlignment.Center;
|
||||
if (importer.Has_SpritePivot())
|
||||
{
|
||||
|
||||
@ -5,8 +5,14 @@ namespace AssetRipper.SourceGenerated.Extensions;
|
||||
|
||||
public static class SpriteAtlasDataExtensions
|
||||
{
|
||||
public static bool IsPacked(this ISpriteAtlasData data) => (data.SettingsRaw & 1) != 0;
|
||||
public static SpritePackingMode GetPackingMode(this ISpriteAtlasData data) => (SpritePackingMode)(data.SettingsRaw >> 1 & 1);
|
||||
public static SpritePackingRotation GetPackingRotation(this ISpriteAtlasData data) => (SpritePackingRotation)(data.SettingsRaw >> 2 & 0xF);
|
||||
public static SpriteMeshType GetMeshType(this ISpriteAtlasData data) => (SpriteMeshType)(data.SettingsRaw >> 6 & 0x1);
|
||||
extension(ISpriteAtlasData data)
|
||||
{
|
||||
public bool IsPacked => (data.SettingsRaw & 1) != 0;
|
||||
|
||||
public SpritePackingMode PackingMode => (SpritePackingMode)(data.SettingsRaw >> 1 & 1);
|
||||
|
||||
public SpritePackingRotation PackingRotation => (SpritePackingRotation)(data.SettingsRaw >> 2 & 0xF);
|
||||
|
||||
public SpriteMeshType MeshType => (SpriteMeshType)(data.SettingsRaw >> 6 & 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
namespace AssetRipper.SourceGenerated.Extensions;
|
||||
|
||||
public static class SpriteAtlasEditorDataExtensions
|
||||
{
|
||||
}
|
||||
@ -247,16 +247,15 @@ public static class SpriteMetaDataExtensions
|
||||
/// <param name="rotation"></param>
|
||||
private static void GetPacking(ISprite sprite, ISpriteAtlas? atlas, out bool isPacked, out SpritePackingRotation rotation)
|
||||
{
|
||||
if (atlas is not null && sprite.Has_RenderDataKey())
|
||||
if (atlas is not null && sprite.Has_RenderDataKey() && atlas.RenderDataMap.TryGetValue(sprite.RenderDataKey, out ISpriteAtlasData? atlasData))
|
||||
{
|
||||
ISpriteAtlasData atlasData = atlas.RenderDataMap[sprite.RenderDataKey];
|
||||
isPacked = atlasData.IsPacked();
|
||||
rotation = atlasData.GetPackingRotation();
|
||||
isPacked = atlasData.IsPacked;
|
||||
rotation = atlasData.PackingRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
isPacked = sprite.RD.IsPacked();
|
||||
rotation = sprite.RD.GetPackingRotation();
|
||||
isPacked = sprite.RD.IsPacked;
|
||||
rotation = sprite.RD.PackingRotation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,20 +5,14 @@ namespace AssetRipper.SourceGenerated.Extensions;
|
||||
|
||||
public static class SpriteRenderDataExtensions
|
||||
{
|
||||
public static bool IsPacked(this ISpriteRenderData spriteRenderData) => (spriteRenderData.SettingsRaw & 1) != 0;
|
||||
|
||||
public static SpritePackingMode GetPackingMode(this ISpriteRenderData spriteRenderData)
|
||||
extension(ISpriteRenderData data)
|
||||
{
|
||||
return (SpritePackingMode)(spriteRenderData.SettingsRaw >> 1 & 1);
|
||||
}
|
||||
public bool IsPacked => (data.SettingsRaw & 1) != 0;
|
||||
|
||||
public static SpritePackingRotation GetPackingRotation(this ISpriteRenderData spriteRenderData)
|
||||
{
|
||||
return (SpritePackingRotation)(spriteRenderData.SettingsRaw >> 2 & 0xF);
|
||||
}
|
||||
public SpritePackingMode PackingMode => (SpritePackingMode)(data.SettingsRaw >> 1 & 1);
|
||||
|
||||
public static SpriteMeshType GetMeshType(this ISpriteRenderData spriteRenderData)
|
||||
{
|
||||
return (SpriteMeshType)(spriteRenderData.SettingsRaw >> 6 & 0x1);
|
||||
public SpritePackingRotation PackingRotation => (SpritePackingRotation)(data.SettingsRaw >> 2 & 0xF);
|
||||
|
||||
public SpriteMeshType MeshType => (SpriteMeshType)(data.SettingsRaw >> 6 & 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user