cohtml.Utils
Class providing utility methods that are commonly used across the integration code.
Public Classes
Name | |
---|---|
class | Application Utility class providing Application methods. |
Public Functions
Name | |
---|---|
void | CreateDirectory(string path, bool clean) Creates a directory at specified path. |
string | CombinePaths(params string [] paths) Combines paths together. |
string | NormalizeSlashes(this string target) Replaces backward slashes with forward slashes. |
string | DecodeString(string content) Encodes a string into a range of bytes and then decodes it into a string. |
string | DecodeString(byte [] content) Decodes a range of bytes from a byte array into a string. |
byte [] | EncodeString(string content) Encodes a string into a sequence of bytes. |
uint | GetByteCount(string content) Calculates the number of bytes produced by encoding a set of characters. |
T | AddMissingComponent< T >(this GameObject go) Adds a component to a given GameObject only if its missing. |
T | FindObjectByType< T >(bool findAny =false) Wrapper method on top of the original Unity3D one allowing support for multiple engine versions. |
T [] | FindObjectsByType< T >() Wrapper method on top of the original Unity3D one allowing support for multiple engine versions. |
void | SetBitState(ref byte bits, int position, bool enabled) Sets the state of a bit at a given position in a byte state machine. |
bool | GetBitState(byte bits, int position) Gets the state of a bit at a given position in a byte state machine. |
void | ResetByteState(ref byte bits) Resets the state of all bits in the byte sequence to 0. |
Public Attributes
Name | |
---|---|
const string | PackagesStr Holds the name of the packages folder. |
const string | CohtmlUpmName The name of the cohtml upm package. |
const byte | DefaultByteMask A default byte mask setting all bits to 0. |
string | CohtmlUpmPath Returns the path of the cohtml upm package. |
Public Functions Documentation
function CreateDirectory
static void CreateDirectory(
string path,
bool clean
)
Creates a directory at specified path.
Parameters:
- path The path where to create the directory.
- clean A flag whether the directory should be cleaned first if it exists.
function CombinePaths
static string CombinePaths(
params string [] paths
)
Combines paths together.
function NormalizeSlashes
static string NormalizeSlashes(
this string target
)
Replaces backward slashes with forward slashes.
function DecodeString
static string DecodeString(
string content
)
Encodes a string into a range of bytes and then decodes it into a string.
function DecodeString
static string DecodeString(
byte [] content
)
Decodes a range of bytes from a byte array into a string.
function EncodeString
static byte [] EncodeString(
string content
)
Encodes a string into a sequence of bytes.
function GetByteCount
static uint GetByteCount(
string content
)
Calculates the number of bytes produced by encoding a set of characters.
function AddMissingComponent< T >
static T AddMissingComponent< T >(
this GameObject go
)
Adds a component to a given GameObject only if its missing.
Parameters:
- go The GameObject to add the component to.
Template Parameters:
- T The type of the component.
Return: Returns the added component or the already existing one.
function FindObjectByType< T >
static T FindObjectByType< T >(
bool findAny =false
)
Wrapper method on top of the original Unity3D one allowing support for multiple engine versions.
Parameters:
- findAny If finding any instance of the type is acceptable, enable this flag for a faster search.
Template Parameters:
- T The object type to find.
Return: Returns the object by the given type if found.
function FindObjectsByType< T >
static T [] FindObjectsByType< T >()
Wrapper method on top of the original Unity3D one allowing support for multiple engine versions.
Template Parameters:
- T The object type to find.
Return: Returns an array of the object by the given type if found.
function SetBitState
static void SetBitState(
ref byte bits,
int position,
bool enabled
)
Sets the state of a bit at a given position in a byte state machine.
Parameters:
- bits A ref to the byte sequence of the state machine.
- position The position of the bit from 0 to 7.
- enabled The new bit state.
function GetBitState
static bool GetBitState(
byte bits,
int position
)
Gets the state of a bit at a given position in a byte state machine.
Parameters:
- bits The byte sequence of the state machine.
- position The position of the bit from 0 to 7.
Return: True or false based on the state of the bit.
function ResetByteState
static void ResetByteState(
ref byte bits
)
Resets the state of all bits in the byte sequence to 0.
Parameters:
- bits The byte sequence to reset.
Public Attributes Documentation
variable PackagesStr
const string PackagesStr = "Packages";
Holds the name of the packages folder.
variable CohtmlUpmName
const string CohtmlUpmName = "com.coherent-labs.cohtml";
The name of the cohtml upm package.
variable DefaultByteMask
const byte DefaultByteMask = 0b00000000;
A default byte mask setting all bits to 0.
variable CohtmlUpmPath
static string CohtmlUpmPath => CombinePaths(PackagesStr, CohtmlUpmName);
Returns the path of the cohtml upm package.