Class TMP_TextUtilities
Namespace: TMPro
Syntax
public static class TMP_TextUtilities
Methods
DistanceToLine(Vector3, Vector3, Vector3)
Function returning the Square Distance from a Point to a Line.
Declaration
public static float DistanceToLine(Vector3 a, Vector3 b, Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | a | |
Vector3 | b | |
Vector3 | point |
Returns
Type | Description |
---|---|
Single |
FindIntersectingCharacter(TMP_Text, Vector3, Camera, Boolean)
Function returning the index of the character at the given position (if any).
Declaration
public static int FindIntersectingCharacter(TMP_Text text, Vector3 position, Camera camera, bool visibleOnly)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | A reference to the TextMeshPro component. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which is rendering the text or whichever one might be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Boolean | visibleOnly | Only check for visible characters. |
Returns
Type | Description |
---|---|
Int32 |
FindIntersectingLine(TMP_Text, Vector3, Camera)
Function returning the line intersecting the position.
Declaration
public static int FindIntersectingLine(TMP_Text text, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | |
Vector3 | position | |
Camera | camera |
Returns
Type | Description |
---|---|
Int32 |
FindIntersectingLink(TMP_Text, Vector3, Camera)
Function returning the index of the Link at the given position (if any).
Declaration
public static int FindIntersectingLink(TMP_Text text, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | A reference to the TMP_Text component. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Returns
Type | Description |
---|---|
Int32 |
FindIntersectingWord(TMP_Text, Vector3, Camera)
Function returning the index of the word at the given position (if any).
Declaration
public static int FindIntersectingWord(TMP_Text text, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | A reference to the TMP_Text component. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Returns
Type | Description |
---|---|
Int32 |
FindNearestCharacter(TMP_Text, Vector3, Camera, Boolean)
Function to find the nearest character to position.
Declaration
public static int FindNearestCharacter(TMP_Text text, Vector3 position, Camera camera, bool visibleOnly)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | A reference to the TMP Text component. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Boolean | visibleOnly | Only check for visible characters. |
Returns
Type | Description |
---|---|
Int32 |
FindNearestCharacterOnLine(TMP_Text, Vector3, Int32, Camera, Boolean)
Function returning the nearest character to position on a given line.
Declaration
public static int FindNearestCharacterOnLine(TMP_Text text, Vector3 position, int line, Camera camera, bool visibleOnly)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | |
Vector3 | position | |
Int32 | line | |
Camera | camera | |
Boolean | visibleOnly |
Returns
Type | Description |
---|---|
Int32 |
FindNearestLine(TMP_Text, Vector3, Camera)
Function returning the line nearest to the position.
Declaration
public static int FindNearestLine(TMP_Text text, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | |
Vector3 | position | |
Camera | camera |
Returns
Type | Description |
---|---|
Int32 |
FindNearestLink(TMP_Text, Vector3, Camera)
Function returning the index of the word at the given position (if any).
Declaration
public static int FindNearestLink(TMP_Text text, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | A reference to the TMP_Text component. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Returns
Type | Description |
---|---|
Int32 |
FindNearestWord(TMP_Text, Vector3, Camera)
Function returning the index of the word at the given position (if any).
Declaration
public static int FindNearestWord(TMP_Text text, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | text | A reference to the TMP_Text component. |
Vector3 | position | |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Returns
Type | Description |
---|---|
Int32 |
GetCursorIndexFromPosition(TMP_Text, Vector3, Camera)
Function returning the index of the character whose origin is closest to the cursor.
Declaration
public static int GetCursorIndexFromPosition(TMP_Text textComponent, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | textComponent | A reference to the text object. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Returns
Type | Description |
---|---|
Int32 |
GetCursorIndexFromPosition(TMP_Text, Vector3, Camera, out CaretPosition)
Function returning the index of the character whose origin is closest to the cursor.
Declaration
public static int GetCursorIndexFromPosition(TMP_Text textComponent, Vector3 position, Camera camera, out CaretPosition cursor)
Parameters
Type | Name | Description |
---|---|---|
TMP_Text | textComponent | A reference to the text object. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
CaretPosition | cursor | The position of the cursor insertion position relative to the position. |
Returns
Type | Description |
---|---|
Int32 |
GetHashCode(String)
Returns the case insensitive hashcode for the given string.
Declaration
public static int GetHashCode(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s |
Returns
Type | Description |
---|---|
Int32 |
GetHashCodeCaseInSensitive(String)
Function which returns a simple hash code from a string converted to uppercase.
Declaration
public static uint GetHashCodeCaseInSensitive(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s | The string from which to compute the hash code. |
Returns
Type | Description |
---|---|
UInt32 | The computed hash code. |
GetSimpleHashCode(String)
Function which returns a simple hashcode from a string.
Declaration
public static int GetSimpleHashCode(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s |
Returns
Type | Description |
---|---|
Int32 |
GetSimpleHashCodeLowercase(String)
Function which returns a simple hashcode from a string converted to lowercase.
Declaration
public static uint GetSimpleHashCodeLowercase(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s |
Returns
Type | Description |
---|---|
UInt32 |
HexToInt(Char)
Function to convert Hex to Int
Declaration
public static int HexToInt(char hex)
Parameters
Type | Name | Description |
---|---|---|
Char | hex |
Returns
Type | Description |
---|---|
Int32 |
IsIntersectingRectTransform(RectTransform, Vector3, Camera)
Function used to determine if the position intersects with the RectTransform.
Declaration
public static bool IsIntersectingRectTransform(RectTransform rectTransform, Vector3 position, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
RectTransform | rectTransform | A reference to the RectTranform of the text object. |
Vector3 | position | Position to check for intersection. |
Camera | camera | The scene camera which may be assigned to a Canvas using ScreenSpace Camera or WorldSpace render mode. Set to null is using ScreenSpace Overlay. |
Returns
Type | Description |
---|---|
Boolean |
ScreenPointToWorldPointInRectangle(Transform, Vector2, Camera, out Vector3)
Method to convert ScreenPoint to WorldPoint aligned with Rectangle
Declaration
public static bool ScreenPointToWorldPointInRectangle(Transform transform, Vector2 screenPoint, Camera cam, out Vector3 worldPoint)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
Vector2 | screenPoint | |
Camera | cam | |
Vector3 | worldPoint |
Returns
Type | Description |
---|---|
Boolean |
StringHexToInt(String)
Function to convert a properly formatted string which contains an hex value to its decimal value.
Declaration
public static int StringHexToInt(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s |
Returns
Type | Description |
---|---|
Int32 |
ToLowerFast(Char)
Get lowercase version of this ASCII character.
Declaration
public static char ToLowerFast(char c)
Parameters
Type | Name | Description |
---|---|---|
Char | c |
Returns
Type | Description |
---|---|
Char |
ToUpperFast(Char)
Get uppercase version of this ASCII character.
Declaration
public static char ToUpperFast(char c)
Parameters
Type | Name | Description |
---|---|---|
Char | c |
Returns
Type | Description |
---|---|
Char |