Class ScriptGenerationUtilities
Inherited Members
Namespace: NeoFPSEditor.ScriptGeneration
Assembly: NeoFPS.dll
Syntax
public static class ScriptGenerationUtilities
Methods
CheckClassOrPropertyName(String, Boolean)
Checks if a string is a valid class or property name (no whitespace, no invalid characters)
Declaration
public static bool CheckClassOrPropertyName(string toCheck, bool camelCase = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | toCheck | The class or property name string to check |
| System.Boolean | camelCase | Is camel case (first letter lower case) allowed |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the name is valid, false if not |
CheckForDuplicateNames(SerializedProperty, Int32, List<Int32>)
Check that the string at the provided index in the array property is unique within the array, and store any duplicate indices in a list (including the index to check)
Declaration
public static int CheckForDuplicateNames(SerializedProperty prop, int index, List<int> duplicates)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | prop | A serialized property pointing to an array of strings |
| System.Int32 | index | The index within the array |
| System.Collections.Generic.List<System.Int32> | duplicates | A list to fill with duplicate indices (will be cleared beforehand) |
Returns
| Type | Description |
|---|---|
| System.Int32 | The number of total duplicates found |
CheckForDuplicateNames(SerializedProperty, Int32, String, List<Int32>)
Check that the string relative property at the provided index in the array property is unique within the array, and store any duplicate indices in a list (including the index to check)
Declaration
public static int CheckForDuplicateNames(SerializedProperty prop, int index, string relativePropertyName, List<int> duplicates)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | prop | A serialized property pointing to an array of strings |
| System.Int32 | index | The index within the array |
| System.String | relativePropertyName | The relative property within the array element for the name string |
| System.Collections.Generic.List<System.Int32> | duplicates | A list to fill with duplicate indices (will be cleared beforehand) |
Returns
| Type | Description |
|---|---|
| System.Int32 | The number of total duplicates found |
CheckNameCollision(String, String[])
Check if the name is found within the provided array
Declaration
public static bool CheckNameCollision(string n, string[] reserved)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | n | The name to check |
| System.String[] | reserved | An array of names to check against |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if found, false if not |
CheckNameIsUnique(SerializedProperty, Int32)
Check that the string at the provided index in the array property is unique within the array
Declaration
public static bool CheckNameIsUnique(SerializedProperty prop, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | prop | A serialized property pointing to an array of strings |
| System.Int32 | index | The index within the array |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the string is unique, false if not |
CheckNameIsUnique(SerializedProperty, Int32, String)
Check that the string relative property at the provided index in the array property is unique within the array
Declaration
public static bool CheckNameIsUnique(SerializedProperty prop, int index, string relativePropertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | prop | A serialized property pointing to an array of serialized classes / structs |
| System.Int32 | index | The index within the array |
| System.String | relativePropertyName | The relative property within the array element for the name string |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the string is unique, false if not |
CheckNamespace(String)
Checks if a namespace name is valid (no whitespace, alphanumeric words, starting with a letter, separated by ."
Declaration
public static bool CheckNamespace(string ns)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | ns | The namespace name to check |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the namespace is valid, false if not |
DrawFolderObjectField(SerializedProperty)
Draw an inspector field for a folder object that allows drag and drop
Declaration
public static bool DrawFolderObjectField(SerializedProperty folderProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | folderProperty |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the path changed, false if not |
DrawFolderPathField(SerializedProperty)
Draw an inspector field for a folder path that shows the folder itself and allows drag and drop
Declaration
public static bool DrawFolderPathField(SerializedProperty pathProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | pathProperty | The folder path serialized property |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the path changed, false if not |
GetFullScriptPath(SerializedProperty, String)
Create a full script path that can be used for file IO from a folder object property and script name. If the folder object is set to "None", then the root assets folder will be used.
Declaration
public static string GetFullScriptPath(SerializedProperty folderProperty, string scriptName)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | folderProperty | The serialized property pointing to the folder object. |
| System.String | scriptName | The name of the script (no extension) |
Returns
| Type | Description |
|---|---|
| System.String | The resulting path |
GetFullScriptPath(String, String)
Create a full script path that can be used for file IO from a folder path and script name. If the folder path is null or empty then the root assets folder will be used.
Declaration
public static string GetFullScriptPath(string folderPath, string scriptName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | folderPath | The path of the output folder |
| System.String | scriptName | The name of the script (no extension) |
Returns
| Type | Description |
|---|---|
| System.String | The resulting path |
InsertMultipleLines(String, String, ScriptGenerationUtilities.LineFormattingCallback, String)
Search and replace a keyword with a series of lines based on a formatting callback.
Declaration
public static string InsertMultipleLines(string source, string searchKey, ScriptGenerationUtilities.LineFormattingCallback func, string countKey = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | source | The source string to modify |
| System.String | searchKey | The keyword to replace |
| ScriptGenerationUtilities.LineFormattingCallback | func | A callback to retrieve the next string in the sequence. If null is returned then the sequence is completed |
| System.String | countKey |
Returns
| Type | Description |
|---|---|
| System.String | The modified source string |
InsertMultipleLines(String, String, String, String[], String)
Search and replace a keyword with a series of lines based on a format string.
Declaration
public static string InsertMultipleLines(string source, string searchKey, string formatString, string[] entries, string countKey = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | source | The source string to modify |
| System.String | searchKey | The keyword to replace |
| System.String | formatString | A format string for each line as used in the method string.Format(). 0 is the entry string, 1 is the index. |
| System.String[] | entries | The string lines to use |
| System.String | countKey |
Returns
| Type | Description |
|---|---|
| System.String | The modified source string |
ReplaceKeyword(String, String, String)
Search and replace within the source string for each of the key value pairs The key is the string to search for (will be converted to "%KEY%" from "key" or "KEY"), while the value is the string to replace it with
Declaration
public static string ReplaceKeyword(string source, string searchKey, string replace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | source | The source string to modify |
| System.String | searchKey | |
| System.String | replace | An array of key value pairs to search and replace |
Returns
| Type | Description |
|---|---|
| System.String | The modified source string |
ReplaceKeywords(String, KeyValuePair<String, String>[])
Declaration
public static string ReplaceKeywords(string source, KeyValuePair<string, string>[] replace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | source | |
| System.Collections.Generic.KeyValuePair<System.String, System.String>[] | replace |
Returns
| Type | Description |
|---|---|
| System.String |
WriteScript(String, String, Boolean)
Write a script string to file.
Declaration
public static void WriteScript(string path, string text, bool refresh)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | The file path to write to |
| System.String | text | The contents of the script |
| System.Boolean | refresh | Should the asset database be refreshed after generating? Set this to true for the last of a batch if writing multiple |