Last active
          March 8, 2025 16:11 
        
      - 
      
 - 
        
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
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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