Skip to content

Instantly share code, notes, and snippets.

@MattRix
Last active March 8, 2025 16:11
Show Gist options
  • Save MattRix/2f4f3911fe388aedb5cdaa7d40b1273e to your computer and use it in GitHub Desktop.
Save MattRix/2f4f3911fe388aedb5cdaa7d40b1273e to your computer and use it in GitHub Desktop.
An example of a really simple asset importer that just reads in text files with a custom .omni extension
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor.AssetImporters;
using System.IO;
[ScriptedImporter(1, "omni")]
public class OmniAssetImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
var asset = ScriptableObject.CreateInstance<OmniAsset>();
asset.text = File.ReadAllText(ctx.assetPath);
ctx.AddObjectToAsset("main obj", asset);
ctx.SetMainObject(asset);
}
}
#endif
public class OmniAsset : ScriptableObject
{
public string text = "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment