Files
BABA_YAGA/Packages/app.rive.rive-unity/Editor/ImageAssetImporter.cs
2026-05-19 17:39:03 +07:00

29 lines
1.0 KiB
C#

using UnityEngine;
using UnityEditor.AssetImporters;
namespace Rive
{
internal static class ImageOobAssetExtensions
{
public const string PNG = "png";
public const string JPG = "jpg";
public const string JPEG = "jpeg";
public const string WEBP = "webp";
public static readonly string[] ImageExtensions = new[] { PNG, JPG, JPEG, WEBP };
}
[ScriptedImporter(2, new string[] { ImageOobAssetExtensions.WEBP }, new string[] { ImageOobAssetExtensions.PNG, ImageOobAssetExtensions.JPG, ImageOobAssetExtensions.JPEG, ImageOobAssetExtensions.WEBP })]
public class ImageAssetImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
byte[] bytesToAssign = System.IO.File.ReadAllBytes(ctx.assetPath);
ImageOutOfBandAsset file = OutOfBandAsset.Create<ImageOutOfBandAsset>(bytesToAssign);
ctx.AddObjectToAsset("rive-image", file);
ctx.SetMainObject(file);
}
}
}