Editable non-monobehaviour objects

Hi,

I’m working on a tool where I need to populate a custom path-finding “database” with objects that can be visualized and manipulated in the editor’s viewport and inspector.

However, all I need to do in play mode is access properties with the path-finding manager and I don’t need any code executed at all in these objects as the database does not change during the execution.

I know it would be easy to edit and visualize all of those database objects by making them inherit Monobehaviour and use either gizmos or handles and a custom inspector, but doing so would make some code run on execution. Even if I used the [ExecuteInEditMode] property or preprocessor directives to hide update functions and so at compilation, the default Monobehaviour functions would still be called in the background. As the database is expected to be rather big (probably a few thousands elements) using monobehaviour components seems like a big waste of CPU for classes that are essentially passive on execution.

I’ve tried using the [System.Serializable] property but I need to be able to make references between the database elements ( object_A is connected to object_B ) and it does not seem supported with serialized classes, but I might be wrong.

So for a quick recap, I’m looking for an efficient way to do this:

  • Visualize and edit objects with spacial properties in the scene for populating a database.
  • Be able to set object references in properties ( object_A is connected to object_B ).
  • In play mode, objects need to be completely passive as there will be a whole lot of them and I only need access to their properties.

I’m new to Unity and I might be missing some basic principles here, but I’ve been searching on this for many days now and I haven’t found any answer regarding this.

Thanks a lot for your help!

Humm okay it turns out the solution was to use ScriptableObject instead of Monobehavior objects… Thanks anyways guys!