MonKey includes a whole range of utilities for writing Editor Commands and for Editor operations. In this section, we will go over all the utilities available.
The HotKeyManager is a class that can help you override hotkeys. If you want to specify MonKey that a key combination is used and that it should be detected in case of hotkey conflict, you can add it here. The HotKeyManager handles all the hotkeys of MonKey, and will be extended in the future.
This class provides few Utilities to make writing commands simpler.
OrderedSelectedGameObjects: While Unity does not keep track of the order with which you selected objects, MonKey does. This Enumerator can help you retrieve the first object, the last, or anything in between, which can be very useful for custom commands.
OrderedSelectedObjects: Same thing, but also contains assets that are not game objects.
OrderedSelectedTransform: Same thing for the transforms, however keep in mind that this follows the same logic as Unity's: the transforms contained are only the uppermost selected: if you select a transform and some of its children, on the parent will appear in that list.
OrderSelectionByHierarchy: Reorders the order of the selection according to the hierarchy order as displayed in the window, with an option to sort ascending or descending.
MousePosition: MonKey keeps a reference to the mouse position so that it may be accessed outside of a GUI call: this can be useful when creating scene commands.
MouseSceneRay: Returns a ray that goes from the mouse position onto the scene.
GetMouseRayCastedPosition: Returns the raycasted position of the mouse on the scene, with the possibility to ignore some objects and to apply an offset. This method outputs the normal of the collision point as well.
LastGlobalEvent: Keeps a reference to the last Event that was called on GUI, so that you may use it outside of GUI logics.
IsKeyDown: A Utility to know if a key is pressed by the user, to be used within a GUI block.
CurrentSceneView: Returns the currently focused scene view.
GetProjectWindowFocusedFolder: Returns the folder that is currently focused in the project window. Keep in mind that this is not the same as the selected folder.
CreateUndoGroup: Makes it easier to collapse few undo operations at once. Returns an undoID that you must use together with Undo.CollapseOperation.
AddCustomReservedHotKeys: If you want to associate reserved hotkeys that are used for something external to MonKey, you can specify it here, and it will appear visible in the console when a conflict happens.
AddSceneCommand: Adds a scene command to the active ones on the scene.
CallCommand: Calls a command by its name as if it would be selected in the MonKey console.
GetCommandInfo: Returns the data structure of the command of the specified name. CommandInfo contains all the information used by MonKey to display and execute the command.
OnCommandLoadingDone: An event you can register to, it will be called once all the MonKey commands are loaded.
UnRegisterQuickName: Removes the quick name specified from MonKey. Can Be useful when you want to override an already existing Quick Name
UnRegisterCommand: Removes the specified command from MonKey. Can be useful when you want to write your own custom replacement for a specific command.
Most of the commands available in MonKey are also accessible through code via the Utilities class. If you want to create a command that combines few behaviors, you may do it thanks to this! The commands are ordered by type in the following utilities:
MonkeyStyle contains all the references to MonKey's look. If you want to create your own GUI for an Auto Complete, for scene commands or for anything else, you can find here references to textures, GUI styles and Colors:
DefaultValuesUtilities contains few helper methods that are meant to return values to be used in default value methods for commands. Their names should be self explanatory enough :)
TypeManager contains references to the types in use for a fast autocomplete: you can get a type by name, and types are ordered in dictionaries by categories.
UndoUtilities contains two classes meant to help you set up Undos that store the state of objects at a given time and creates an Undo relative to that state when you call it.
AbstractUndo is a generic abstract class you can inherit to follow this Undo logic.
TransformUndo is so far the only implementation of this Undo logic: you can store the transform of objects at a given moment with Register(params Transform[] valuesToRegister), and create an Undo relative to that transform state at any time by calling RecordUndo().
This will compare the current transform values and create an undo from the registered values.
ValidationUtilities contains all the default command validation methods accessible by DefaultValidation when creating a command.
MonKey contains few extension classes for some common types that can be useful when creating commands: