Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | IlyaChernikov |
I need a Node2D component that draws a rect visible only in the editor viewport. I tried to use a CollisionShape2D but it shows ugly yellow exclamation mark icon because it has improper parent. I made it just a Node2D type and wanted to draw a rectangle myself. After I marked my class with [Tool]
attribute, everything broke because there was runtime-related logic in _Ready()
function. The only solution I found is to use editor check guard if (Engine.IsEditorHint()) return;
but it is an ugly solution for this task.
I tried to subclass my component from a tool class but it doesn’t work, probably not getting correctly registered in engine’s internal logic. Is there a convenient way to define an additional (decorating) logic to an existing component and not break the component. Mixing up tool and runtime code seems a very bad solution, IMO