I simply write in ScriptedImporter
:
var t = new LuaScriptAsset(content);
ctx.AddObjectToAsset("Content", t);
where LuaScriptAsset is:
public class LuaScriptAsset : TextAsset { ... }
Unity looks not recognize the type “LuaScriptAsset”.
In MonoBehaviour
script I write
public LuaScriptAsset script;
I can’t drag my script asset to the object field in inspector; but using TextAsset
could do.
I don’t think you can extend the TextAsset class in this way, just like you can’t extend other Unity’s built-in classes (such as Collider). There are only few classes that derive from UnityEngine.Object that you can extend further (and have them properly used by the engine), such as MonoBehaviour, ScriptableObject and those derived from them (such as EditorWindow and StateMachineBehaviour).
If you want to create a custom asset type, start from ScriptableObject, if you want to create a custom component, start from MonoBehaviour.