Class Platform
A collection of platform related helper utilities.
Inheritance
Namespace: GDX
Syntax
[VisualScriptingCompatible((short)8)]
public static class Platform
Fields
| Improve this Doc View SourceCharacterPoolLength
Declaration
public const int CharacterPoolLength = 25
Field Value
Type | Description |
---|---|
System.Int32 |
CharacterPoolLengthExclusive
Declaration
public const int CharacterPoolLengthExclusive = 24
Field Value
Type | Description |
---|---|
System.Int32 |
DoubleTolerance
Declaration
public const double DoubleTolerance = 1E-06
Field Value
Type | Description |
---|---|
System.Double |
FilenameTimestampFormat
A filename safe version of the timestamp format.
Declaration
public const string FilenameTimestampFormat = "yyyyMMdd_HHmmss"
Field Value
Type | Description |
---|---|
System.String |
FloatTolerance
Declaration
public const float FloatTolerance = 1E-06F
Field Value
Type | Description |
---|---|
System.Single |
ImageCompareTolerance
Declaration
public const float ImageCompareTolerance = 0.99F
Field Value
Type | Description |
---|---|
System.Single |
SafeCharacterPool
Declaration
public const string SafeCharacterPool = "abcdefghijklmnopqrstuvwxyz"
Field Value
Type | Description |
---|---|
System.String |
TimestampFormat
Declaration
public const string TimestampFormat = "yyyy-MM-dd HH:mm:ss"
Field Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceEnsureFileFolderHierarchyExists(String)
Validate that all parent directories are created for a given filePath
.
Declaration
public static void EnsureFileFolderHierarchyExists(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The path to process and validate. |
EnsureFileWritable(String)
Validate that the file path is writable, making the necessary folder structure and setting permissions.
Declaration
public static void EnsureFileWritable(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The absolute path to validate. |
EnsureFolderHierarchyExists(String)
Validate that all directories are created for a given folderPath
.
Declaration
public static void EnsureFolderHierarchyExists(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath | The path to process and validate. |
ForceDeleteFile(String)
Use our best attempt to remove a file at the designated filePath
.
Declaration
public static void ForceDeleteFile(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file path to remove forcefully. |
GetHardwareGeneration()
Gets the current platforms hardware generation number?
Declaration
public static int GetHardwareGeneration()
Returns
Type | Description |
---|---|
System.Int32 | Returns 0 for base hardware, 1 for updates. |
GetOutputFolder(String)
Returns a runtime writable folder.
Declaration
public static string GetOutputFolder(string folderName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderName | An optional additional folder under the provided path that will be created if necessary. |
Returns
Type | Description |
---|---|
System.String | The full path to a writable folder at runtime. |
Remarks
Depending on the platform, different routes are taken to finding a writable folder.
Editor | The project's root folder is used in this case. |
Standard Player | Utilizes UnityEngine.Application.persistentDataPath to find a suitable place. |
DOTS Runtime | Uses System.IO.Directory.GetCurrentDirectory. |
GetRandomSafeCharacter(IRandomProvider)
Declaration
public static char GetRandomSafeCharacter(IRandomProvider random)
Parameters
Type | Name | Description |
---|---|---|
IRandomProvider | random |
Returns
Type | Description |
---|---|
System.Char |
GetUniqueOutputFilePath(String, String, String)
Declaration
public static string GetUniqueOutputFilePath(string prefix = "GDX_", string extension = ".log", string folderName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | |
System.String | extension | |
System.String | folderName |
Returns
Type | Description |
---|---|
System.String |
IsFileWritable(String)
Is it safe to write to the indicated filePath
?
Declaration
public static bool IsFileWritable(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file path to check if it can be written. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the path can be written too. |
IsFocused()
Is the application focused?
Declaration
public static bool IsFocused()
Returns
Type | Description |
---|---|
System.Boolean | true/false if the application has focus. |
Remarks
There are issues on some platforms with getting an accurate reading.
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
IsHeadless()
Is the application running in headless mode?.
Declaration
public static bool IsHeadless()
Returns
Type | Description |
---|---|
System.Boolean | true/false if the application is without an initialized graphics device. |
Remarks
Useful for detecting running a server.
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |