Hi,

I have some 2d objects that are built at runtime.

I want to define an area/rectangle in the editor (so I can visually see the thing) and when I run the scene, the object (e.g. some Mesh or Polygon) will be generated.

My question is the following: What's the best practices to handle this in the editor.

Does anybody use a ColorRect (easy to handle in editor, resizing, moving, etc.) and then replaces it with something else in code during runtime?

I will try to create a scene where a ColorRect is the root element. It will have an attached script that will create the 'real' objects at runtime but also replace the ColorRect with a Polygon (if that's possible at runtime).
Else I'll have to find another solution.

I can't have a scene with a Node2D as root with an ColorRect attached to it as child node because then the handling of this scene in another scene will get cumbersome (regarding resizing, moving).

Has anybody tried to do something similar and found a good solution? (I wouldn't want to build some editor thingy. I think that would get too complicated.

Thanks for any responses.

Cheers

  • xyz replied to this.

    randomspeech You can run the script in editor by adding @tool at the first line. In the script you can determine if it's running in the editor by calling Engine.is_editor_hint() end generate any type of preview.