Some more editor scripting questions

Hi,

I have a few questions about editor scripting

  • Is it possible to create a gameobject that isn’t serialized at all? It’s because I want to draw a preview object somewhere, but this shouldn’t end up in the builds
  • Is it possible to have a field that is serialized in the scene (so it is saved) but it won’t end it up in the build (for similar reasons)?
  • Is there a way to detect when an Editor window is opened or closed?

Thanks!

The ‘EditorOnly’ tag might do what you need. (Not sure about excluding specific fields from the build though, at least not off the top of my head.)

Check the docs. OnEnable(), OnDisable(), and OnDestroy() (among others) might be of interest.

Thanks for your reply.
OnEnable etc only work in EditorWindows though, and not in Editors…

I thought you wanted to detect when an editor window had opened or closed? (I guess I must have misunderstood…)

Ah, sorry, my bad, an Editor window, not an EditorWindow :slight_smile:
So basically when you start inspecting a gameobject that has a custom editor. Does that make sense?

Oh, ok. (I think the term ‘editor window’ is usually used to refer to windows specifically, while the term ‘inspector’ is used for the inspector.)

For that, try OnEnable() and OnDisable() and see if they do what you want.

Right. Weird, I checked the manual 3 times and didn’t see it. Thanks!
But it’s 8am here and I haven’t slept yet so that may be the reason :slight_smile: