How to get rich text into the world, parented to a game object?

I am new to Defold, but not to game development. I’m working on an adventure game with an inventory system that exists in the world, not as a GUI. This is done because the objects in the inventory are game objects with sprites and collision objects, and can be dragged out of the inventory and into the world. The inventory itself isn’t a pop-up GUI, it is also a game object that can be shrunk down and put to the side. All that to say, I’m not using GUI scenes for any of my inventory system right now.

I want to change from using a text component on a game node to having rich text. The only way I know of to support rich text in Defold is to use defold-richtext, but this creates and requires using GUI elements.

I’m not against using GUI elements, however I do not know any way to have GUIs parented to game objects, tracking their movement, rotation, scaling, etc. So my question is, how can I get rich text into the world and parented to a game object? The things I have thought of and tried include:

  • Trying to parent GUI elements to a game object. I’ve never been able to get this to work, although I’ve seen some example Defold projects where it “looks like” they are doing this, but I think they are just using game objects and not GUI elements.
  • Making the GUI elements follow the game object through an elaborate use of messages telling the GUI where to move to exactly track whatever the game object does. This sounds incredibly tedious, but even if this could work, I don’t actually see how to intercept all necessary property changes to make this actually work.
  • Make the text window a viewport into a completely separate world/screen where a GUI screen lives – this seems like it should be possible and would basically be the same as parenting the GUI to my game object, but I can’t see anything in the Defold documentation on how to do something like this.
  • Generate rich text in the world some other way – is there a library that can do this besides the main defold-richtext library that I just don’t know about? The big limitation I see is that outside of the GUI API I don’t see how to get font metrics, etc. Obviously the label component does this internally somehow, but it doesn’t appear to be exposed in Lua.
  • Figure out if this X/Y problem? Is there some totally better way to accomplish what I want that doesn’t involve effectively parenting GUI nodes to game objects?

Thanks in advance for any tips! :grinning:

To get the size of text, use resource.get_text_metrics()

Are you using a camera extension? Orthographic ( is great and includes functions to convert between GO and GUI space.