AddManuallyUpdated

Introduction

The AddManuallyUpdated method adds the argument Text to the TextManager to be drawn. A manually updated Text does not have any of its ever-frame behavior performed by the TextManager, so changes to the Text must be manually applied.

Manually updated Texts can be used in situations where a Text does not change after it has been created, or where only a small subset of properties change every frame, so manual updating can selectively update these variables for a performance boost.

Code Example

The following code shows how to create 1000 manually updated Texts. It uses a large number of Text instances to show the performance benefit of using manually updated Texts.

On an i7 (in 2018) this code renders at around 464 frames per second, as shown in the following screenshot:

By contrast, calling  AddText instead of  AddManuallyUpdated  results in a framerate of around 150 frames per second.

ForceUpdateDependencies

The  ForceUpdateDependencies  call is required to update a  Text  object according to its properties so that it renders properly. Normally this call is not needed because the engine calls it automatically, but in the code above we must call it after setting all properties to apply the values to the Text object.

Notice that any changes made to the Text object after calling  ForceUpdateDependencies  will not apply on manually-updated  Text  instances. For example, changing the  DisplayText  after calling  ForceUpdateDependencies  will not change the string that the  Text  object is displaying.

UpdateInternalRenderingVariables

FlatRedBall introduced a new method to the Text object:  UpdateInternalRenderingVariables . This function will update the internal rendering values just like ForceUpdateDependencies without also updating the object according to its parent’s position and rotation. Using UpdateInternalRenderingVariables  can be slightly faster if the Text being updated is not attached to another object (such as an entity).