How include in editor script another editor script

  • I have in project a nice editor for sprites from ToolKit 2d tech
  • I create ScriptableObject for collect some resources, with tk2dSprites, but the fields has simple view
  • And I need instead of one simple field with a link to display more detailed information exactly the same as in this container. So how I can integrate toolkit 2d sprite editor into my editor?

screen

Well the part of your code that doesn’t work is this:

testSprite = new tk2dSprite();

I never used that sprite toolkit but a quick google search showed that the tk2dSprite class is derived from tk2dBaseSprite which in turn is derived from MonoBehaviour. So the class is an actual component that has to be attached to a gameobject. MonoBehaviour and ScriptableObject derived types can not be created with “new”. You have to attach it to a gameobject using AddComponent (or CreateInstance in case of ScriptableObject). Maybe you want to create a new gameobject and add the tk2dSprite script to it?

testSprite = (new GameObject("testsprite")).AddComponent<tk2dSprite>();

When you create a MonoBehaviour derived type with new you should get a warning in the console that this is not possible. Also such created instances would be fake-null objects so of course you can’t create an editor for such an instance because it’s like the object got Destroy()ed