Class Utilities
Helper Utilities methods used by other classes.
Assembly: cs.temp.dll.dll
public static class Utilities
Fields
Declaration
public const string MetaFileGuidRegex = "guid:\\s*([0-9a-fA-F]{32})"
Field Value
Declaration
public const string PackagesCopyFolderName = "PackagesCopy"
Field Value
Properties
Declaration
public static string AssetPath { get; }
Property Value
Declaration
public static string BuiltInPackagesPath { get; }
Property Value
Declaration
public static string MSBuildOutputFolder { get; }
Property Value
Declaration
public static string PackagesCopyPath { get; }
Property Value
Declaration
public static string ProjectPath { get; }
Property Value
Methods
Copies the source directory to the output directory creating all the directories first then copying.
Declaration
public static void CopyDirectory(string sourcePath, string destinationPath)
Parameters
Type |
Name |
Description |
String |
sourcePath |
|
String |
destinationPath |
|
Delete directory helper that also waits for delete to completely propagate through the system.
Declaration
public static void DeleteDirectory(string targetDir, bool waitForDirectoryDelete = false)
Parameters
Type |
Name |
Description |
String |
targetDir |
|
Boolean |
waitForDirectoryDelete |
|
Deletes a directory then waits for it to be flushed in the system as deleted before creating. Sometimes deleting and creating to quickly will result in an exception.
Declaration
public static void EnsureCleanDirectory(string path)
Parameters
Type |
Name |
Description |
String |
path |
|
Declaration
public static AssetLocation GetAssetLocation(FileInfo assetFile)
Parameters
Type |
Name |
Description |
FileInfo |
assetFile |
The asset file.
|
Returns
Get a path relative to the assets folder from the absolute path.
Declaration
public static string GetAssetsRelativePathFrom(string absolutePath)
Parameters
Type |
Name |
Description |
String |
absolutePath |
|
Returns
Declaration
public static BuildTargetGroup GetBuildTargetGroup(BuildTarget buildTarget)
Parameters
Type |
Name |
Description |
BuildTarget |
buildTarget |
|
Returns
Type |
Description |
BuildTargetGroup |
|
Converts an assets relative path to an absolute path.
Declaration
public static string GetFullPathFromAssetsRelative(string assetsRelativePath)
Parameters
Type |
Name |
Description |
String |
assetsRelativePath |
|
Returns
Gets a full path from one of the two known relative paths (Assets, Packages). Packages is converted to use PackagesCopy.
Declaration
public static string GetFullPathFromKnownRelative(string path)
Parameters
Type |
Name |
Description |
String |
path |
|
Returns
Converts a Packages relative path to an absolute path using PackagesCopy directory instead.
Declaration
public static string GetFullPathFromPackagesRelative(string path)
Parameters
Type |
Name |
Description |
String |
path |
|
Returns
Gets a normalized path (with back slashes only), and optionally can make full path.
Declaration
public static string GetNormalizedPath(string path, bool makeFullPath = false)
Parameters
Returns
Get a path relative to the Packages folder from the absolute path, uses PackagesOutput folder.
Declaration
public static string GetPackagesRelativePathFrom(string absolutePath)
Parameters
Type |
Name |
Description |
String |
absolutePath |
|
Returns
Given a list of Asset guids converts them to asset paths in place.
Declaration
public static void GetPathsFromGuidsInPlace(string[] guids, bool fullPaths = false)
Parameters
Gets a relative path between two absolute paths.
Declaration
public static string GetRelativePath(string thisAbsolute, string thatAbsolute)
Parameters
Type |
Name |
Description |
String |
thisAbsolute |
|
String |
thatAbsolute |
|
Returns
Gets a relative path between two known relative paths (inside Assets or Packages)
Declaration
public static string GetRelativePathForKnownFolders(string thisKnownFolder, string thatKnownFolder)
Parameters
Type |
Name |
Description |
String |
thisKnownFolder |
|
String |
thatKnownFolder |
|
Returns
Declaration
public static IEnumerable<Version> GetUWPSDKs()
Returns
Type |
Description |
IEnumerable<Version> |
|
A helper to check whether a DLL is a managed assembly.
Declaration
public static bool IsManagedAssembly(string assemblyPath)
Parameters
Type |
Name |
Description |
String |
assemblyPath |
The path to the assembly.
|
Returns
Type |
Description |
Boolean |
True if a managed assembly.
|
Helper to see if the specified BuildTarget is installed in the editor.
Declaration
public static bool IsPlatformInstalled(BuildTarget buildTarget)
Parameters
Type |
Name |
Description |
BuildTarget |
buildTarget |
|
Returns
Reads until some contents is encountered, or the end of the stream is reached.
Declaration
public static string ReadUntil(this StreamReader reader, params string[] contents)
Parameters
Type |
Name |
Description |
StreamReader |
reader |
The StreamReader to use for reading.
|
String[] |
contents |
The contents to search for in the lines being read.
|
Returns
Type |
Description |
String |
The line on which some of the contents was found.
|
Reads while the predicate is satisfied, returns the line on which it failed.
Declaration
public static string ReadWhile(this StreamReader reader, Func<string, bool> predicate)
Parameters
Type |
Name |
Description |
StreamReader |
reader |
The StreamReader to use for reading.
|
Func<String, Boolean> |
predicate |
The predicate that should return false when reading should stop.
|
Returns
Type |
Description |
String |
The line on which the predicate returned false.
|
Helper to replace tokens in text using StringBuilder.
Declaration
public static string ReplaceTokens(string text, Dictionary<string, string> tokens, bool verifyAllTokensPresent = false)
Parameters
Returns
Parses a .meta file to extract a guid for the asset.
Declaration
public static bool TryGetGuidForAsset(FileInfo assetPath, out Guid guid)
Parameters
Type |
Name |
Description |
FileInfo |
assetPath |
The path to the asset (not the .meta file).
|
Guid |
guid |
The guid extracted.
|
Returns
Type |
Description |
Boolean |
True if the operation was successful.
|
TryGetTextTemplate(String, String, out String)
Helper to fetch a normal text file based template ('prefixed with #')
Declaration
public static bool TryGetTextTemplate(string text, string templateName, out string fullTemplate)
Parameters
Returns
TryGetTextTemplate(String, String, out String, out String)
Helper to fetch a normal text file based template ('prefixed with #')
Declaration
public static bool TryGetTextTemplate(string text, string templateName, out string fullTemplate, out string templateBody)
Parameters
Returns
Helper to fetch an XML based template.
Declaration
public static bool TryGetXMLTemplate(string text, string templateName, out string template)
Parameters
Returns
Helper to perform an IO operation with retries.
Declaration
public static bool TryIOWithRetries(Action operation, int numRetries, TimeSpan sleepBetweenRetries, bool throwOnLastRetry = false)
Parameters
Type |
Name |
Description |
Action |
operation |
|
Int32 |
numRetries |
|
TimeSpan |
sleepBetweenRetries |
|
Boolean |
throwOnLastRetry |
|
Returns