diff --git a/MiraAPI/Utilities/Assets/SpriteTools.cs b/MiraAPI/Utilities/Assets/SpriteTools.cs index 5d438de..667d0c9 100644 --- a/MiraAPI/Utilities/Assets/SpriteTools.cs +++ b/MiraAPI/Utilities/Assets/SpriteTools.cs @@ -11,12 +11,13 @@ namespace MiraAPI.Utilities.Assets; public static class SpriteTools { /// - /// Load a sprite from a resource path. + /// Loads and returns a texture from a resource path using the specified assembly. /// - /// The path to the resource. - /// A sprite made from the resource. - /// The resource cannot be found. - public static Sprite LoadSpriteFromPath(string resourcePath, Assembly assembly, float pixelsPerUnit) + /// The path to the resource within the assembly. + /// The assembly from which to load the resource. + /// A object loaded from the specified resource path. + /// Thrown when the resource cannot be found in the specified assembly. + public static Texture2D LoadTextureFromResourcePath(string resourcePath, Assembly assembly) { var tex = new Texture2D(1, 1, TextureFormat.ARGB32, false); var myStream = assembly.GetManifestResourceStream(resourcePath); @@ -31,6 +32,19 @@ public static class SpriteTools } tex.name = resourcePath; + return tex; + } + + /// + /// Loads and returns a from a resource path using the specified assembly. + /// + /// The path to the resource within the assembly. + /// The assembly from which to load the resource. + /// The number of pixels per unit for the sprite. + /// A object created from the texture loaded from the specified resource path. + public static Sprite LoadSpriteFromPath(string resourcePath, Assembly assembly, float pixelsPerUnit) + { + var tex = LoadTextureFromResourcePath(resourcePath, assembly); var sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f), pixelsPerUnit); sprite.name = resourcePath; return sprite;