VectorText Text Utility Release! [UPBGE 0.2.5 - 0.3+]

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!

Features

You can add these variables as necessary to the text object to enable the feature.

Run

Run code through a text object, useful for quickly displaying variables and such.

Update

image

Set the update frequency in terms of Frames Per Second instead of skipped frames (so 10.0 = updates 10 times per second)

Color

image

Similarly to BGText, you can set the color of the text’s RGB with a tuple or a word.
words: white, red, green, blue, yellow, purple, cyan, black
or tuple: (Red, Green, Blue, Alpha)

Wrap

image

The number of characters before the text wraps. Pretty self-explanatory. To separate paragraphs, press enter twice (two line breaks)

Align

image

The side to align the text to. This supports center, left, and right alignments.
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.

Reveal

image

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.
e.g. own["ResetReveal"] = True
This will make it re-reveal the text all over again.

Scale

image

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. :smiley:

Resolution

image

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.

Setup:

  1. Make sure you have the VectorText.py script imported into your project somehow. It should be available in the text editor.
  2. Set up your logic bricks like so:
  3. The Always sensor must be named “UpdateText” and the python controller should be in module mode, running the VectorText.main function.

Blend File

v2 fixes a bug with updating text.
v3 introduces a version for UPBGE 0.3 and also fixes another bug.

For UPBGE 0.2.5ish
VectorText_v3_UPBGE2.blend (1.3 MB)

For UPBGE 0.3+ish (Colors are now managed by materials, so the “Color” keyword does nothing)
VectorText_v3_UPBGE3.blend (1.4 MB)

8 Likes

Nice work! Since I don’t work anymore on BGText’s development, it’s always good to have new choices for dynamic texts in UPBGE. :tada:

1 Like

Just added a fix for a bug that prevents text from properly updating.

1 Like

A couple of updates. First, I fixed a typo that was causing some funky behavior when revealing text. Additionally, @Dumbledore adapted this script for 0.3 over at the UPBGE discord :smiley:

I’ll also add a section at the bottom of the first post with some differences.

3 Likes

It was a pleasure ! Might get back on it in order to fix the 3.0 version and add several new features as replacement of older ones that can’t work anymore. :slight_smile:

1 Like