UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Utility Systems / GameObject Editor System Completed

Utility Systems — UGTK

GameObject Editor System

Summary

Marks a GameObject as editor-only: Mn_GameObjectEditor leaves the object visible while you work in the Unity Editor and switches it off by itself in a built player. It is for the props you want on screen while designing and gone when shipping — layout guides, reference images, gizmo helpers, notes placed in the scene.


Content


Modules Dependencies

None. One MonoBehaviour with no field and no reference.


Setup

Nothing to show in a GIF: there is no prefab, no scene, no inspector field. Add Mn_GameObjectEditor to any GameObject that must exist only while editing, and leave that object active in the scene.


How To Use

There is no API and nothing to configure — the whole behaviour is one #if !UNITY_EDITOR branch in Update that calls SetActive(false) on its own GameObject. In the editor the branch is compiled out and the object stays as you left it.

Two things worth knowing before relying on it:

For an object that has to disappear from the build entirely, Unity's own EditorOnly tag is the better tool; this component is the right one when you want the object present at runtime (so references to it keep resolving) but off.


Testing Scene

Open Debug/GameObjectEditorScene.unity. Two objects sit in front of the camera: a cube that belongs to the game, and a quad called Reference Image (editor only) carrying Mn_GameObjectEditor. The component has no runtime controls — everything is in its inspector's Editor Test Tools.

  1. Preview: hide it as the build would — the quad disappears from the Game view while the cube stays. That is exactly what a build does: Awake deactivates the object before the first frame is drawn, so it is never rendered even once.
  2. Restore visibility puts it back for editing.

The inspector also prints what the object still costs, and the warning that goes with it: the object is disabled, not stripped. Its meshes, textures and materials are still shipped inside the build. This is the right tool for guides, alignment references and debug helpers you want to see while working; it is the wrong tool for keeping placeholder art out of the package, which needs the assets genuinely excluded.


Technical Info

Path Content
Scripts/Mn_GameObjectEditor.cs The whole system: Update with the #if !UNITY_EDITOR branch that deactivates its own GameObject

No public API, no serialized field.


© 2026 Marcello De Bonis. All rights reserved