+2 votes

Hello Everyone,

I am looking into creating a new UI control in C++. I know simple custom controls can be GDScript-ed, but this question is about C++ modules.

I have read the Custom Modules section and I am now looking for further advise.

The docs say, "As you see, it’s really easy to develop Godot in C++. Just write your stuff normally and remember to 'macro, bind, etc' ".

I can see that approach working for modules that are not tied to Godot; they can be fully written and tested outside Godot first, then incorporated as the docs describe.

But what about developing new UI components in C++? It seems you would have to re-link the entire project each time you want to check your work, which would really slow things down.

So, my questions are...

  1. Am I way off base here and just don't understand what I'm talking
    about?
  2. Does anyone know of a simplified way to develop for the UI system
    without having to write it against the entire Godot source?
  3. Is there a minimal project somewhere that would allow for
    faster development. Perhaps that only contains minimal core and
    rendering features?

Thanks for you help, and patients for my long-winded questions.

in Engine by (78 points)

1 Answer

0 votes

If you write your UI components as a C++ module, you will have to compile your changes everytime. This may not slow things down that much, but you may prefer to prototype your Control in GDScript first and then move to C++ (only if there is a good reason to do so, like performance issues).

I guess the simpler example of a Control in C++ is Panel, which only draws a rect. Another simple one is ProgressBar which has methods binding.

EDIT: And, of course, don't forget to read the docs about writing custom modules in C++ :P

by (488 points)

Thanks for your help.

It is mostly the build times that I'm concerned about.

I don't know how I would create a custom control in c++ without compiling against the entire engine, which can take a minute or more just to re-link with my module after the initial 10min build. Meaning every time I want to run my module during development, I will have to wait a minute or more to view the changes, which will drive me crazy.

So, the only way I know to test a custom control is from within the editor.

Am I correct about this assumption, or is there a way to write and test custom Controls in C++ outside of Godot, and then only compile them into the engine when they are done?
(I assume not)

Thanks again, I really do appreciate your time.

No, there is no way to do that. You have to compile the whole thing. But if you already compiled the engine before, the next time it should only compile your changes.
Still I recommend you to first prototype your Control in GDScript and then translate it to C++.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.