#Use custom imported asset as texture property
1 messages · Page 1 of 1 (latest)
You are using a scripted importer right?
If so, then I think using ctx.AddObjectToAsset followed by ctx.SetMainObject is what you want.
What is SourceModel?
Unity does not support deriving custom classes from Object
It only supports MonoBehavior and ScriptableObject
The reason is that all other types expect a C++ class matching the C# one.
Simply inheriting from ScriptableObject will do what you want
You also need to use ScriptableObject.CreateInstance to create an instance, not new
@dusky kindle right I jsut tested and it works fine.
using UnityEditor.AssetImporters;
using UnityEngine;
[ScriptedImporter(0, "mdl")]
public class SourceMDLImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
var model = ScriptableObject.CreateInstance<SourceModel>();
ctx.AddObjectToAsset("main model", model);
ctx.SetMainObject(model);
}
}
Put that inside of an Editor folder