Introducing a new text utility, useful for quickly setting up simple effects with your text objects! Made for UPBGE 0.2.5, but it may work in other versions (?)
I enjoyed using BGText, but it used pre-rendered image textures instead of vector fonts. Additionally, it didn’t really work well with non-monospaced fonts, so I made VectorText to help with that! It has many of the same features as BGText, but works with the default vector-based Text objects. This does mean that text will be flat-shaded, however. Additionally, it still is missing some of BGText’s features such as horizontal and vertical text alignment, so if you need those, check BGText out.
Please let me know if there are ways I can improve the performance/functionality of this script!
You can add these variables as necessary to the text object to enable the feature.
Run code through a text object, useful for quickly displaying variables and such.
Set the update frequency in terms of Frames Per Second instead of skipped frames (so 10.0 = updates 10 times per second)
Similarly to BGText, you can set the color of the text’s RGB with a tuple or a word.
white, red, green, blue, yellow, purple, cyan, black
(Red, Green, Blue, Alpha)
The number of characters before the text wraps. Pretty self-explanatory. To separate paragraphs, press enter twice (two line breaks)
The side to align the text to. This supports
If you use center or right align, you must use a monospace font! This is because non-monospace fonts have variable spacing and it throws off the alignment.
One of the more fun features. The actual variable type and value don’t really matter, it just needs to be on the text object. The text will reveal letter by letter based on the Update frequency.
You can reset the reveal by setting the object’s ResetReveal variable to True.
own["ResetReveal"] = True
This will make it re-reveal the text all over again.
By default, text objects have a weirdly different scale in-game engine and out of it. VectorText automatically corrects for this to a rough extent, but it may need some tweaking. The Scale feature allows you to tweak the scale of the text object. Pretty simple.
Finally, the resolution variable simply allows you to change the resolution of the text. Be careful with high resolutions! These are vector text objects so very high resolutions can eat your RAM and reduce performance.
- Make sure you have the VectorText.py script imported into your project somehow. It should be available in the text editor.
- Set up your logic bricks like so:
- The Always sensor must be named “UpdateText” and the python controller should be in module mode, running the
v2 fixes a bug with updating text.
v3 introduces a version for UPBGE 0.3 and also fixes another bug.