void DrawToolGUI(Rect rect, System.Type brushType, bool haveBrush) { GUI.backgroundColor = (haveBrush && (currentTool.GetType() == brushType)) ? Color.gray : Color.white; Texture2D brushIcon = Resources.Load(brushType.Name) as Texture2D; GUI.contentColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; if (GUI.Button(rect, brushIcon, "LargeButtonRight")) { SelectTool(brushType, haveBrush); Event.current.Use(); } GUI.backgroundColor = Color.white; ToolKeyCodeAttribute attribute = brushType.GetCustomAttribute(typeof(ToolKeyCodeAttribute)) as ToolKeyCodeAttribute; var brushKey = attribute.keyCode; Rect info = new Rect(rect.x + 25, rect.y + 5f, rect.width + 80, rect.height); GUI.contentColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; string buttonInfo = " [" + brushKey.ToString() + "] - " + brushType.Name.Replace("Tool", ""); var labelRect = GUILayoutUtility.GetRect(new GUIContent(buttonInfo), "label", GUILayout.ExpandWidth(false)); string barStyle = (haveBrush && (currentTool.GetType() == brushType)) ? "ChannelStripAttenuationBar" : "ChannelStripEffectBar"; GUI.Box(new Rect(info.position, labelRect.size + Vector2.up * 2.5f), "", new GUIStyle(barStyle)); GUI.Label(new Rect(info.position - Vector2.up * 2, labelRect.size), buttonInfo, new GUIStyle("MiniBoldLabel")); GUI.contentColor = Color.white; }
void Shortcuts() { var e = Event.current; if (e.type != EventType.KeyDown) { return; } for (int i = 0; i < possibleTools.Length; i++) { ToolKeyCodeAttribute attribute = possibleTools[i].GetCustomAttribute(typeof(ToolKeyCodeAttribute)) as ToolKeyCodeAttribute; var brushKey = attribute.keyCode; if (e.keyCode == brushKey) { SelectTool(possibleTools[i], currentTool != null); blockToggle = currentTool != null; if (blockToggle) { Selection.activeGameObject = null; } e.Use(); } } }