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.TextureTypeE = TextureImporterType.Sprite;
|
||||||
}
|
}
|
||||||
importer.SpriteExtrude = sprite.Extrude;
|
importer.SpriteExtrude = sprite.Extrude;
|
||||||
importer.SpriteMeshType = (int)sprite.RD.GetMeshType();
|
importer.SpriteMeshType = (int)sprite.RD.MeshType;
|
||||||
importer.Alignment = (int)SpriteAlignment.Custom;
|
importer.Alignment = (int)SpriteAlignment.Custom;
|
||||||
if (importer.Has_SpritePivot() && sprite.Has_Pivot())
|
if (importer.Has_SpritePivot() && sprite.Has_Pivot())
|
||||||
{
|
{
|
||||||
@ -121,7 +121,7 @@ public class TextureExportCollection : AssetsExportCollection<ITexture2D>
|
|||||||
importer.TextureTypeE = TextureImporterType.Sprite;
|
importer.TextureTypeE = TextureImporterType.Sprite;
|
||||||
importer.SpriteModeE = SpriteImportMode.Multiple;
|
importer.SpriteModeE = SpriteImportMode.Multiple;
|
||||||
importer.SpriteExtrude = sprite.Extrude;
|
importer.SpriteExtrude = sprite.Extrude;
|
||||||
importer.SpriteMeshType = (int)sprite.RD.GetMeshType();
|
importer.SpriteMeshType = (int)sprite.RD.MeshType;
|
||||||
importer.Alignment = (int)SpriteAlignment.Center;
|
importer.Alignment = (int)SpriteAlignment.Center;
|
||||||
if (importer.Has_SpritePivot())
|
if (importer.Has_SpritePivot())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,8 +5,14 @@ namespace AssetRipper.SourceGenerated.Extensions;
|
|||||||
|
|
||||||
public static class SpriteAtlasDataExtensions
|
public static class SpriteAtlasDataExtensions
|
||||||
{
|
{
|
||||||
public static bool IsPacked(this ISpriteAtlasData data) => (data.SettingsRaw & 1) != 0;
|
extension(ISpriteAtlasData data)
|
||||||
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 bool IsPacked => (data.SettingsRaw & 1) != 0;
|
||||||
public static SpriteMeshType GetMeshType(this ISpriteAtlasData data) => (SpriteMeshType)(data.SettingsRaw >> 6 & 0x1);
|
|
||||||
|
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>
|
/// <param name="rotation"></param>
|
||||||
private static void GetPacking(ISprite sprite, ISpriteAtlas? atlas, out bool isPacked, out SpritePackingRotation rotation)
|
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;
|
||||||
isPacked = atlasData.IsPacked();
|
rotation = atlasData.PackingRotation;
|
||||||
rotation = atlasData.GetPackingRotation();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isPacked = sprite.RD.IsPacked();
|
isPacked = sprite.RD.IsPacked;
|
||||||
rotation = sprite.RD.GetPackingRotation();
|
rotation = sprite.RD.PackingRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,20 +5,14 @@ namespace AssetRipper.SourceGenerated.Extensions;
|
|||||||
|
|
||||||
public static class SpriteRenderDataExtensions
|
public static class SpriteRenderDataExtensions
|
||||||
{
|
{
|
||||||
public static bool IsPacked(this ISpriteRenderData spriteRenderData) => (spriteRenderData.SettingsRaw & 1) != 0;
|
extension(ISpriteRenderData data)
|
||||||
|
|
||||||
public static SpritePackingMode GetPackingMode(this ISpriteRenderData spriteRenderData)
|
|
||||||
{
|
{
|
||||||
return (SpritePackingMode)(spriteRenderData.SettingsRaw >> 1 & 1);
|
public bool IsPacked => (data.SettingsRaw & 1) != 0;
|
||||||
}
|
|
||||||
|
|
||||||
public static SpritePackingRotation GetPackingRotation(this ISpriteRenderData spriteRenderData)
|
public SpritePackingMode PackingMode => (SpritePackingMode)(data.SettingsRaw >> 1 & 1);
|
||||||
{
|
|
||||||
return (SpritePackingRotation)(spriteRenderData.SettingsRaw >> 2 & 0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SpriteMeshType GetMeshType(this ISpriteRenderData spriteRenderData)
|
public SpritePackingRotation PackingRotation => (SpritePackingRotation)(data.SettingsRaw >> 2 & 0xF);
|
||||||
{
|
|
||||||
return (SpriteMeshType)(spriteRenderData.SettingsRaw >> 6 & 0x1);
|
public SpriteMeshType MeshType => (SpriteMeshType)(data.SettingsRaw >> 6 & 0x1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user