Shortcuts.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. /*
  2. Copyright (c) 2021 Omar Duarte
  3. Unauthorized copying of this file, via any medium is strictly prohibited.
  4. Writen by Omar Duarte, 2021.
  5. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11. THE SOFTWARE.
  12. */
  13. using UnityEngine;
  14. namespace PluginMaster
  15. {
  16. public static partial class Shortcuts
  17. {
  18. #if UNITY_2019_1_OR_NEWER
  19. public static void UpdateTooltipShortcut(GUIContent button, string tooltip, string shortcutId)
  20. {
  21. var shortcut = UnityEditor.ShortcutManagement.ShortcutManager.instance.GetShortcutBinding(shortcutId).ToString();
  22. if(shortcut != string.Empty) button.tooltip = tooltip + " ... " + shortcut;
  23. }
  24. #endif
  25. }
  26. }