- Home /
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!
Answer by ifdef_ben · Apr 21, 2016 at 05:16 PM
Humm okay it turns out the solution was to use ScriptableObject instead of Monobehavior objects.. Thanks anyways guys!
Your answer
Follow this Question
Related Questions
ScriptableObject with Custom Editor resetting data in inspector 1 Answer
Null reference exceptions when using a Custom Editor 0 Answers
Using a custom editor script with a prefab instance causes my variables to reset on Play 3 Answers
EditorWindow: How to Serialize variables after PLay 1 Answer
How can i get SerializedProperty from UnityEvent which in List. Sorry for my Eng. 2 Answers