Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

TextElement.SetText

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void SetText(ReadOnlySpan<char> text);

Parameters

Parameter Description
text The character span to set as the element's text content.

Description

Sets the text content without allocating a managed string.

Unlike assigning to TextElement.text, this method writes directly into an internal native buffer and defers string materialization until TextElement.text is read. A ChangeEvent<T0> of type string is raised only when listeners for value-change events exist in the element's hierarchy; when no such listeners are present, the method is fully allocation-free.


Declaration

public void SetText(char[] sourceText, int start, int length);

Parameters

Parameter Description
sourceText The source character array.
start The starting index in the array.
length The number of characters to copy.

Description

Sets the text content from a character array slice without allocating a managed string.


Declaration

public void SetText(stringBuilder sb);

Parameters

Parameter Description
sb The Text.StringBuilder whose contents to copy.

Description

Sets the text content from a Text.StringBuilder without allocating a managed string.


Declaration

public void SetText(float value, string format);

Parameters

Parameter Description
value The float value to display.
format An optional standard or custom numeric format string.

Description

Formats a float value directly into the text buffer without allocating a managed string.


Declaration

public void SetText(int value);

Parameters

Parameter Description
value The integer value to display.

Description

Formats an integer value directly into the text buffer without allocating a managed string.