- Home /
What is EditorOnly tag used for?
Looking at the documentation for tags, I stumbled across the predefined tag "EditorOnly". Does it hold any special attributes such as "MainCamera" does for the main camera? What is the intent of this tag?
We used the tag for background images so we could setup our UI. They exist within the UI hierarchy and are tagged EditorOnly. While profiling iPad Air 2 in Development build, we recognised their graphics being put into RA$$anonymous$$.
Are there requirements to be met like "only root Gameobjects will be removed", or "the gameobject has to be active", or "the gameobject must be available in the scene on build?"
Answer by Meltdown · Dec 21, 2010 at 02:03 PM
Sometimes you may want to draw some waypoints or markers in the editor, to make it easier to debug your game. for instance if you want a patrolling guard to walk a route, you may want render the route in debug mode as a set of lines, and confirm the guard is walking along it, obviously you don't want these lines appearing in your game, so you can set them as EditorOnly.
Oh I see! Objects with the tag are removed when building the game. I was only trying it out in the editor and I couldn't see any effects. I just tried it out, things with the tag are removed automatically when building.
Answer by eiked · Mar 26, 2019 at 12:50 PM
I've made a test with Unity 2018.2.20f1 and game objects tagged with "EditorOnly" are being removed from compiled scenes. Prefabs remain however untouched and will contain game objects with this tag in the compiled game as well.
Answer by Zib Redlektab · Dec 21, 2010 at 01:05 PM
I would assume that the tag is supposed to be used for objects that should never appear in an exported game, like guide objects or the like. However, minimal testing makes it seem like no, it doesn't hold any special attributes. It's up to you to implement its purpose.
Actually, it turns out that objects tagged with EditorOnly are removed when building the game.
Documentation says these objects are removed when building, but I've not found this to happen in practise, for any platform I've tested. I have to run a script that says:
foreach (GameObject go in GameObject.FindGameObjectsWithTag("EditorOnly")) Destroy(go);
(Generally foreach should be avoided, but this only runs once at the start of the scene, so simplicity is more important than efficiency here.)
does not require a script to do this, the current 5.2 build removes the gameobjects automatically from your build
Your answer
![](https://koobas.hobune.stream/wayback/20220613091914im_/https://answers.unity.com/themes/thub/images/avi.jpg)