Are there still no hotkeys for changing brush size or opacity? If not, is there any way to add custom hotkeys for it? I’ve looked through all the new APIs but can’t seem to find a way to change the brush size from script.
This is probably the most frequent action performed when editing terrain, apart from clicking. I can’t really understand how the terrain tools have been missing this functionality for so long.
I don’t think anyone was working on them until recently haha. 2018.3 was mostly performance updates for Terrain. We are now working on workflow improvements which include hotkeys and SceneView controls (ala Photoshop resizer with alt + mouse move) for brush settings.
If you want to add hotkeys/controls for brush settings in your own tool, don’t use the brush settings provided by any of the Context objects we give you via OnInspectorGUI, OnPaint, and OnSceneGUI. You can just use your own and then add ClutchShortcutAttribute (from the ShortcutManager API) to a function that you want to be called when modifying a specific brush setting like so:
[ClutchShortcut("Terrain/Adjust Brush Strength (SceneView)", typeof(TerrainToolShortcutContext), KeyCode.A)]
static void StrengthBrushShortcut(ShortcutArguments args)
{
// modify brush strength here or set the state for modifying brush strength
}
So I’m using the following to perform a willy-nilly keypress in the editor to throw out a Debug.Log so I can test shortcuts, but I am finding I can’t use the IShortcutToolContext due to its protection level.
Is there anything I can do to execute a keypress globally and have it simply execute a function?
This is what I have:
using System.Collections;
using UnityEditor.ShortcutManagement;
using UnityEditor;
using UnityEditorInternal;
class ShortcutKeys : IShortcutToolContext
{
[ClutchShortcut("3D Viewport/Test" , typeof(ShortcutKeys) , KeyCode.A)]
public static void Stuff (ShortcutArguments args) {
Debug.Log("Yo");
}
There is next to zero documentation on how to actually use this API to execute a function via shortcut without being bound to a particular EditorWindow.
This error is what I’m getting:
Ignoring shortcut attribute with invalid context type ShortcutKeys on ShortcutKeys.Stuff
The context type must either be null, derive from UnityEditor.EditorWindow, or implement UnityEditor.ShortcutManagement.IShortcutToolContext.
UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes(Type[])