From e5693e1e58d7f09b1a8355ba097235a5db77bca7 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Thu, 11 Nov 2021 10:24:15 -0800 Subject: [PATCH] feat: Allow pivot to be specified in LoadSpriteFromFile --- JotunnLib/Utils/AssetUtils.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/JotunnLib/Utils/AssetUtils.cs b/JotunnLib/Utils/AssetUtils.cs index e2fdb6bd3..4c989e5d4 100644 --- a/JotunnLib/Utils/AssetUtils.cs +++ b/JotunnLib/Utils/AssetUtils.cs @@ -54,12 +54,23 @@ public static Texture2D LoadTexture(string texturePath, bool relativePath = true /// Texture path relative to "plugins" BepInEx folder /// Texture2D loaded, or null if invalid path public static Sprite LoadSpriteFromFile(string spritePath) + { + return LoadSpriteFromFile(spritePath, Vector2.zero); + } + + /// + /// Loads a from file at runtime. + /// + /// Texture path relative to "plugins" BepInEx folder + /// The pivot to use in the resulting Sprite + /// Texture2D loaded, or null if invalid path + 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;