PixelCrushers.DialogueSystem.Tools Class Reference

A static class of general purpose functions used by the dialogue system. More...

Static Public Member Functions

static bool IsPrefab (GameObject go)
 Determines if a GameObject reference is a non-instantiated prefab or a scene object. More...
 
static byte HexToByte (string hex)
 Utility function to convert a hex string to byte value. More...
 
static bool IsNumber (object o)
 Determines whether an object is a numeric type. More...
 
static int StringToInt (string s)
 Converts a string to an int. More...
 
static float StringToFloat (string s)
 Converts a string to a float. More...
 
static bool StringToBool (string s)
 Converts a string to a bool. More...
 
static bool IsStringNullOrEmptyOrWhitespace (string s)
 Determines if a string is null, empty or whitespace. More...
 
static string GetObjectName (UnityEngine.Object o)
 Gets the name of the object, or null if the object is null. More...
 
static string GetGameObjectName (Component c)
 Gets the name of a component's GameObject. More...
 
static string GetFullName (GameObject go)
 Gets the full name of a GameObject, following the hierarchy down from the root. More...
 
static Transform Select (params Transform[] args)
 Returns the first non-null argument. More...
 
static MonoBehaviour Select (params MonoBehaviour[] args)
 Returns the first non-null argument. More...
 
static void SendMessageToEveryone (string message)
 Sends a message to all GameObjects in the scene. More...
 
static void SendMessageToEveryone (string message, string arg)
 Sends a message to all GameObjects in the scene. More...
 
static IEnumerator SendMessageToEveryoneAsync (string message, int gameObjectsPerFrame)
 Sends a message to all GameObjects in the scene in batches. More...
 
static void SetGameObjectActive (Component component, bool value)
 Sets the component's game object active or inactive. More...
 
static bool ApproximatelyZero (float x)
 Checks if a float value is approximately zero (accounting for rounding error). More...
 
static Color WebColor (string colorCode)
 Converts a web color string to a Color. More...
 
static string ToWebColor (Color color)
 Converts a color of to a web color string. More...
 
static string StripRichTextCodes (string s)
 
static bool IsClipInAnimations (Animation animation, string clipName)
 Determines whether an animation clip is in the animation list. More...
 
static GameObject GameObjectHardFind (string str)
 Finds an in-scene GameObject even if it's inactive, as long as the inactive GameObject is a child of an active GameObject. More...
 
static GameObject GameObjectHardFind (string str, string tag)
 
static T GetComponentAnywhere< T > (GameObject gameObject)
 Like GetComponentInChildren(), but also searches parents. More...
 
static float GetGameObjectHeight (GameObject gameObject)
 Gets the height of the game object based on its collider. More...
 
static void SetComponentEnabled (Component component, Toggle state)
 Sets a component's enabled state to a specified state. More...
 
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 Public Attributes

static int maxHardFindRecursion = 256
 Specifies how deep to recurse in GameObjectHardFind. More...
 

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)
static

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.

◆ GameObjectHardFind() [1/2]

static GameObject PixelCrushers.DialogueSystem.Tools.GameObjectHardFind ( string  str)
static

Finds an in-scene GameObject even if it's inactive, as long as the inactive GameObject is a child of an active GameObject.

Returns
The GameObject.
Parameters
strName of the GameObject.

Based on code by cawas: http://answers.unity3d.com/questions/48252/how-to-find-inactive-gameobject.html

◆ GameObjectHardFind() [2/2]

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

◆ GetComponentAnywhere< T >()

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

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)
static

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)
static

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)
static

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)
static

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)
static

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 
)
static

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 ( )
static

◆ IsCursorLocked()

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

◆ IsCursorVisible()

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

◆ IsNumber()

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

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)
static

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)
static

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)
static

◆ LoadLevel() [2/2]

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

◆ LoadLevelAsync() [1/2]

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

◆ LoadLevelAsync() [2/2]

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

◆ LockCursor()

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

◆ Select() [1/2]

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

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)
static

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)
static

Sends a message to all GameObjects in the scene.

Parameters
messageMessage.

◆ SendMessageToEveryone() [2/2]

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

Sends a message to all GameObjects in the scene.

Parameters
messageMessage.
argArgument.

◆ SendMessageToEveryoneAsync()

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

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 
)
static

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)
static

◆ SetGameObjectActive()

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

Sets the component's game object active or inactive.

Parameters
componentComponent.
valueThe value to set.

◆ ShowCursor()

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

◆ StringToBool()

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

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)
static

Converts a string to a float.

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)
static

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)
static

◆ ToWebColor()

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

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)
static

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

◆ maxHardFindRecursion

int PixelCrushers.DialogueSystem.Tools.maxHardFindRecursion = 256
static

Specifies how deep to recurse in GameObjectHardFind.

Property Documentation

◆ loadedLevelName

string PixelCrushers.DialogueSystem.Tools.loadedLevelName
staticget

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