DemiEditor
Replicates Unity's GUI.Scope with Unity versions older than 5.X.
Thanks to Dmitriy Yukhanov for pointing this out and creating an initial version
(which I meant to use until we discovered Unity had implemented it too)
File utils
Path slash for AssetDatabase format
Path slash to replace for AssetDatabase format
Current OS path slash
Path slash to replace on current OS
Full path to project directory, without final slash.
Full path to project's Assets directory, without final slash.
Converts the given project-relative path to a full path
Converts the given full path to a project-relative path
Returns TRUE if the file/directory at the given path exists.
Path, relative to Unity's project folder
Converts the given string to a valid filename and returns it.
Beware: doesn't check for reserved words
Returns the asset path of the given GUID (relative to Unity project's folder),
or an empty string if either the GUID is invalid or the related path doesn't exist.
Checks if the given directory (full path) is empty or not
Deletes all files and subdirectories from the given directory
Returns the adb path to the given ScriptableObject
Returns the adb path to the given MonoBehaviour
Returns the adb directory that contains the given ScriptableObject without final slash
Returns the adb directory that contains the given MonoBehaviour without final slash
Returns the adb paths to the selected folders in the Project panel, or NULL if there is none.
Contrary to Selection.activeObject, which only returns folders selected in the right side of the panel,
this method also works with folders selected in the left side.
Sets the script execution order of the given MonoBehaviour
Gets the script execution order of the given MonoBehaviour
Utilities for Editor Panels.
Connects to a asset.
If the asset already exists at the given path, loads it and returns it.
Otherwise, depending on the given parameters, either returns NULL or automatically creates it before loading and returning it.
Asset type
File path (relative to Unity's project folder)
If TRUE and the requested asset doesn't exist, forces its creation
If TRUE also creates the path folders if they don't exist
Sets the icon and title of an editor window. Works with older versions of Unity, where the titleContent property wasn't available.
Reference to the editor panel whose icon to set
Icon to apply
Title. If NULL doesn't change it
Prefab utilities
Behaves as the Inspector's Apply button, applying any modification of this instance to the prefab parent
Completely removes any prefab connection from the given prefab instances.
Based on RodGreen's method (http://forum.unity3d.com/threads/82883-Breaking-connection-from-gameObject-to-prefab-for-good.?p=726602&viewfull=1#post726602)
Completely removes any prefab connection from the given prefab instance.
Based on RodGreen's method (http://forum.unity3d.com/threads/82883-Breaking-connection-from-gameObject-to-prefab-for-good.?p=726602&viewfull=1#post726602)
Calls the given action after the given delay
Return the size of the editor game view, eventual extra bars excluded (meaning the true size of the game area)
Clears all logs from Unity's console
Nothing is being dragged
Dragging
Dragging concluced and accepted
Dragging concluced but item position didn't change
Dragging canceled
Dragging concluced but not accepted because too short
Manages the dragging of GUI elements
True if a GUI element is currently being dragged
Return the current item being dragged, or NULL if there is none
Type of current item being dragged, or NULL if there is none
Starting index of current item being dragged, or NULL if there is none
Retrieves the eventual optional data stored via the StartDrag method
Starts a drag operation on a GUI element.
ID for this drag operation (must be the same for both StartDrag and Drag
Reference to the current editor drawing the GUI (used when a Repaint is needed)
List containing the dragged item and all other relative draggable items
DraggableList index of the item being dragged
Optional data that can be retrieved via the static property
Starts a drag operation on a GUI element.
ID for this drag operation (must be the same for both StartDrag and Drag
Reference to the current editor drawing the GUI (used when a Repaint is needed)
List containing the dragged item and all other relative draggable items
DraggableList index of the item being dragged
Optional data that can be retrieved via the static property
Call this after each draggable GUI block, to calculate and draw the current drag state
(or complete it if the mouse was released).
ID for this drag operation (must be the same for both StartDrag and Drag
List containing the draggable item and all other relative draggable items
Current index of the draggable item being drawn
Call this after each draggable GUI block, to calculate and draw the current drag state
(or complete it if the mouse was released).
ID for this drag operation (must be the same for both StartDrag and Drag
List containing the draggable item and all other relative draggable items
Current index of the draggable item being drawn
Color to use for drag divider and selection
Ends the drag operations, and eventually applies the drag outcome.
Returns TRUE if the position of the dragged item actually changed.
Called automatically by Drag method. Use it only if you want to force the end of a drag operation.
If TRUE applies the drag results, otherwise simply cancels the drag
Contains both free and pro skins GUIStyle variations,
and automatically returns the correct one when converted to GUIStyle
Plays the given clip in the Editor
Stops playing the given clip.
Stops all clips playing.
Assembly extensions
AssetDatabase path to the assembly directory, without final slash
GUI extension methods
Clones the style and adds the given formats to it. You can pass any of these types of values:
- Format:Rich-text, wordwrap
- FontStyle:Font style
- TextAnchor:Content anchor
- int:Font size
- Color/DeSkinColor:Font color
Adds the given formats to the style. You can pass any of these types of values:
- Format:RichText, WordWrap
- FontStyle:Font style
- TextAnchor:Content anchor
- int:Font size
- Color/DeSkinColor:Font color
Sets the border of the style
Sets the border of the style
Sets the background of the style
Sets the contentOffset of the style
Sets the contentOffset of the style
Sets the X contentOffset of the style
Sets the Y contentOffset of the style
Sets the margin of the style
Sets the margin of the style
Sets the margin of the style
Sets the left margin of the style
Sets the right margin of the style
Sets the top margin of the style
Sets the bottom margin of the style
Sets the overflow of the style
Sets the overflow of the style
Sets the overflow of the style
Sets the left overflow of the style
Sets the right overflow of the style
Sets the top overflow of the style
Sets the bottom overflow of the style
Sets the padding of the style
Sets the padding of the style
Sets the padding of the style
Sets the left padding of the style
Sets the right padding of the style
Sets the top padding of the style
Sets the bottom padding of the style
Sets the Y fixedWidth of the style
Sets the fixedHeight of the style
Sets the stretchHeight property of the style
Sets the stretchWidth property of the style
Stores a GUIStyle palette, which can be passed to default DeGUI layouts when calling DeGUI.BeginGUI,
and changed at any time by calling DeGUI.ChangePalette.
You can inherit from this class to create custom GUIStyle palettes with more options.
Each of the sub-options require a public Init method to initialize the styles, which will be called via Reflection.
Called automatically by DeGUI.BeginGUI.
Override when adding new style subclasses.
Extend any custom subpalettes from this, so they will be initialized correctly
GUILayout methods
Shaded button
Shaded button
Shaded button
Shaded button
Colored button
Colored button
Colored button
Colored button
Draws a button that returns TRUE the first time it's pressed, instead than when its released.
Draws a button that returns TRUE the first time it's pressed, instead than when its released.
Toolbar foldout button
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Begins an horizontal toolbar layout
Begins an horizontal toolbar layout
Begins an horizontal toolbar layout
Begins an horizontal toolbar layout
Ends an horizontal toolbar layout
A toolbar with a label
A toolbar with a label
A toolbar with a label
A toolbar with a label
A toolbar with a label
A toolbar with a label
Vertical box layout with style and color options
Vertical box layout with style and color options
End vertical box layout
Horizontal Divider
A text field that becomes editable only on double-click
EditorWindow reference
A unique ID to use in order to determine if the text is selected or not
Text
Style for default (non-editing mode) appearance
Style for editing mode
A text field that becomes editable only on double-click
Editor reference
A unique ID to use in order to determine if the text is selected or not
Text
Style for default (non-editing mode) appearance
Style for editing mode
A text field that becomes editable only on double-click and can also be dragged
EditorWindow reference
A unique ID to use in order to determine if the text is selected or not
Text
ID for this drag operation (must be the same for both this and Drag
List containing the dragged item and all other relative draggable items
DraggableList index of the item being dragged
Style for default (non-editing mode) appearance
Style for editing mode
A text field that becomes editable only on double-click and can also be dragged
Editor reference
A unique ID to use in order to determine if the text is selected or not
Text
ID for this drag operation (must be the same for both this and Drag
List containing the dragged item and all other relative draggable items
DraggableList index of the item being dragged
Style for default (non-editing mode) appearance
Style for editing mode
Creates a Gradient field by using Unity 4.x hidden default one and Reflection.
Scene field
Global Demigiant GUI manager. Call to initialize it inside GUI calls.
Default color palette
Default style palette
TRUE if we're using the PRO skin
Call this at the beginning of GUI methods
Eventual to use
Eventual to use
Exits the current event correctly, also taking care of eventual drag operations
Changes the active palettes to the given ones
(or resets them to the default ones if NULL)
Resets the GUI colors to the default ones (only available if BeginGUI was called first)
Sets the GUI colors to the given ones
Shaded button
Shaded button
Shaded button
Shaded button
Colored button
Colored button
Colored button
Colored button
Draws a button that returns TRUE the first time it's pressed, instead than when its released.
Draws a button that returns TRUE the first time it's pressed, instead than when its released.
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Button that can be toggled on and off
Scene field
Box with style and color options
Draws a colored square
A text field that becomes editable only on double-click
Area
EditorWindow reference
A unique ID to use in order to determine if the text is selected or not
Text
Style for default (non-editing mode) appearance
Style for editing mode
A text field that becomes editable only on double-click
Area
Editor reference
A unique ID to use in order to determine if the text is selected or not
Text
Style for default (non-editing mode) appearance
Style for editing mode
A text field that becomes editable only on double-click and can also be dragged
Area
EditorWindow reference
A unique ID to use in order to determine if the text is selected or not
Text
ID for this drag operation (must be the same for both this and Drag
List containing the dragged item and all other relative draggable items
DraggableList index of the item being dragged
Style for default (non-editing mode) appearance
Style for editing mode
A text field that becomes editable only on double-click and can also be dragged
Area
Editor reference
A unique ID to use in order to determine if the text is selected or not
Text
ID for this drag operation (must be the same for both this and Drag
List containing the dragged item and all other relative draggable items
DraggableList index of the item being dragged
Style for default (non-editing mode) appearance
Style for editing mode
Divider
Returns the value of the given property (works like a cast to type).
Improved from HiddenMonk's functions (http://answers.unity3d.com/questions/627090/convert-serializedproperty-to-custom-class.html)
Returns TRUE if this property is inside an array
Returns -1 if the property is not inside an array, otherwise returns its index inside the array
String extensions
If the given string is a directory path, returns its parent
with or without final slash depending on the original directory format
If the string is a directory, returns the directory name,
if instead it's a file returns its name without extension.
Works better than Path.GetDirectoryName, which kind of sucks imho
Texture extensions
Checks that the texture uses the correct import settings, and applies them if they're incorrect.