Skip to content

Commit

Permalink
Support unity 2019 and change menu path
Browse files Browse the repository at this point in the history
  • Loading branch information
litefeel committed May 2, 2019
1 parent 668c497 commit 5d8e83a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Editor/AlignToolsMenu.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
using UnityEditor;
#if UNITY_2019_1_OR_NEWER
using UnityEditor.ShortcutManagement;
using UnityEngine;
#endif

namespace litefeel.AlignTools
{
public static class AlignToolsMenu
{
private const string KeyboardMenuPath = "Window/Align Tools/Adjust Position By Keyboard %#K";

#if UNITY_2019_1_OR_NEWER
private const string KeyboardMenuPath = "Align Tools/Adjust Position By Keyboard";
private const string WindowMenuPath = "Window/LiteFeel/Align Tools";
#else
private const string KeyboardMenuPath = "Window/LiteFeel/Align Tools/Adjust Position By Keyboard %#K";
private const string WindowMenuPath = "Window/LiteFeel/Align Tools/Align Tools";
#endif
// Creation of window
[MenuItem("Window/Align Tools/Align Tools")]
[MenuItem(WindowMenuPath)]
private static void AlignToolsWindows()
{
AlignToolsWindow window = EditorWindow.GetWindow<AlignToolsWindow>(false, "Align Tools", true);
window.Show();
window.autoRepaintOnSceneChange = true;
}

#if UNITY_2019_1_OR_NEWER
[ClutchShortcut(KeyboardMenuPath, KeyCode.K, ShortcutModifiers.Action | ShortcutModifiers.Shift)]
private static void ToggleKeyboard(ShortcutArguments arg)
{
if (arg.stage == ShortcutStage.Begin)
Settings.AdjustPositionByKeyboard = !Settings.AdjustPositionByKeyboard;
}
#else
[MenuItem(KeyboardMenuPath, true)]
private static bool VaildToggleKeyboard()
{
Expand All @@ -26,6 +43,7 @@ private static void ToggleKeyboard()
{
Settings.AdjustPositionByKeyboard = !Menu.GetChecked(KeyboardMenuPath);
}
#endif
}
}

Expand Down
15 changes: 15 additions & 0 deletions Editor/Unity.com.litefeel.aligntools.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Unity.com.litefeel.aligntools.Editor",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
7 changes: 7 additions & 0 deletions Editor/Unity.com.litefeel.aligntools.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d8e83a

Please sign in to comment.