SetText
Sets the text content without allocating a managed string.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Method
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
SetText(ReadOnlySpan<char>)
Sets the text content without allocating a managed string.
public void SetText(ReadOnlySpan<char> text)
Parameters
The character span to set as the element's text content.
Remarks
Unlike assigning to _text, this method writes directly into an internal native buffer and defers string materialization until _text is read. A ChangeEvent<T> of type 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.
stringSetText(char[], int, int)
Sets the text content from a character array slice without allocating a managed string.
public void SetText(char[] sourceText, int start, int length)
Parameters
SetText(StringBuilder)
Sets the text content from a StringBuilder without allocating a managed string.
public void SetText(StringBuilder sb)
Parameters
The StringBuilder whose contents to copy.
SetText(float, string)
Formats a float value directly into the text buffer without allocating a managed string.
public void SetText(float value, string format = null)
Parameters
SetText(int)
Formats an integer value directly into the text buffer without allocating a managed string.
public void SetText(int value)
Parameters
The integer value to display.