Skip to content

SolidUtilities.Editor

Artem edited this page Feb 19, 2021 · 5 revisions

All types

ReadOnlyDrawer Class IndentLevel Struct TemporaryRenderTexture Class
EditorWindowExtensions Class LogHelper Class TextureHelper Class
MonoScriptExtensions Class LogModes Enum VerticalBlock Struct
SerializedObjectValuesCopier Class MixedValue Struct EditorIcon Struct
SerializedPropertyExtensions Class ObjectType Enum EditorIconsDatabase Class
AssetDatabaseHelper Class PackageSearcher Class Action Enum
AssetSearcher Class PropertyExtensions Class ConflictState Class
ChildProperties Class PropertyWrapper Struct EnumerationEntry Struct
ContentCache Class ScrollView Struct PropertyIdentity Struct
EditorDrawHelper Class SearchToolbarStyle Struct ResizableTextAreaAttributeDrawer Class
EditorIcons Class SRGBWriteScope Struct SerializableDictionaryPropertyDrawer Class
FoundObject Struct TemporaryActiveTexture Class

ReadOnlyDrawer Class

Namespace: GenericScriptableObjects.Usage_Example.Editor

Base class: PropertyDrawer

Properties

Name Type Summary
attribute PropertyAttribute
fieldInfo FieldInfo

Methods

Name Returns Summary
GetPropertyHeight(SerializedProperty property, GUIContent label) float
OnGUI(Rect position, SerializedProperty property, GUIContent label) void

Methods

GetPropertyHeight(SerializedProperty property, GUIContent label)

Returns

float

OnGUI(Rect position, SerializedProperty property, GUIContent label)

EditorWindowExtensions Class

Namespace: SolidUtilities.Editor.Extensions

Different useful extensions for UnityEditor.EditorWindow.

Methods

Name Returns Summary
CenterOnMainWin(EditorWindow window) void Centers the window in the main Unity window. This is not the same as centering a window on screen, because the Unity window may not be maximized.
MoveOutOfScreen(EditorWindow window) void Moves the window out of screen to hide but not close it.
Resize(EditorWindow window, float width, float height) void Resizes the window to the needed size.

Methods

CenterOnMainWin(EditorWindow window)

Centers the window in the main Unity window. This is not the same as centering a window on screen, because the Unity window may not be maximized.

Parameter Type Description
window EditorWindow The window to center.

MoveOutOfScreen(EditorWindow window)

Moves the window out of screen to hide but not close it.

Parameter Type Description
window EditorWindow The window to hide.

Resize(EditorWindow window, float width, float height)

Resizes the window to the needed size.

Parameter Type Description
window EditorWindow The window to change the size of.
width float The width to set. If the value is -1f, the width will not be changed.
height float The height to set. If the value is -1f, the height will not be changed.

Examples

             public class DummyWindow : EditorWindow
             {
                 private void OnCreate(Rect buttonRect)
                 {
                     var windowSize = new Vector2(100f, 100f);
                     ShowAsDropDown(buttonRect, windowSize);
                 }
            
                 private void OnGUI()
                 {
                     float optimalWidth = CalculateOptimalWidth();
                     float optimalHeight = Math.Min(_contentHeight, DropdownStyle.MaxWindowHeight);
                     this.Resize(optimalWidth, optimalHeight);
                 }
             }
             

MonoScriptExtensions Class

Namespace: SolidUtilities.Editor.Extensions

Methods

Name Returns Summary
GetAssemblyName(MonoScript script) string Returns the assembly name of the class implemented by this script.
GetClassType(MonoScript script) Type Returns the System.Type of the class implemented by this script. Works for types not derived from UnityEngine.Object and generic classes (the file must be named by the "GenericClass`1.cs" template).

Methods

GetAssemblyName(MonoScript script)

Returns the assembly name of the class implemented by this script.

Parameter Type Description
script MonoScript The script to search for assembly in.

Returns

string

The assembly name without the .dll extension, or an empty string if the assembly was not found.

GetClassType(MonoScript script)

Returns the System.Type of the class implemented by this script. Works for types not derived from UnityEngine.Object and generic classes (the file must be named by the "GenericClass`1.cs" template).

Parameter Type Description
script MonoScript The script to get the type from.

Returns

Type

The System.Type of the class implemented by this script or null,

SerializedObjectValuesCopier Class

Namespace: SolidUtilities.Editor.Extensions

Provides methods that allow to copy values from one UnityEngine.Object to another. It works with UnityEditor.SerializedObject too.

Methods

Name Returns Summary
[CopyValuesFrom(SerializedObject thisSerializedObject, Object otherObject, HashSet<string> excludeValues)](#copyvaluesfromserializedobject-thisserializedobject-object-otherobject-hashsethttpsdocsmicrosoftcomen-usdotnetapisystemcollectionsgenerichashset-1string-excludevalues) void Copies values of the visible properties from otherObject to thisSerializedObject.
[CopyValuesFrom(Object thisObject, Object otherObject, HashSet<string> excludeValues)](#copyvaluesfromobject-thisobject-object-otherobject-hashsethttpsdocsmicrosoftcomen-usdotnetapisystemcollectionsgenerichashset-1string-excludevalues) void Copies values of the visible properties from otherObject to thisObject.
[CopyValuesFrom(Object thisObject, SerializedObject otherObject, HashSet<string> excludeValues)](#copyvaluesfromobject-thisobject-serializedobject-otherobject-hashsethttpsdocsmicrosoftcomen-usdotnetapisystemcollectionsgenerichashset-1string-excludevalues) void Copies values of the visible properties from otherObject to thisObject.
[CopyValuesFrom(SerializedObject thisObject, SerializedObject otherObject, HashSet<string> excludeValues)](#copyvaluesfromserializedobject-thisobject-serializedobject-otherobject-hashsethttpsdocsmicrosoftcomen-usdotnetapisystemcollectionsgenerichashset-1string-excludevalues) void Copies values of the visible properties from otherObject to thisObject.

Methods

CopyValuesFrom(SerializedObject thisSerializedObject, Object otherObject, HashSet<string> excludeValues)

Copies values of the visible properties from otherObject to thisSerializedObject.

Parameter Type Description
thisSerializedObject SerializedObject Destination object.
otherObject Object Source object.
excludeValues HashSet<string> Names of properties to exclude from copying.

CopyValuesFrom(Object thisObject, Object otherObject, HashSet<string> excludeValues)

Copies values of the visible properties from otherObject to thisObject.

Parameter Type Description
thisObject Object Destination object.
otherObject Object Source object.
excludeValues HashSet<string> Names of properties to exclude from copying.

CopyValuesFrom(Object thisObject, SerializedObject otherObject, HashSet<string> excludeValues)

Copies values of the visible properties from otherObject to thisObject.

Parameter Type Description
thisObject Object Destination object.
otherObject SerializedObject Source object.
excludeValues HashSet<string> Names of properties to exclude from copying.

CopyValuesFrom(SerializedObject thisObject, SerializedObject otherObject, HashSet<string> excludeValues)

Copies values of the visible properties from otherObject to thisObject.

Parameter Type Description
thisObject SerializedObject Destination object.
otherObject SerializedObject Source object.
excludeValues HashSet<string> Names of properties to exclude from copying.

SerializedPropertyExtensions Class

Namespace: SolidUtilities.Editor.Extensions

Different useful extensions for UnityEditor.SerializedProperty.

Methods

Name Returns Summary
GetObjectType(SerializedProperty property) Type Gets type of the object serialized by the property.
IsBuiltIn(SerializedProperty property) bool Checks whether the serialized property is built-in. UnityEditor.SerializedObject has a lot of built-in properties and we are often interested only in the custom ones.

Methods

GetObjectType(SerializedProperty property)

Gets type of the object serialized by the property.

Parameter Type Description
property SerializedProperty The property whose type to find.

Returns

Type

Type of the object serialized by property.

IsBuiltIn(SerializedProperty property)

Checks whether the serialized property is built-in. UnityEditor.SerializedObject has a lot of built-in properties and we are often interested only in the custom ones.

Parameter Type Description
property SerializedProperty The property to check.

Returns

bool

Whether the property is built-in.

AssetDatabaseHelper Class

Namespace: SolidUtilities.Editor.Helpers

Methods

Name Returns Summary
GetTypeFromGUID(string guid) Type Retrieves type of the class located in an asset with the matching guid.

Methods

GetTypeFromGUID(string guid)

Retrieves type of the class located in an asset with the matching guid.

Parameter Type Description
guid string The GUID of an asset to search for.

Returns

Type

Type of the class located in an asset with the matching guid.

AssetSearcher Class

Namespace: SolidUtilities.Editor.Helpers

A class that allows to find assets provided different parameters.

Methods

Name Returns Summary
FindObjectsWithValue(string variableName, string value) List<FoundObject> Finds all scriptable objects, scene objects, prefabs, and their overrides that contain a variable named variableName with value equal to value.
[GetAssetDetails(Type type, out string GUID, out MonoScript monoScript)](#getassetdetailstypehttpsdocsmicrosoftcomen-usdotnetapisystemtype-type-out-string-guid-out-monoscript-monoscript) bool Gets the GUID of an asset where the type is located.
[GetClassGUID(Type type)](#getclassguidtypehttpsdocsmicrosoftcomen-usdotnetapisystemtype-type) string
[GetMonoScriptFromType(Type type)](#getmonoscriptfromtypetypehttpsdocsmicrosoftcomen-usdotnetapisystemtype-type) MonoScript

Methods

FindObjectsWithValue(string variableName, string value)

Finds all scriptable objects, scene objects, prefabs, and their overrides that contain a variable named variableName with value equal to value.

Parameter Type Description
variableName string The name of the variable to search for.
value string The value of the variable to search for.

Returns

List<FoundObject>

A list of SolidUtilities.Editor.Helpers.FoundObject that contain details about each found match.

Examples

             [Serializable] public class CustomClass
             {
                 [SerializeField] private string _testField;
             }
            
             public class TestBehaviour : MonoBehaviour
             {
                 [SerializeField] private CustomClass _test;
             }
            
             public class TestScriptableObject : ScriptableObject
             {
                 public CustomClass ScriptableTestField;
             }
            
             // This will find all prefabs, scriptable objects, and scene objects where the value of _testField was set
             // to "value set in editor". It will then output details about each found match: path to the asset, component
             // where the variable was found, etc.
             var foundObjects = AssetSearcher.FindObjectsWithValue("_testField", "value set in editor");
            
             foreach (FoundObject foundObject in foundObjects)
             {
                 Debug.Log($"[foundObject.Type]");
            
                 foreach (var detail in foundObject)
                 {
                     Debug.Log($"{detail.Key}: {detail.Value}");
                 }
             }
             

GetAssetDetails(Type type, out string GUID, out MonoScript monoScript)

Gets the GUID of an asset where the type is located.

Parameter Type Description
type Type Type to search for in assets.
GUID out string GUID of the asset where the type is located, or null if the asset was not found.
monoScript out MonoScript MonoScript of the asset where the type is located, or null if the asset was not found.

Returns

bool

true if the asset with the specified type was found.

GetClassGUID(Type type)

Returns

string

GetMonoScriptFromType(Type type)

Returns

MonoScript

ChildProperties Class

Namespace: SolidUtilities.Editor.Helpers

Allows iterating over child properties of a serialized object without entering nested properties.

Examples

            var childProperties = new ChildProperties(serializedObject);
            foreach (var child in childProperties)
            {
                FieldInfo field = targetType.GetFieldAtPath(child.propertyPath);
                Draw(field);
            }
            

Properties

Name Type Summary
System.Collections.Generic.IEnumerator<UnityEditor.SerializedProperty>.Current SerializedProperty
System.Collections.IEnumerator.Current Object

Constructors

Name Summary
ChildProperties(SerializedObject parentObject, bool enterChildren, bool excludeBuiltInProperties, bool visibleOnly) Initializes a new instance of the SolidUtilities.Editor.Helpers.ChildProperties class.

Methods

Name Returns Summary
Reset() void

Constructors

ChildProperties(SerializedObject parentObject, bool enterChildren, bool excludeBuiltInProperties, bool visibleOnly)

Initializes a new instance of the SolidUtilities.Editor.Helpers.ChildProperties class.

Parameter Type Description
parentObject SerializedObject The parent serialized object which child properties you want to inspect.
enterChildren bool Whether to iterate through child properties recursively. false by default.
excludeBuiltInProperties bool Whether to exclude built-in properties from the iteration. true by default.
visibleOnly bool Whether to iterate only over the visible properties.

Methods

Reset()

ContentCache Class

Namespace: SolidUtilities.Editor.Helpers

Allows to create a UnityEngine.GUIContent instance and keep it in cache, reducing the garbage collection overhead.

Methods

Name Returns Summary
GetItem(string text) GUIContent Get cached GUIContent or create a new one and cache it.

Methods

GetItem(string text)

Get cached GUIContent or create a new one and cache it.

Parameter Type Description
text string Text in GUIContent.

Returns

GUIContent

GUIContent instance containing the text.

Examples

            GUI.Label(placeHolderArea, ContentCache.GetItem(placeholder), PlaceholderStyle);
            

EditorDrawHelper Class

Namespace: SolidUtilities.Editor.Helpers

Different useful methods that simplify UnityEditor.EditorGUILayout API.

Properties

Name Type Summary
InfoMessageStyle GUIStyle
PlaceholderStyle GUIStyle

Methods

Name Returns Summary
[CheckIfChanged(Action drawContent)](#checkifchangedactionhttpsdocsmicrosoftcomen-usdotnetapisystemaction-drawcontent) bool Draws content and checks if it was changed.
CreateEditor(Object targetObject) T Creates an editor of type T for targetObject.
DelayedPropertyField(SerializedProperty property, GUIContent label, GUILayoutOption[] options) bool Draws the property identically to UnityEditor.EditorGUILayout.PropertyField(UnityEditor.SerializedProperty,UnityEngine.GUIContent,UnityEngine.GUILayoutOption[]) but makes fields delayed where possible.
DrawBorders(float rectWidth, float rectHeight, Color color, float borderWidth) void Draws borders with a given color and width around a rectangle.
DrawInfoMessage(string message) void Shows the info message.
FocusedTextField(Rect rect, string text, string placeholder, GUIStyle style, string controlName) string Draws a text field that is always focused.
GetMainWindowPosition() Rect Returns the rectangle of the main Unity window.
GetScreenWidth() float Returns the same value as Screen.currentResolution.width if one screen is used. Returns the sum of two screens' widths when two monitors are used and Unity is located on the second screen. It will only return the incorrect value when Unity is located on the second screen and is not fullscreen.

Fields

Name Type Summary
ContentCache ContentCache Cache that creates UnityEngine.GUIContent instances and keeps them, reducing the garbage collection overhead.

Methods

CheckIfChanged(Action drawContent)

Draws content and checks if it was changed.

Parameter Type Description
drawContent Action Action that draws the content.

Returns

bool

Whether the content was changed.

Examples

            bool changed = EditorDrawHelper.CheckIfChanged(() =&gt;
            {
                _searchString = DrawSearchField(innerToolbarArea, _searchString);
            });
            

CreateEditor(Object targetObject)

Creates an editor of type T for targetObject.

Parameter Type Description
targetObject Object Target object to create an editor for.

Returns

T

Editor of type T.

DelayedPropertyField(SerializedProperty property, GUIContent label, GUILayoutOption[] options)

Draws the property identically to UnityEditor.EditorGUILayout.PropertyField(UnityEditor.SerializedProperty,UnityEngine.GUIContent,UnityEngine.GUILayoutOption[]) but makes fields delayed where possible.

Parameter Type Description
property SerializedProperty The SerializedProperty to make a field for.
label GUIContent Optional label to use. If not specified the label of the property itself is used. Use GUIContent.none to not display a label at all.
options GUILayoutOption[] An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the style. See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight,

Returns

bool

True if the property has children and is expanded and includeChildren was set to false; otherwise false.

DrawBorders(float rectWidth, float rectHeight, Color color, float borderWidth)

Draws borders with a given color and width around a rectangle.

Parameter Type Description
rectWidth float Width of the rectangle.
rectHeight float Height of the rectangle.
color Color Color of the borders.
borderWidth float Width of the borders.

Examples

            EditorDrawHelper.DrawBorders(position.width, position.height, DropdownStyle.BorderColor);
            

DrawInfoMessage(string message)

Shows the info message.

Parameter Type Description
message string The message to output.

Examples

EditorDrawHelper.DrawInfoMessage("No types to select.");

FocusedTextField(Rect rect, string text, string placeholder, GUIStyle style, string controlName)

Draws a text field that is always focused.

Parameter Type Description
rect Rect Rectangle to draw the field in.
text string The text to show in the field.
placeholder string Placeholder to show if the field is empty.
style GUIStyle Style to draw the field with.
controlName string Unique control name of the field.

Returns

string

The text that was written to the field.

Examples

            searchText = EditorDrawHelper.FocusedTextField(searchFieldArea, searchText, "Search",
                DropdownStyle.SearchToolbarStyle, _searchFieldControlName);
            

GetMainWindowPosition()

Returns the rectangle of the main Unity window.

Returns

Rect

Rectangle of the main Unity window.

GetScreenWidth()

Returns the same value as Screen.currentResolution.width if one screen is used. Returns the sum of two screens' widths when two monitors are used and Unity is located on the second screen. It will only return the incorrect value when Unity is located on the second screen and is not fullscreen.

Returns

float

Screen width if one monitor is used, or sum of screen widths if multiple monitors are used.

EditorIcons Class

Namespace: SolidUtilities.Editor.Helpers

Collection of icons to use for creating custom inspectors and drawers. Icons can have different tints depending on their state: active, highlighted, etc.

Examples

            var messageContent = new GUIContent(message, EditorIcons.Info);
            EditorIcon triangleIcon = Expanded ? EditorIcons.TriangleDown : EditorIcons.TriangleRight;
            

Fields

Name Type Summary
Info Texture2D The default Unity info icon.
TriangleRight EditorIcon Triangle with one of the vertices looking to the right. Useful in foldout menus.
TriangleDown EditorIcon Triangle with one of the vertices looking to the bottom. Useful in foldout menus.

FoundObject Struct

Namespace: SolidUtilities.Editor.Helpers

Represents information about object found with the matching value of a variable. It contains the object type (scene object, prefab, etc.) and details about where the variable with the matching value was found (path to the asset, the component where it was found, etc.)

Constructors

Name Summary
[FoundObject(ObjectType objectType)](#foundobjectobjecttypeobjecttype-enum-objecttype)

Methods

Name Returns Summary
Add(string key, string value) void
GetEnumerator() Enumerator

Fields

Name Type Summary
Type ObjectType

Constructors

FoundObject(ObjectType objectType)

Methods

Add(string key, string value)

GetEnumerator()

Returns

Enumerator

IndentLevel Struct

Namespace: SolidUtilities.Editor.Helpers

Constructors

Name Summary
IndentLevel(int indentLevel)

Methods

Name Returns Summary
Dispose() void

Constructors

IndentLevel(int indentLevel)

Methods

Dispose()

LogHelper Class

Namespace: SolidUtilities.Editor.Helpers

Contains different methods that simplify or extend operations on log entries.

Methods

Name Returns Summary
Clear() void Removes all logs from the console.
GetCount() int Returns the total number of log entries in the console.
GetCountByType() (int errorCount, int warningCount, int logCount) Returns the number of log entries in the console by type: error logs, warning logs, info logs.
GetErrorCount() int Returns the number of errors in the console.
GetLogCount() int Returns the number of info logs in the console.
GetWarningCount() int Returns the number of warnings in the console.
[RemoveLogEntriesByMode(LogModes mode)](#removelogentriesbymodelogmodeslogmodes-enum-mode) void Removes log entries that match mode from console.

Methods

Clear()

Removes all logs from the console.

GetCount()

Returns the total number of log entries in the console.

Returns

int

Total number of log entries in the console.

GetCountByType()

Returns the number of log entries in the console by type: error logs, warning logs, info logs.

Returns

(int errorCount, int warningCount, int logCount)

The number of log entries in the console by type: error logs, warning logs, info logs.

GetErrorCount()

Returns the number of errors in the console.

Returns

int

The number of errors in the console.

GetLogCount()

Returns the number of info logs in the console.

Returns

int

The number of info logs in the console.

GetWarningCount()

Returns the number of warnings in the console.

Returns

int

The number of warnings in the console.

RemoveLogEntriesByMode(LogModes mode)

Removes log entries that match mode from console.

Parameter Type Description
mode LogModes Mode of the log entries to remove.

LogModes Enum

Namespace: SolidUtilities.Editor.Helpers

Values

Name Summary
UserAll All user-generated log entries.
EditorErrors Editor-generated errors.
UserErrorsAndExceptions User-generated red log entries (errors, exceptions, assertions).
UserAndEditorWarnings User and editor-generated warnings.
UserAndEditorInfos User and editor-generated info messages.
NoScriptAssetWarning Mode of the "No script asset for..." warning.
UserWarning User-generated warnings.
UserInfo User-generated info messages.

MixedValue Struct

Namespace: SolidUtilities.Editor.Helpers

Sets UnityEditor.EditorGUI.showMixedValue to the needed value temporarily.

Examples

            using (new EditorDrawHelper.MixedValue(true))
            {
                DrawTypeSelectionControl();
            }
            

Constructors

Name Summary
MixedValue(bool showMixedValue) Sets UnityEditor.EditorGUI.showMixedValue to the needed value temporarily.

Methods

Name Returns Summary
Dispose() void

Constructors

MixedValue(bool showMixedValue)

Sets UnityEditor.EditorGUI.showMixedValue to the needed value temporarily.

Parameter Type Description
showMixedValue bool Whether to show mixed value.

Examples

            using (new EditorDrawHelper.MixedValue(true))
            {
                DrawTypeSelectionControl();
            }
            

Methods

Dispose()

ObjectType Enum

Namespace: SolidUtilities.Editor.Helpers

Values

Name Summary
ScriptableObject
Prefab
SceneObject
PrefabOverride

PackageSearcher Class

Namespace: SolidUtilities.Editor.Helpers

Methods

Name Returns Summary
FindPackageByName(string packageName) PackageInfo Finds a package by its UnityEditor.PackageManager.PackageInfo.name or UnityEditor.PackageManager.PackageInfo.displayName.

Methods

FindPackageByName(string packageName)

Finds a package by its UnityEditor.PackageManager.PackageInfo.name or UnityEditor.PackageManager.PackageInfo.displayName.

Parameter Type Description
packageName string UnityEditor.PackageManager.PackageInfo.name or UnityEditor.PackageManager.PackageInfo.displayName of the package to search for.

Returns

PackageInfo

Package Info object of the package or null if the package was not found.

PropertyExtensions Class

Namespace: SolidUtilities.Editor.Helpers

Methods

Name Returns Summary
Next(SerializedProperty prop, bool enterChildren, bool visible) bool

Methods

Next(SerializedProperty prop, bool enterChildren, bool visible)

Returns

bool

PropertyWrapper Struct

Namespace: SolidUtilities.Editor.Helpers

Draws content in a property wrapper, useful for making regular GUI controls work with SerializedProperty.

Constructors

Name Summary
PropertyWrapper(Rect position, GUIContent label, SerializedProperty property) Draws content in a property wrapper, useful for making regular GUI controls work with SerializedProperty.

Methods

Name Returns Summary
Dispose() void

Constructors

PropertyWrapper(Rect position, GUIContent label, SerializedProperty property)

Draws content in a property wrapper, useful for making regular GUI controls work with SerializedProperty.

Parameter Type Description
position Rect Rectangle on the screen to use for the control, including label if applicable.
label GUIContent Optional label in front of the slider. Use null to use the name from the
property SerializedProperty The SerializedProperty to use for the control.

Methods

Dispose()

ScrollView Struct

Namespace: SolidUtilities.Editor.Helpers

Draws content in an automatically laid out scroll view.

Examples

            _thumbPos = EditorDrawHelper.DrawInScrollView(_thumbPos, () =&gt;
            {
                float contentHeight = EditorDrawHelper.DrawVertically(_selectionTree.Draw, _preventExpandingHeight,
                    DropdownStyle.BackgroundColor);
            });
            

Constructors

Name Summary
ScrollView(ref Vector2 scrollPos) Draws content in an automatically laid out scroll view.
ScrollView(ref Vector2 scrollPos, bool visible) Draws content in an automatically laid out scroll view.

Methods

Name Returns Summary
Dispose() void

Constructors

ScrollView(ref Vector2 scrollPos)

Draws content in an automatically laid out scroll view.

Parameter Type Description
scrollPos ref Vector2 Position of the thumb that is changed to the new thumb position upon SolidUtilities.Editor.Helpers.EditorDrawHelper.ScrollView initialization.

ScrollView(ref Vector2 scrollPos, bool visible)

Draws content in an automatically laid out scroll view.

Parameter Type Description
scrollPos ref Vector2 Position of the thumb that is changed to the new thumb position upon SolidUtilities.Editor.Helpers.EditorDrawHelper.ScrollView initialization.
visible bool Whether scrollbar should be visible (it may not be visible if the list is short enough to fit the window.)

Methods

Dispose()

SearchToolbarStyle Struct

Namespace: SolidUtilities.Editor.Helpers

Applies the search toolbar style to the stuff that will be drawn inside.

Examples

            using (new EditorDrawHelper.SearchToolbarStyle(DropdownStyle.SearchToolbarHeight))
            {
                DrawSearchToolbar();
            }
            

Properties

Name Type Summary
Style GUIStyle

Constructors

Name Summary
SearchToolbarStyle(float toolbarHeight) Applies the search toolbar style to the stuff that will be drawn inside.

Methods

Name Returns Summary
Dispose() void

Constructors

SearchToolbarStyle(float toolbarHeight)

Applies the search toolbar style to the stuff that will be drawn inside.

Parameter Type Description
toolbarHeight float Height of the toolbar.

Examples

            using (new EditorDrawHelper.SearchToolbarStyle(DropdownStyle.SearchToolbarHeight))
            {
                DrawSearchToolbar();
            }
            

Methods

Dispose()

SRGBWriteScope Struct

Namespace: SolidUtilities.Editor.Helpers

Temporarily sets UnityEngine.GL.sRGBWrite to the passed value, then returns it back.

Constructors

Name Summary
SRGBWriteScope(bool enableWrite) Temporarily sets UnityEngine.GL.sRGBWrite to ****, then executes the action.

Methods

Name Returns Summary
Dispose() void

Constructors

SRGBWriteScope(bool enableWrite)

Temporarily sets UnityEngine.GL.sRGBWrite to ****, then executes the action.

Parameter Type Description
enableWrite bool Temporary value of UnityEngine.GL.sRGBWrite.

Examples

            using (new SRGBWriteScope(true))
            {
                GL.Clear(false, true, new Color(1f, 1f, 1f, 0f));
                Graphics.Blit(Default, temporary, material);
            });
            

Methods

Dispose()

TemporaryActiveTexture Class

Namespace: SolidUtilities.Editor.Helpers

Creates a temporary texture, sets it as active in UnityEngine.RenderTexture.active, then removes the changes and sets the previous active texture back automatically.

Examples

            using (var temporaryActiveTexture = new TemporaryActiveTexture(icon.width, icon.height, 0))
            {
                Graphics.Blit(icon, temporary, material);
            });
            

Constructors

Name Summary
TemporaryActiveTexture(int width, int height, int depthBuffer) Creates a temporary texture, sets it as active in UnityEngine.RenderTexture.active, then removes it and sets the previous active texture back automatically.

Methods

Name Returns Summary
Dispose() void

Constructors

TemporaryActiveTexture(int width, int height, int depthBuffer)

Creates a temporary texture, sets it as active in UnityEngine.RenderTexture.active, then removes it and sets the previous active texture back automatically.

Parameter Type Description
width int Width of the temporary texture in pixels.
height int Height of the temporary texture in pixels.
depthBuffer int Depth buffer of the temporary texture.

Examples

            using (var temporaryActiveTexture = new TemporaryActiveTexture(icon.width, icon.height, 0))
            {
                Graphics.Blit(icon, temporary, material);
            });
            

Methods

Dispose()

TemporaryRenderTexture Class

Namespace: SolidUtilities.Editor.Helpers

Creates a temporary texture that can be used and then removed automatically.

Examples

            using (var temporaryTexture = new TemporaryRenderTexture(icon.width, icon.height, 0))
            {
                Graphics.Blit(icon, temporaryTexture, material);
            });
            

Constructors

Name Summary
TemporaryRenderTexture(int width, int height, int depthBuffer) Creates a temporary texture that can be used and then removed automatically.

Methods

Name Returns Summary
Dispose() void

Constructors

TemporaryRenderTexture(int width, int height, int depthBuffer)

Creates a temporary texture that can be used and then removed automatically.

Parameter Type Description
width int Width of the temporary texture in pixels.
height int Height of the temporary texture in pixels.
depthBuffer int Depth buffer of the temporary texture.

Examples

            using (var temporaryTexture = new TemporaryRenderTexture(icon.width, icon.height, 0))
            {
                Graphics.Blit(icon, temporaryTexture, material);
            });
            

Methods

Dispose()

TextureHelper Class

Namespace: SolidUtilities.Editor.Helpers

Helps to create new textures.

VerticalBlock Struct

Namespace: SolidUtilities.Editor.Helpers

Draws content in the vertical direction.

Examples

             using (new EditorDrawHelper.VerticalBlock(_preventExpandingHeight, DropdownStyle.BackgroundColor, out float contentHeight))
             {
                 _selectionTree.Draw();
            
                 if (Event.current.type == EventType.Repaint)
                     _contentHeight = contentHeight;
             }
             

Constructors

Name Summary
VerticalBlock(out Rect rect) Draws content in the vertical direction.
VerticalBlock(GUILayoutOption option, Color backgroundColor, out float height) Draws content in the vertical direction.

Methods

Name Returns Summary
Dispose() void

Constructors

VerticalBlock(out Rect rect)

Draws content in the vertical direction.

Parameter Type Description
rect out Rect Rectangle of the vertical group.

Examples

            Rect newWholeListRect = EditorDrawHelper.DrawVertically(() =&gt;
            {
                for (int index = 0; index &lt; nodes.Count; ++index)
                    nodes[index].DrawSelfAndChildren(0, visibleRect);
            });
            

VerticalBlock(GUILayoutOption option, Color backgroundColor, out float height)

Draws content in the vertical direction.

Parameter Type Description
option GUILayoutOption Option to draw the vertical group with.
backgroundColor Color Background of the vertical group rectangle.
height out float Height of the vertical group rectangle.

Examples

             using (new EditorDrawHelper.VerticalBlock(_preventExpandingHeight, DropdownStyle.BackgroundColor, out float contentHeight))
             {
                 _selectionTree.Draw();
            
                 if (Event.current.type == EventType.Repaint)
                     _contentHeight = contentHeight;
             }
             

Methods

Dispose()

EditorIcon Struct

Namespace: SolidUtilities.Editor.Helpers.EditorIconsRelated

Icon that can have different tints depending on its state: active, highlighted, etc. Useful for creating custom inspectors and drawers.

Constructors

Name Summary
EditorIcon(Texture2D icon)

Fields

Name Type Summary
Default Texture2D Icon with the default color.
Active Texture2D Icon with the active state tint.
Highlighted Texture2D Icon with the highlighted state tint.

Constructors

EditorIcon(Texture2D icon)

EditorIconsDatabase Class

Namespace: SolidUtilities.Editor.Helpers.EditorIconsRelated

Base class: ScriptableObject

Scriptable object that holds references to resources needed for SolidUtilities.Editor.Helpers.EditorIcons. With this database, we only need to know a GUID of the scriptable object instead of GUIDS or paths to all the resources used in SolidUtilities.Editor.Helpers.EditorIcons.

Properties

Name Type Summary
Active Material
Highlighted Material
name string
hideFlags HideFlags

Fields

Name Type Summary
TriangleRight Texture2D

Action Enum

Namespace: SolidUtilities.Editor.PropertyDrawers

Values

Name Summary
None
Add
Remove

ConflictState Class

Namespace: SolidUtilities.Editor.PropertyDrawers

Fields

Name Type Summary
ConflictKey Object
ConflictValue Object
ConflictIndex int
ConflictOtherIndex int
ConflictKeyPropertyExpanded bool
ConflictValuePropertyExpanded bool
ConflictLineHeight float

EnumerationEntry Struct

Namespace: SolidUtilities.Editor.PropertyDrawers

Constructors

Name Summary
EnumerationEntry(SerializedProperty keyProperty, SerializedProperty valueProperty, int index)

Fields

Name Type Summary
KeyProperty SerializedProperty
ValueProperty SerializedProperty
Index int

Constructors

EnumerationEntry(SerializedProperty keyProperty, SerializedProperty valueProperty, int index)

PropertyIdentity Struct

Namespace: SolidUtilities.Editor.PropertyDrawers

Constructors

Name Summary
PropertyIdentity(SerializedProperty property)

Methods

Name Returns Summary
[Equals(Object obj)](#equalsobjecthttpsdocsmicrosoftcomen-usdotnetapisystemobject-obj) bool
[Equals(PropertyIdentity p)](#equalspropertyidentitypropertyidentity-struct-p) bool
GetHashCode() int

Constructors

PropertyIdentity(SerializedProperty property)

Methods

Equals(Object obj)

Returns

bool

Returns

bool

GetHashCode()

Returns

int

ResizableTextAreaAttributeDrawer Class

Namespace: SolidUtilities.Editor.PropertyDrawers

Base class: PropertyDrawer

Properties

Name Type Summary
Style GUIStyle
attribute PropertyAttribute
fieldInfo FieldInfo

Methods

Name Returns Summary
GetPropertyHeight(SerializedProperty property, GUIContent label) float
OnGUI(Rect fieldRect, SerializedProperty property, GUIContent label) void

Methods

GetPropertyHeight(SerializedProperty property, GUIContent label)

Returns

float

OnGUI(Rect fieldRect, SerializedProperty property, GUIContent label)

SerializableDictionaryPropertyDrawer Class

Namespace: SolidUtilities.Editor.PropertyDrawers

Base class: PropertyDrawer

Property drawer for SolidUtilities.SerializableCollections.SerializableDictionary`2.

Properties

Name Type Summary
attribute PropertyAttribute
fieldInfo FieldInfo

Methods

Name Returns Summary
GetPropertyHeight(SerializedProperty property, GUIContent label) float
OnGUI(Rect position, SerializedProperty property, GUIContent label) void

Methods

GetPropertyHeight(SerializedProperty property, GUIContent label)

Returns

float

OnGUI(Rect position, SerializedProperty property, GUIContent label)

Clone this wiki locally