- Home /
EditorWindow properties in Game Code
Brief description
Is it possible to expose EditorWindow properties (automatically serialized by Unity) so that they can be accessed in Game Code when compiled? Thanks
Full description
I have created a custom editor for a list of items...
public class ItemsEditor : EditorWindow
{
public List<ItemDescriptor> Items = new List<ItemDescriptor>();
// Other code...
}
I would like to copy this list in a publicly accessible static variable when running the game or compiling, but I couldn't find any way to do so...
Can you help me?
Thanks, Fabio Iotti
Answer by Jessy · Feb 13, 2013 at 03:39 PM
You can't access anything that's stored in an Editor window. It's for the Editor, not the build. Instead, store the data in Scriptable Objects in your project, and read from those objects, to the window. (Or, if you prefer, just use a custom Inspector for the Scriptable Object.) MonoBeaviours can reference Scriptable Objects.
Ok, I tried using a ScriptableObject as you suggested, but this time I failed to create a serialized singleton (avoiding to create an asset), any advice? Thanks again...
Posting your code would help. But know that a ScriptableObject either needs to be an asset, or referenced by something in a scene. In the latter case, it is serialized with the scene only.
To simplify it, I need a static List, serializing with the scene would be perfect, it should be referenced by both EditorWindow and $$anonymous$$onoBehaviour classes.
If it help, I'll post the code.
Really thanks for your availability.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092629im_/https://answers.unity.com/themes/thub/images/avi.jpg)