Skip to content

Commit

Permalink
fix(Editor): Place menu item under tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jul 17, 2023
1 parent 562a109 commit 12c0220
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
6 changes: 5 additions & 1 deletion Assets/JCSUnity/Editor/JCSUnity_About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class JCSUnity_About : EditorWindow
{
/* Variables*/

private const string MI_BaseName = JCSUnity_EditorWindow.MI_BaseName;

public const int MI_BasePriority = JCSUnity_EditorWindow.MI_BasePriority;

/* all the .ini file located here. */
public static Dictionary<string, string> EDITOR_INI = new Dictionary<string, string>();

Expand Down Expand Up @@ -88,7 +92,7 @@ public static void ReadINIFile()
/// <summary>
/// About JCSUnity.
/// </summary>
[MenuItem("JCSUnity/About", false, 100)]
[MenuItem(MI_BaseName + "/About", false, MI_BasePriority + 100)]
public static void AboutJCSUnity()
{
var window = CreateInstance<JCSUnity_About>();
Expand Down
34 changes: 19 additions & 15 deletions Assets/JCSUnity/Editor/JCSUnity_EditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class JCSUnity_EditorWindow : EditorWindow
{
/* Variables*/

public const string MI_BaseName = "Tools/JCSUnity";

public const int MI_BasePriority = -24;

public static JCSUnity_EditorWindow instance = null;

public static string NAME
Expand All @@ -42,8 +46,8 @@ public static string NAME
private bool mFO_Input = false;
private bool mFO_Tool = false;

public string PROJECT_NAME = "";
public const string PROJECT_NAME_LASTING = "_Assets";
public string PROJECT_NAME = "_Project";
public const string PROJECT_NAME_SUFFIX = "";
public string[] ProjectSubFolders = {
"Animations",
"Editor",
Expand Down Expand Up @@ -297,7 +301,7 @@ private void Part_Tool()
/// <summary>
/// Main editor window initialize function.
/// </summary>
[MenuItem("JCSUnity/Window", false, 1)]
[MenuItem(MI_BaseName + "/Window", false, MI_BasePriority + 1)]
private static void JCSUnityEditor()
{
JCSUnity_EditorWindow window = GetWindow<JCSUnity_EditorWindow>(false, NAME, true);
Expand All @@ -307,7 +311,7 @@ private static void JCSUnityEditor()
/// <summary>
/// Serialize the current scene into 2D style.
/// </summary>
[MenuItem("JCSUnity/Scene/Convert to 2D scene", false, 2)]
[MenuItem(MI_BaseName + "/Scene/Convert to 2D scene", false, MI_BasePriority + 2)]
private static void ConvertTo2D()
{
// create settings
Expand All @@ -334,7 +338,7 @@ private static void ConvertTo2D()
/// <summary>
/// Serialize the current scene into 3D style.
/// </summary>
[MenuItem("JCSUnity/Scene/Convert to 3D scene", false, 2)]
[MenuItem(MI_BaseName + "/Scene/Convert to 3D scene", false, MI_BasePriority + 2)]
private static void ConvertTo3D()
{
// create settings
Expand All @@ -356,7 +360,7 @@ private static void ConvertTo3D()
/// <summary>
/// Create managers for 3d game combine with JCSUnity.
/// </summary>
[MenuItem("JCSUnity/Basic/Create Managers", false, 10)]
[MenuItem(MI_BaseName + "/Basic/Create Managers", false, MI_BasePriority + 10)]
private static GameObject CreateManagers()
{
const string manager_path = "JCS_Managers";
Expand All @@ -370,7 +374,7 @@ private static GameObject CreateManagers()
/// <summary>
/// Create settings for 3d game combine with JCSUnity.
/// </summary>
[MenuItem("JCSUnity/Basic/Create Settings", false, 10)]
[MenuItem(MI_BaseName + "/Basic/Create Settings", false, MI_BasePriority + 10)]
private static GameObject CreateSettings()
{
const string setting_path = "JCS_Settings";
Expand All @@ -384,7 +388,7 @@ private static GameObject CreateSettings()
/// <summary>
/// BGM player for game.
/// </summary>
[MenuItem("JCSUnity/Basic/Create BGM Player", false, 11)]
[MenuItem(MI_BaseName + "/Basic/Create BGM Player", false, MI_BasePriority + 11)]
private static void CreateBGMPlayer()
{
const string player_path = "Sound/JCS_BGMPlayer";
Expand All @@ -396,7 +400,7 @@ private static void CreateBGMPlayer()
/// <summary>
/// Debug tool using in JCSUnity.
/// </summary>
[MenuItem("JCSUnity/Basic/Create Debug Tools", false, 12)]
[MenuItem(MI_BaseName + "/Basic/Create Debug Tools", false, MI_BasePriority + 12)]
private static void CreateDebugTools()
{
const string tools_path = "Tools/JCS_Tools";
Expand All @@ -408,19 +412,19 @@ private static void CreateDebugTools()
/// <summary>
/// Create settings for 3d game combine with JCSUnity.
/// </summary>
[MenuItem("JCSUnity/Input/Update", false, 15)]
[MenuItem(MI_BaseName + "/Input/Update", false, MI_BasePriority + 15)]
private static void UpdateInputManager()
{
JCS_InputController.SetupInputManager();
}

[MenuItem("JCSUnity/Input/Clear", false, 15)]
[MenuItem(MI_BaseName + "/Input/Clear", false, MI_BasePriority + 15)]
private static void ClearInputManager()
{
JCS_InputController.ClearInputManagerSettings();
}

[MenuItem("JCSUnity/Input/Revert", false, 15)]
[MenuItem(MI_BaseName + "/Input/Revert", false, MI_BasePriority + 15)]
private static void RevertDefaultInputManager()
{
JCS_InputController.DefaultInputManagerSettings();
Expand Down Expand Up @@ -448,11 +452,11 @@ private static GameObject CreateJCSCanvas()
/// <summary>
/// Create a new project.
/// </summary>
[MenuItem("JCSUnity/Tool/Create project assets folder", false, 20)]
[MenuItem(MI_BaseName + "/Tool/Create project assets folder", false, MI_BasePriority + 20)]
private static void CreateProjectAssetsFolder()
{
string parentFolder = "Assets";
string newFolderName = instance.PROJECT_NAME + PROJECT_NAME_LASTING;
string newFolderName = instance.PROJECT_NAME + PROJECT_NAME_SUFFIX;

string assetsPath = Application.dataPath + "/";
string newProjectPath = assetsPath + newFolderName + "/";
Expand All @@ -473,7 +477,7 @@ private static void CreateProjectAssetsFolder()
/// <summary>
/// Update JCSUnity
/// </summary>
[MenuItem("JCSUnity/Check for Update", false, 75)]
[MenuItem(MI_BaseName + "/Check for Update", false, MI_BasePriority + 75)]
private static void UpdateJCSUnity()
{
// TODO(jenchieh): check framework need to update or not?
Expand Down
16 changes: 13 additions & 3 deletions Assets/JCSUnity/Editor/JCSUnity_Hotkeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ namespace JCSUnity
/// </summary>
public class JCSUnity_Hotkeys
{
/* Variables*/

private const string MI_BaseName = JCSUnity_EditorWindow.MI_BaseName + "/Hotkeys";

public const int MI_BasePriority = JCSUnity_EditorWindow.MI_BasePriority;

private static EditorWindow _mouseOverWindow;

[MenuItem("JCSUnity/Hotkeys/Select Inspector under mouse cursor (use hotkey) #&q", false, 50)]
/* Setter & Getter */

/* Functions */

[MenuItem(MI_BaseName + "/Select Inspector under mouse cursor (use hotkey) #&q", false, MI_BasePriority + 50)]
private static void SelectLockableInspector()
{
if (EditorWindow.mouseOverWindow.GetType().Name == "InspectorWindow")
Expand All @@ -36,7 +46,7 @@ private static void SelectLockableInspector()
}
}

[MenuItem("JCSUnity/Hotkeys/Toggle Lock &q", false, 50)]
[MenuItem(MI_BaseName + "/Toggle Lock &q", false, MI_BasePriority + 50)]
private static void ToggleInspectorLock()
{
if (_mouseOverWindow == null)
Expand All @@ -60,7 +70,7 @@ private static void ToggleInspectorLock()
}
}

[MenuItem("JCSUnity/Hotkeys/Clear Console #&c", false, 50)]
[MenuItem(MI_BaseName + "/Clear Console #&c", false, MI_BasePriority + 50)]
private static void ClearConsole()
{
Type type = Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditorInternal.LogEntries");
Expand Down

0 comments on commit 12c0220

Please sign in to comment.