![]() |
Infohazard.Core 1.4.1
Infohazard Core Utility Library
|
Contains several editor-only utilities. More...
Static Public Member Functions | |
static object | GetValue (this SerializedProperty property) |
Get the value of a SerializedProperty of any type. Does not work for serializable objects or gradients. Enum values are returned as ints. More... | |
static object | FindValue (this SerializedProperty prop) |
Find the value of a given property using reflection and reading the field directly. More... | |
static T | FindValue< T > (this SerializedProperty prop) |
Find the value of a given property using Reflection and reading the field directly. More... | |
static FieldInfo | FindFieldInfo (this SerializedProperty prop) |
Find the FieldInfo of a given property using Reflection and reading the field directly. If the property is an array element, return null. More... | |
static List< string > | GetDefinesList (BuildTargetGroup group) |
Get the Unity PlayerSettings list of #define symbols for the given build target. More... | |
static void | SetSymbolDefined (string symbol, bool value, BuildTargetGroup group) |
Sets whether the given symbol is defined in the PlayerSettings for the given build target. More... | |
static string | GetResourcePath (Object obj) |
Get the path an object lives in relative to a resource folder. More... | |
static string | GetResourcePath (string path) |
Get the given path relative to a resource folder. More... | |
static string | GetPathRelativeToAssetsFolder (string path) |
Convert the given path to be relative to the Assets folder. More... | |
static void | DoLazyDropdown< T > (Rect position, GUIContent content, Func< T[]> optionsFunc, Func< T, string > stringifier, Action< T > setter) |
Create a dropdown button in the IMGUI, whose options will not be calculated until it is clicked. More... | |
static IEnumerable< T > | GetAssetsOfType< T > (string folder=null) |
Find all the assets of the given type in the project. More... | |
static IEnumerable< Object > | GetAssetsOfType (string type) |
Find all the assets of the given type in the project. More... | |
static string | GetTypeName (this SerializedProperty property) |
Get the type full name (including assembly) of the type of the underlying field for the given property. More... | |
static void | CopyFrom (this SerializedProperty destination, SerializedObject source) |
Perform a recursive copy of the values from a SerializedObject to a struct-type SerializedProperty. More... | |
static void | CopyFrom (this SerializedProperty destination, SerializedProperty source) |
Perform a recursive copy of the values from one SerializedProperty to another. For compound types, values in one of the properties but not the other are ignored. More... | |
static Type | GetFieldType (this PropertyDrawer drawer) |
Get the type of the field the property drawer is drawing. If the type is an array or list, returns the element type. More... | |
static void | EnsureDataFolderExists () |
Ensure that the DataFolder directory exists in your project, and contains an assembly definition. More... | |
static bool | ExecuteProcess (string command, string args, bool showMessages) |
Launch an external process using the given command and arguments, and wait for it to complete. More... | |
static GameObject | InstantiatePrefabInScene (string path, string name) |
Instantiate the given prefab in the scene, as a child of the selected GameObject if there is one. More... | |
static GameObject | CreateGameObjectInScene (string name) |
Create an empty GameObject in the scene, as a child of the selected GameObject if there is one. More... | |
static T | CreateGameObjectInSceneWithComponent< T > (string name) |
Create a GameObject in the scene with a given component, as a child of the selected GameObject if there is one. More... | |
static Object | CreateAndSaveNewAsset (string name, Type type, string defaultSavePath, Object copyObject=null, Object parentObject=null, Action< Object, string > saveAction=null) |
Prompts the user to browse for a path to save a new asset at. Upon confirmation, a new asset is created and saved. More... | |
Static Public Attributes | |
const string | DataFolder = "Assets/Infohazard.Core.Data/" |
Folder where all generated files used by the Infohazard libraries should live. More... | |
Contains several editor-only utilities.
|
static |
Perform a recursive copy of the values from a SerializedObject to a struct-type SerializedProperty.
destination | Destination property to update. Must by a serializable class or struct. |
source | Source object to read. |
|
static |
Perform a recursive copy of the values from one SerializedProperty to another. For compound types, values in one of the properties but not the other are ignored.
destination | Destination property to update. |
source | Source property to read. |
|
static |
Prompts the user to browse for a path to save a new asset at. Upon confirmation, a new asset is created and saved.
By using a custom save action, you can, for example, add the created object to another asset rather than saving to the project directly. If a custom save action is used, the file browser will not be shown.
name | The default filename of the created object. |
type | Type of object to create. |
defaultSavePath | Default path to save the asset. |
parentObject | The object containing the created object (can be null). |
saveAction | Action to take to save the asset. Can be null for regular asset save. |
copyObject | Copy this object to create the new asset (can be null). |
|
static |
Create an empty GameObject in the scene, as a child of the selected GameObject if there is one.
name | Name to assign to the object. |
|
static |
Create a GameObject in the scene with a given component, as a child of the selected GameObject if there is one.
name | Name to assign to the object. |
T | The type of component to add. |
T | : | Component |
|
static |
Create a dropdown button in the IMGUI, whose options will not be calculated until it is clicked.
For a normal dropdown, you'd need to know all of the options before the button was clicked. With lazy dropdown, they are not evaluated until needed. They are also re-evaluated every time the dropdown is opened, preventing the need for cache invalidation.
position | Position to draw the dropdown button. |
content | Current value to show in the dropdown button (when not selected). |
optionsFunc | Function that will calculate and return the options. |
stringifier | Function that converts options to strings for display. |
setter | Function that sets the value when an option is chosen. |
T | Type of the options before they are converted to strings. |
|
static |
Ensure that the DataFolder directory exists in your project, and contains an assembly definition.
|
static |
Launch an external process using the given command and arguments, and wait for it to complete.
command | The command (executable file) to run. |
args | The argument string to pass to the command. |
showMessages | Whether to display a dialog box if the command fails. |
|
static |
Find the FieldInfo of a given property using Reflection and reading the field directly. If the property is an array element, return null.
prop | The property to read |
|
static |
Find the value of a given property using reflection and reading the field directly.
prop | The property to read. |
|
static |
Find the value of a given property using Reflection and reading the field directly.
T | The type to cast the value to. |
prop | The property to read |
|
static |
Find all the assets of the given type in the project.
Only assets whose root object is the given type are included.
type | The type name of assets to find. Use the class name only, without namespace. |
|
static |
Find all the assets of the given type in the project.
Only assets whose root object is the given type are included.
folder | The folder to search in, or null for the entire project. |
T | The type of asset to find. |
T | : | Object |
|
static |
Get the Unity PlayerSettings list of #define symbols for the given build target.
group | The build target. |
|
static |
Get the type of the field the property drawer is drawing. If the type is an array or list, returns the element type.
drawer | Drawer to get the type of. |
|
static |
Convert the given path to be relative to the Assets folder.
Accepts absolute paths, paths staring with "Assets/", and paths starting with "/"'". </remarks> <param name="path">
|
static |
Get the path an object lives in relative to a resource folder.
The result path can be used with Resources.Load.
obj | The object to get the path for. |
|
static |
Get the given path relative to a resource folder.
The result path can be used with Resources.Load.
path | The path to search for. |
|
static |
Get the type full name (including assembly) of the type of the underlying field for the given property.
Due to how Unity works, this will not include the namespace. If you need to access the property type from a PropertyDrawer, use PropertyDrawer.fieldInfo.FieldType instead.
property | Property to get type of. |
|
static |
Get the value of a SerializedProperty of any type. Does not work for serializable objects or gradients. Enum values are returned as ints.
property | The property to read. |
|
static |
Instantiate the given prefab in the scene, as a child of the selected GameObject if there is one.
path | Prefab path to load. |
name | Name to assign to the object, or null. |
|
static |
Sets whether the given symbol is defined in the PlayerSettings for the given build target.
symbol | The symbol to set. |
value | Whether the symbol should be defined. |
group | The build target. |
|
static |
Folder where all generated files used by the Infohazard libraries should live.
Call EnsureDataFolderExists to make sure this folder exists before using it.