PixelCrushers.DialogueSystem.Tools Class Reference

A static class of general purpose functions used by the Dialogue System. More...

Static Public Member Functions

static void DeprecationWarning (MonoBehaviour mb, string extraInfo=null)
 
static bool IsPrefab (GameObject go)
 Determines if a GameObject reference is a non-instantiated prefab or a scene object.
 
static byte HexToByte (string hex)
 Utility function to convert a hex string to byte value.
 
static bool IsNumber (object o)
 Determines whether an object is a numeric type.
 
static int StringToInt (string s)
 Converts a string to an int.
 
static float StringToFloat (string s)
 Converts a string to a float, culture invariant (i.e., uses '.
 
static bool StringToBool (string s)
 Converts a string to a bool.
 
static bool IsStringNullOrEmptyOrWhitespace (string s)
 Determines if a string is null, empty or whitespace.
 
static string GetAllAfterSlashes (string s)
 Returns the remainder of a string after all forward slashes, or the enter string if it doesn't contain any forward slashes.
 
static string GetObjectName (UnityEngine.Object o)
 Gets the name of the object, or null if the object is null.
 
static string GetGameObjectName (Component c)
 Gets the name of a component's GameObject.
 
static string GetFullName (GameObject go)
 Gets the full name of a GameObject, following the hierarchy down from the root.
 
static Transform Select (params Transform[] args)
 Returns the first non-null argument.
 
static MonoBehaviour Select (params MonoBehaviour[] args)
 Returns the first non-null argument.
 
static void SendMessageToEveryone (string message)
 Sends a message to all GameObjects in the scene.
 
static void SendMessageToEveryone (string message, string arg)
 Sends a message to all GameObjects in the scene.
 
static IEnumerator SendMessageToEveryoneAsync (string message, int gameObjectsPerFrame)
 Sends a message to all GameObjects in the scene in batches.
 
static void SetGameObjectActive (Component component, bool value)
 Sets the component's game object active or inactive.
 
static void SetGameObjectActive (GameObject gameObject, bool value)
 Sets a game object active or inactive.
 
static bool ApproximatelyZero (float x)
 Checks if a float value is approximately zero (accounting for rounding error).
 
static Color WebColor (string colorCode)
 Converts a web color string to a Color.
 
static string ToWebColor (Color color)
 Converts a color of to a web color string.
 
static string StripRichTextCodes (string s)
 
static string StripTextMeshProTags (string s)
 
static string StripRPGMakerCodes (string s)
 
static bool IsClipInAnimations (Animation animation, string clipName)
 Determines whether an animation clip is in the animation list.
 
static GameObject GameObjectHardFind (string goName)
 Finds an in-scene GameObject even if it's inactive.
 
static GameObject GameObjectHardFind (string goName, string tag)
 Finds an in-scene GameObject matching a name and tag even if it's inactive.
 
static GameObject[] FindGameObjectsWithTagHard (string tag)
 Finds all GameObjects with a specified tag, even inactive GameObjects.
 
static T GetComponentAnywhere< T > (GameObject gameObject)
 Like GetComponentInChildren(), but also searches parents.
 
static float GetGameObjectHeight (GameObject gameObject)
 Gets the height of the game object based on its collider.
 
static void SetComponentEnabled (Component component, Toggle state)
 Sets a component's enabled state to a specified state.
 
static bool IsCursorActive ()
 
static void SetCursorActive (bool value)
 
static bool IsCursorVisible ()
 
static bool IsCursorLocked ()
 
static void ShowCursor (bool value)
 
static void LockCursor (bool value)
 
static void LoadLevel (int index)
 
static void LoadLevel (string name)
 
static AsyncOperation LoadLevelAsync (string name)
 
static AsyncOperation LoadLevelAsync (int index)
 
static string RemoveHtml (string s)
 Removes HTML tags from a string.
 
static string ReplaceHtmlCharacterCodes (string s)
 Selectively replaces HTML character codes (numeric character references) that articy uses.
 

Static Public Attributes

static Regex TextMeshProTagsRegex
 

Properties

static string loadedLevelName [get]
 

Detailed Description

A static class of general purpose functions used by the Dialogue System.

Member Function Documentation

◆ ApproximatelyZero()

static bool PixelCrushers.DialogueSystem.Tools.ApproximatelyZero ( float  x)
inlinestatic

Checks if a float value is approximately zero (accounting for rounding error).

Returns
true if the value is approximately zero.
Parameters
xThe float to check.

◆ DeprecationWarning()

static void PixelCrushers.DialogueSystem.Tools.DeprecationWarning ( MonoBehaviour  mb,
string  extraInfo = null 
)
inlinestatic

◆ FindGameObjectsWithTagHard()

static GameObject[] PixelCrushers.DialogueSystem.Tools.FindGameObjectsWithTagHard ( string  tag)
inlinestatic

Finds all GameObjects with a specified tag, even inactive GameObjects.

Parameters
tagTag.
Returns
Array of GameObjects with a tag.

◆ GameObjectHardFind() [1/2]

static GameObject PixelCrushers.DialogueSystem.Tools.GameObjectHardFind ( string  goName)
inlinestatic

Finds an in-scene GameObject even if it's inactive.

Parameters
goNameName of the GameObject.
Returns
The GameObject, or null if not found.

◆ GameObjectHardFind() [2/2]

static GameObject PixelCrushers.DialogueSystem.Tools.GameObjectHardFind ( string  goName,
string  tag 
)
inlinestatic

Finds an in-scene GameObject matching a name and tag even if it's inactive.

Parameters
goNameName of the GameObject.
tagTag.
Returns
The GameObject, or null if not found.

◆ GetAllAfterSlashes()

static string PixelCrushers.DialogueSystem.Tools.GetAllAfterSlashes ( string  s)
inlinestatic

Returns the remainder of a string after all forward slashes, or the enter string if it doesn't contain any forward slashes.

◆ GetComponentAnywhere< T >()

static T PixelCrushers.DialogueSystem.Tools.GetComponentAnywhere< T > ( GameObject  gameObject)
inlinestatic

Like GetComponentInChildren(), but also searches parents.

Returns
The component, or null if not found.
Parameters
gameObjectGame object to search.
Template Parameters
TThe component type.
Type Constraints
T :Component 

◆ GetFullName()

static string PixelCrushers.DialogueSystem.Tools.GetFullName ( GameObject  go)
inlinestatic

Gets the full name of a GameObject, following the hierarchy down from the root.

Returns
The full name.
Parameters
goA GameObject.

◆ GetGameObjectHeight()

static float PixelCrushers.DialogueSystem.Tools.GetGameObjectHeight ( GameObject  gameObject)
inlinestatic

Gets the height of the game object based on its collider.

This only works if the game object has a CharacterController, CapsuleCollider, BoxCollider, or SphereCollider.

Returns
The game object height if it has a recognized type of collider; otherwise 0.
Parameters
gameObjectGame object.

◆ GetGameObjectName()

static string PixelCrushers.DialogueSystem.Tools.GetGameObjectName ( Component  c)
inlinestatic

Gets the name of a component's GameObject.

Returns
The game object name.
Parameters
cA component

◆ GetObjectName()

static string PixelCrushers.DialogueSystem.Tools.GetObjectName ( UnityEngine::Object  o)
inlinestatic

Gets the name of the object, or null if the object is null.

Returns
The object name.
Parameters
oThe object.

◆ HexToByte()

static byte PixelCrushers.DialogueSystem.Tools.HexToByte ( string  hex)
inlinestatic

Utility function to convert a hex string to byte value.

Returns
The byte value of the hex string.
Parameters
hexThe hex string (e.g., "f0").

◆ IsClipInAnimations()

static bool PixelCrushers.DialogueSystem.Tools.IsClipInAnimations ( Animation  animation,
string  clipName 
)
inlinestatic

Determines whether an animation clip is in the animation list.

Returns
true if the clip is in the animation list.
Parameters
animationThe legacy Animation component.
clipNameThe clip name.

◆ IsCursorActive()

static bool PixelCrushers.DialogueSystem.Tools.IsCursorActive ( )
inlinestatic

◆ IsCursorLocked()

static bool PixelCrushers.DialogueSystem.Tools.IsCursorLocked ( )
inlinestatic

◆ IsCursorVisible()

static bool PixelCrushers.DialogueSystem.Tools.IsCursorVisible ( )
inlinestatic

◆ IsNumber()

static bool PixelCrushers.DialogueSystem.Tools.IsNumber ( object  o)
inlinestatic

Determines whether an object is a numeric type.

Returns
true if the object is a numeric type; otherwise, false.
Parameters
oThe object to check.

◆ IsPrefab()

static bool PixelCrushers.DialogueSystem.Tools.IsPrefab ( GameObject  go)
inlinestatic

Determines if a GameObject reference is a non-instantiated prefab or a scene object.

If go is null, active in the scene, or its parent is active in the scene, it's considered a scene object. Otherwise this method searches all scene objects for matches. If it doesn't find any matches, this is a prefab.

Returns
true if a prefab; otherwise, false.
Parameters
goGameObject.

◆ IsStringNullOrEmptyOrWhitespace()

static bool PixelCrushers.DialogueSystem.Tools.IsStringNullOrEmptyOrWhitespace ( string  s)
inlinestatic

Determines if a string is null, empty or whitespace.

Returns
true if the string null, empty or whitespace; otherwise, false.
Parameters
sThe string to check.

◆ LoadLevel() [1/2]

static void PixelCrushers.DialogueSystem.Tools.LoadLevel ( int  index)
inlinestatic

◆ LoadLevel() [2/2]

static void PixelCrushers.DialogueSystem.Tools.LoadLevel ( string  name)
inlinestatic

◆ LoadLevelAsync() [1/2]

static AsyncOperation PixelCrushers.DialogueSystem.Tools.LoadLevelAsync ( int  index)
inlinestatic

◆ LoadLevelAsync() [2/2]

static AsyncOperation PixelCrushers.DialogueSystem.Tools.LoadLevelAsync ( string  name)
inlinestatic

◆ LockCursor()

static void PixelCrushers.DialogueSystem.Tools.LockCursor ( bool  value)
inlinestatic

◆ RemoveHtml()

static string PixelCrushers.DialogueSystem.Tools.RemoveHtml ( string  s)
inlinestatic

Removes HTML tags from a string.

Returns
The string without HTML.
Parameters
sThe HTML-filled string.

◆ ReplaceHtmlCharacterCodes()

static string PixelCrushers.DialogueSystem.Tools.ReplaceHtmlCharacterCodes ( string  s)
inlinestatic

Selectively replaces HTML character codes (numeric character references) that articy uses.

◆ Select() [1/2]

static MonoBehaviour PixelCrushers.DialogueSystem.Tools.Select ( params MonoBehaviour[]  args)
inlinestatic

Returns the first non-null argument.

This function replaces C#'s null-coalescing operator (??), which doesn't work with component properties because, under the hood, they're always non-null.

Parameters
argsList of elements to select from.

◆ Select() [2/2]

static Transform PixelCrushers.DialogueSystem.Tools.Select ( params Transform[]  args)
inlinestatic

Returns the first non-null argument.

This function replaces C#'s null-coalescing operator (??), which doesn't work with component properties because, under the hood, they're always non-null.

Parameters
argsList of elements to select from.

◆ SendMessageToEveryone() [1/2]

static void PixelCrushers.DialogueSystem.Tools.SendMessageToEveryone ( string  message)
inlinestatic

Sends a message to all GameObjects in the scene.

Parameters
messageMessage.

◆ SendMessageToEveryone() [2/2]

static void PixelCrushers.DialogueSystem.Tools.SendMessageToEveryone ( string  message,
string  arg 
)
inlinestatic

Sends a message to all GameObjects in the scene.

Parameters
messageMessage.
argArgument.

◆ SendMessageToEveryoneAsync()

static IEnumerator PixelCrushers.DialogueSystem.Tools.SendMessageToEveryoneAsync ( string  message,
int  gameObjectsPerFrame 
)
inlinestatic

Sends a message to all GameObjects in the scene in batches.

Parameters
messageMessage.
gameObjectsPerFrameNumber of GameObjects to handle each frame.

◆ SetComponentEnabled()

static void PixelCrushers.DialogueSystem.Tools.SetComponentEnabled ( Component  component,
Toggle  state 
)
inlinestatic

Sets a component's enabled state to a specified state.

Parameters
componentComponent to set.
stateState to set the component to (true, false, or flip).

◆ SetCursorActive()

static void PixelCrushers.DialogueSystem.Tools.SetCursorActive ( bool  value)
inlinestatic

◆ SetGameObjectActive() [1/2]

static void PixelCrushers.DialogueSystem.Tools.SetGameObjectActive ( Component  component,
bool  value 
)
inlinestatic

Sets the component's game object active or inactive.

Parameters
componentComponent.
valueThe value to set.

◆ SetGameObjectActive() [2/2]

static void PixelCrushers.DialogueSystem.Tools.SetGameObjectActive ( GameObject  gameObject,
bool  value 
)
inlinestatic

Sets a game object active or inactive.

Parameters
gameObjectGameObject.
valueThe value to set.

◆ ShowCursor()

static void PixelCrushers.DialogueSystem.Tools.ShowCursor ( bool  value)
inlinestatic

◆ StringToBool()

static bool PixelCrushers.DialogueSystem.Tools.StringToBool ( string  s)
inlinestatic

Converts a string to a bool.

Returns
The bool, or false if the string can't be parsed to a bool.
Parameters
sThe string.

◆ StringToFloat()

static float PixelCrushers.DialogueSystem.Tools.StringToFloat ( string  s)
inlinestatic

Converts a string to a float, culture invariant (i.e., uses '.

' for decimal point).

Returns
The float, or 0 if the string can't be parsed to a float.
Parameters
sThe string.

◆ StringToInt()

static int PixelCrushers.DialogueSystem.Tools.StringToInt ( string  s)
inlinestatic

Converts a string to an int.

Returns
The int, or 0 if the string can't be parsed to an int.
Parameters
sThe string.

◆ StripRichTextCodes()

static string PixelCrushers.DialogueSystem.Tools.StripRichTextCodes ( string  s)
inlinestatic

◆ StripRPGMakerCodes()

static string PixelCrushers.DialogueSystem.Tools.StripRPGMakerCodes ( string  s)
inlinestatic

◆ StripTextMeshProTags()

static string PixelCrushers.DialogueSystem.Tools.StripTextMeshProTags ( string  s)
inlinestatic

◆ ToWebColor()

static string PixelCrushers.DialogueSystem.Tools.ToWebColor ( Color  color)
inlinestatic

Converts a color of to a web color string.

Returns
The web RGB-format color code of the format "\#rrggbb".
Parameters
colorColor.

◆ WebColor()

static Color PixelCrushers.DialogueSystem.Tools.WebColor ( string  colorCode)
inlinestatic

Converts a web color string to a Color.

Returns
The color.
Parameters
colorCodeA web RGB-format color code of the format "\#rrggbb", where rr, gg, and bb are hexadecimal values (e.g., #ff0000 for red).

Member Data Documentation

◆ TextMeshProTagsRegex

Regex PixelCrushers.DialogueSystem.Tools.TextMeshProTagsRegex
static
Initial value:
= new Regex(@"<[Bb]>|</[Bb]>|<[Ii]>|</[Ii]>|<color=[#]?\w+>|<color=""\w+"">|</color>|<#\w+>|" +
@"<align=\w+>|</align>|<font=[^>]+>|</font>|<indent=\w+\%>|<indent=\w+>|</indent>|" +
@"<line-height=\w+%>|<line-height=\w+>|</line-height>|<line-indent=\w+\%>|<line-ident=\w+>|</line-ident>|" +
@"<link=""[^""]+"">|</link>|<lowercase>|</lowercase>|<uppercase>|</uppercase>|" +
@"<smallcaps>|</smallcaps>|<margin=.+?>|<margin-?\w+=.+?>|</margin>|<mark=#\w+>|</mark>|" +
@"<nobr>|</nobr>|<size=\w+\%>|<size=\w+>|</size>|<sprite=.+?>|<[Ss]>|</[Ss]>|<[Uu]>|</[Uu]>|" +
@"<sup>|</sup>|<sub>|</sub>|<p>|</p>|<\\/p>")

Property Documentation

◆ loadedLevelName

string PixelCrushers.DialogueSystem.Tools.loadedLevelName
staticget

The documentation for this class was generated from the following file: