update
This commit is contained in:
28
Packages/app.rive.rive-unity/Editor/ImageAssetImporter.cs
Normal file
28
Packages/app.rive.rive-unity/Editor/ImageAssetImporter.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user