I really want to be able to randomly select from a set of predefined text strings at runtime, and then project a material including that text as a light function.
Is there any way to do this, preferably through Blueprints? If not I can just bake each one into a big texture and select the text based on UV coordinates, but being able to type whatever I want right into a parameterized field seems so much more elegant.
There is a Render to Texture feature that can be used to create textures from strings. Unfortunately, it’s only available via c++ at the moment.
If the strings are predefined and you are not familiar with c++ I might recommend going with the uv approach.
A material function called debugScalarValues does something similar. It can be found in the material functions folder here: MaterialFunction’/Engine/Functions/Engine_MaterialFunctions02/Utility/DebugScalarValues.DebugScalarValues’. It manipulates the meshes uvs to display the correct n digit number with only a few texture samples.
If you’re going to make something a bit more straight forward and only have a few strings to display than the “debug scalar value” approach may be overkill. In that case you could create a much simpler version of the same shader to pick from a series of strings that were stored in a texture.
Here is some info regarding the c++ tools I was mentioning earlier:
UE4: Canvas Render Targets
There is a new C++ class called CanvasRenderTarget2D.
You can use it to create render targets that are updated every frame by some C++ code that draws to it using the Canvas interface.
You can then apply the render target texture to 3D models in your scene.
This gives you a way achieve in “in-world” UI without using TextRenderComponents.