Skip to content

Commit

Permalink
Merge pull request #329 from joeyparrish/asset-pivot
Browse files Browse the repository at this point in the history
feat: Allow pivot to be specified in LoadSpriteFromFile
  • Loading branch information
sirskunkalot authored Nov 11, 2021
2 parents e2b1867 + e5693e1 commit a5e3dae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion JotunnLib/Utils/AssetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ public static Texture2D LoadTexture(string texturePath, bool relativePath = true
/// <param name="spritePath">Texture path relative to "plugins" BepInEx folder</param>
/// <returns>Texture2D loaded, or null if invalid path</returns>
public static Sprite LoadSpriteFromFile(string spritePath)
{
return LoadSpriteFromFile(spritePath, Vector2.zero);
}

/// <summary>
/// Loads a <see cref="Sprite"/> from file at runtime.
/// </summary>
/// <param name="spritePath">Texture path relative to "plugins" BepInEx folder</param>
/// <param name="pivot">The pivot to use in the resulting Sprite</param>
/// <returns>Texture2D loaded, or null if invalid path</returns>
public static Sprite LoadSpriteFromFile(string spritePath, Vector2 pivot)
{
var tex = LoadTexture(spritePath);

if (tex != null)
{
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(), 100);
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), pivot);
}

return null;
Expand Down

0 comments on commit a5e3dae

Please sign in to comment.