mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-26 08:46:47 +00:00
26 lines
749 B
C#
26 lines
749 B
C#
using System.Reflection;
|
|
using UnityEngine;
|
|
|
|
namespace MiraAPI.Utilities.Assets;
|
|
|
|
/// <summary>
|
|
/// A utility class for loading assets from embedded resources.
|
|
/// </summary>
|
|
/// <param name="path">The path to the embedded resource.</param>
|
|
/// <param name="pixelsPerUnit">The pixels per unit for the loaded sprite.</param>
|
|
public class LoadableResourceAsset(string path, float pixelsPerUnit=100f) : LoadableAsset<Sprite>
|
|
{
|
|
private readonly Assembly _assembly = Assembly.GetCallingAssembly();
|
|
|
|
/// <inheritdoc />
|
|
public override Sprite LoadAsset()
|
|
{
|
|
if (LoadedAsset)
|
|
{
|
|
return LoadedAsset!;
|
|
}
|
|
|
|
return LoadedAsset = SpriteTools.LoadSpriteFromPath(path, _assembly, pixelsPerUnit);
|
|
}
|
|
}
|