Class EditorExtensions
Extension methods for Unity Editor
Inheritance
System.Object
EditorExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: cs.temp.dll.dll
Syntax
public static class EditorExtensions
Methods
AddLayer(String)
Adds a layer programmatically.
Declaration
public static void AddLayer(string layer)
Parameters
| Type |
Name |
Description |
| System.String |
layer |
|
AddTag(String)
Adds a tag programmatically.
Declaration
public static void AddTag(string tag)
Parameters
| Type |
Name |
Description |
| System.String |
tag |
|
CenterOnEditor(EditorWindow)
Centers the given EditorWindow relatively to the main Unity Editor
Declaration
public static void CenterOnEditor(this EditorWindow editorWindow)
Parameters
| Type |
Name |
Description |
| EditorWindow |
editorWindow |
|
ConvertHSLtoRGB(Single, Single, Single)
Given H,S,L in range of 0-1.
Returns a Color (RGB struct) in range of 0-255.
Declaration
public static Color ConvertHSLtoRGB(float hue, float saturation, float luminosity)
Parameters
| Type |
Name |
Description |
| System.Single |
hue |
|
| System.Single |
saturation |
|
| System.Single |
luminosity |
|
Returns
CreateAsset<TUnityObject>(TUnityObject, String)
Declaration
public static void CreateAsset<TUnityObject>(this TUnityObject unityObject, string path)
where TUnityObject : UnityEngine.Object
Parameters
| Type |
Name |
Description |
| TUnityObject |
unityObject |
|
| System.String |
path |
|
Type Parameters
| Name |
Description |
| TUnityObject |
|
CreateAsset<TScriptableObject>(String)
Creates an instance of a ScriptableObject, as well as creating an Asset for it at the active object location
Declaration
public static TScriptableObject CreateAsset<TScriptableObject>(string assetName = null)
where TScriptableObject : ScriptableObject
Parameters
| Type |
Name |
Description |
| System.String |
assetName |
|
Returns
| Type |
Description |
| TScriptableObject |
|
Type Parameters
| Name |
Description |
| TScriptableObject |
|
CreatePrefab(GameObject, String, IList<UnityEngine.Object>)
Creates an Unity prefab from a GameObject and dependencies
Declaration
public static GameObject CreatePrefab(this GameObject gameObject, string path, IList<UnityEngine.Object> dependencies = null)
Parameters
| Type |
Name |
Description |
| GameObject |
gameObject |
Root GameObject to save a prefab
|
| System.String |
path |
Path to the prefab without extension (Asset/..../MyPrefab)
|
| System.Collections.Generic.IList<UnityEngine.Object> |
dependencies |
Dependencies to save inside the prefab
|
Returns
| Type |
Description |
| GameObject |
|
GetEditor<TEditor>(ScriptableObject)
Declaration
public static TEditor GetEditor<TEditor>(this ScriptableObject scriptableObject)
where TEditor : UnityEditor.Editor
Parameters
| Type |
Name |
Description |
| ScriptableObject |
scriptableObject |
|
Returns
Type Parameters
GetEditorMainWindowPos()
Gets the main Unity Editor position and size
Declaration
public static Rect GetEditorMainWindowPos()
Returns
GetEditorWindow(Type, Boolean, String)
Returns an editor window.
Declaration
public static EditorWindow GetEditorWindow(Type type, bool utility, string windowTitle)
Parameters
| Type |
Name |
Description |
| System.Type |
type |
|
| System.Boolean |
utility |
If true, a floating window is created. If false, a normal window is created
|
| System.String |
windowTitle |
|
Returns
| Type |
Description |
| EditorWindow |
|
GetGUID(UnityEngine.Object)
Returns the GUID of a UnityObject. Returns null if the object isn't Serialized.
Declaration
public static string GetGUID(this UnityEngine.Object unityObject)
Parameters
| Type |
Name |
Description |
| UnityEngine.Object |
unityObject |
|
Returns
| Type |
Description |
| System.String |
|
GetLayers()
Returns all defined layers.
Declaration
public static HashSet<string> GetLayers()
Returns
| Type |
Description |
| HashSet<System.String> |
|
Returns all defined tags.
Declaration
public static HashSet<string> GetTags()
Returns
| Type |
Description |
| HashSet<System.String> |
|
GetTextures(Material)
Returns unique textures used in a given material.
Declaration
public static HashSet<Texture> GetTextures(this Material material)
Parameters
| Type |
Name |
Description |
| Material |
material |
|
Returns
| Type |
Description |
| HashSet<Texture> |
|
GetTooltipText<T>(String)
Uses reflection to return a tooltip of given field of a given type.
Declaration
public static string GetTooltipText<T>(string field)
Parameters
| Type |
Name |
Description |
| System.String |
field |
Field name
|
Returns
| Type |
Description |
| System.String |
|
Type Parameters
| Name |
Description |
| T |
Type containing the field
|
GetUnityObject<T>(String)
Returns an UnityObject from a GUID. Will return null if object isn't Serialized.
Declaration
public static T GetUnityObject<T>(string guid)
where T : UnityEngine.Object
Parameters
| Type |
Name |
Description |
| System.String |
guid |
|
Returns
Type Parameters
GetVolatileDependencies(GameObject)
Returns all non persistent (also called volatile) dependencies from a given GameObject and it's children recursively.
Declaration
public static UnityEngine.Object[] GetVolatileDependencies(this GameObject gameObject)
Parameters
| Type |
Name |
Description |
| GameObject |
gameObject |
|
Returns
| Type |
Description |
| UnityEngine.Object[] |
|
GetVolatileDependencies(IList<GameObject>)
Returns all non persistent (also called volatile) dependencies from given GameObjects.
Declaration
public static UnityEngine.Object[] GetVolatileDependencies(this IList<GameObject> gameObjects)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IList<GameObject> |
gameObjects |
|
Returns
| Type |
Description |
| UnityEngine.Object[] |
|
GetVolatileDependenciesRearranged(IList<GameObject>)
Returns all non persistent (also called volatile) dependencies from given GameObjects.
Declaration
public static LookupTable<string, UnityEngine.Object> GetVolatileDependenciesRearranged(this IList<GameObject> gameObjects)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IList<GameObject> |
gameObjects |
|
Returns
| Type |
Description |
| LookupTable<System.String, UnityEngine.Object> |
|
IsSerialized(UnityEngine.Object)
Declaration
public static bool IsSerialized(this UnityEngine.Object unityObject)
Parameters
| Type |
Name |
Description |
| UnityEngine.Object |
unityObject |
|
Returns
| Type |
Description |
| System.Boolean |
|
OpenWindow<TEditorWindow>()
Declaration
public static TEditorWindow OpenWindow<TEditorWindow>()
where TEditorWindow : SingletonEditorWindow
Returns
| Type |
Description |
| TEditorWindow |
|
Type Parameters
| Name |
Description |
| TEditorWindow |
|
SaveAsset(ScriptableObject, String, Boolean, String)
Saves a ScriptableObject as an Asset.
Declaration
public static void SaveAsset(this ScriptableObject scriptableObject, string assetName, bool focusOnSave = false, string path = null)
Parameters
| Type |
Name |
Description |
| ScriptableObject |
scriptableObject |
|
| System.String |
assetName |
Asset name (which will be the file name without .asset extension)
|
| System.Boolean |
focusOnSave |
|
| System.String |
path |
|
SelectFile(String[])
Opens a browser to select a file
Declaration
public static string SelectFile(string[] filter)
Parameters
| Type |
Name |
Description |
| System.String[] |
filter |
|
Returns
| Type |
Description |
| System.String |
|