Unity Custom Editor: Temporary objects

I am writing a custom editor for a feature in the game. During the course of using this editor, it creates several temporary gameObjects to help with visualization in the Scene viewport.

Questions:

  1. Can I somehow hide these temporary objects from appearing in the Hierarchy tab? I want to see them only in the Scene viewport.
  2. If the user saves the project/scene from Unity menu, all the temporary objects are also saved. How do I prevent this?

I think you can use Object.hideFlags
and it looks like HideFlags.HideAndDontSave would suit what you need “A combination of not shown in the hierarchy and not saved to to scenes.”

I believe it is used like this:

Object.hideFlags = HideFlags.HideAndDontSave;

though I’m not certain of that.

Hope that helps,

Scribe

I don’t think you can hide objects in the hierarchy pannel. However, you can use a parent to make sure it doesn’t take to much place.

About the save thing, you need to destroy them all before the scene is saved, but you don’t want the user to take care of it, is that correct ? Maybe you can try this, but I’m not quite sure.