This commit is contained in:
陈思海 2026-04-09 16:44:43 +08:00
parent cc0cc71fb7
commit 68daaa4a1d

View File

@ -27,8 +27,11 @@ public class UXCreateHelper : Editor
return type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, types, null).Invoke(null, parameters); return type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, types, null).Invoke(null, parameters);
} }
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXImage")] [MenuItem("GameObject/UI/UXImage")]
#else
[MenuItem("GameObject/UI (Canvas)/UXImage")]
#endif
public static void CreateUXImage(MenuCommand menuCommand) public static void CreateUXImage(MenuCommand menuCommand)
{ {
Type MenuOptionsType = typeof(UnityEditor.UI.ImageEditor).Assembly.GetType("UnityEditor.UI.MenuOptions"); Type MenuOptionsType = typeof(UnityEditor.UI.ImageEditor).Assembly.GetType("UnityEditor.UI.MenuOptions");
@ -40,8 +43,11 @@ public class UXCreateHelper : Editor
image.material = AssetDatabase.LoadAssetAtPath<Material>(UXGUIConfig.UIDefaultMatPath); image.material = AssetDatabase.LoadAssetAtPath<Material>(UXGUIConfig.UIDefaultMatPath);
} }
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXToggle")] [MenuItem("GameObject/UI/UXToggle")]
#else
[MenuItem("GameObject/UI (Canvas)/UXToggle")]
#endif
public static void CreateUXToggle(MenuCommand menuCommand) public static void CreateUXToggle(MenuCommand menuCommand)
{ {
Type MenuOptionsType = typeof(UnityEditor.UI.SliderEditor).Assembly.GetType("UnityEditor.UI.MenuOptions"); Type MenuOptionsType = typeof(UnityEditor.UI.SliderEditor).Assembly.GetType("UnityEditor.UI.MenuOptions");
@ -56,7 +62,11 @@ public class UXCreateHelper : Editor
#if TEXTMESHPRO_SUPPORT #if TEXTMESHPRO_SUPPORT
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXTextMeshPro")] [MenuItem("GameObject/UI/UXTextMeshPro")]
#else
[MenuItem("GameObject/UI (Canvas)/UXTextMeshPro")]
#endif
public static void CreateUXTextMeshPro(MenuCommand menuCommand) public static void CreateUXTextMeshPro(MenuCommand menuCommand)
{ {
Type MenuOptionsType = typeof(ImageEditor).Assembly.GetType("UnityEditor.UI.MenuOptions"); Type MenuOptionsType = typeof(ImageEditor).Assembly.GetType("UnityEditor.UI.MenuOptions");
@ -67,7 +77,11 @@ public class UXCreateHelper : Editor
obj.AddComponent<UXTextMeshPro>(); obj.AddComponent<UXTextMeshPro>();
} }
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXButton")] [MenuItem("GameObject/UI/UXButton")]
#else
[MenuItem("GameObject/UI (Canvas)/UXButton")]
#endif
public static void CreateUXButton(MenuCommand menuCommand) public static void CreateUXButton(MenuCommand menuCommand)
{ {
Type MenuOptionsType = typeof(TMPro_CreateObjectMenu).Assembly.GetType("TMPro.EditorUtilities.TMPro_CreateObjectMenu"); Type MenuOptionsType = typeof(TMPro_CreateObjectMenu).Assembly.GetType("TMPro.EditorUtilities.TMPro_CreateObjectMenu");
@ -78,7 +92,11 @@ public class UXCreateHelper : Editor
obj.AddComponent<UXButton>(); obj.AddComponent<UXButton>();
} }
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXInput Field")] [MenuItem("GameObject/UI/UXInput Field")]
#else
[MenuItem("GameObject/UI (Canvas)/UXInput Field")]
#endif
public static void CreateUXInputField(MenuCommand menuCommand) public static void CreateUXInputField(MenuCommand menuCommand)
{ {
Type MenuOptionsType = typeof(TMPro_CreateObjectMenu).Assembly.GetType("TMPro.EditorUtilities.TMPro_CreateObjectMenu"); Type MenuOptionsType = typeof(TMPro_CreateObjectMenu).Assembly.GetType("TMPro.EditorUtilities.TMPro_CreateObjectMenu");
@ -100,7 +118,11 @@ public class UXCreateHelper : Editor
} }
#endif #endif
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXScrollView")] [MenuItem("GameObject/UI/UXScrollView")]
#else
[MenuItem("GameObject/UI (Canvas)/UXScrollView")]
#endif
public static void CreateUxRecyclerView() public static void CreateUxRecyclerView()
{ {
GameObject selectionObject = Selection.activeGameObject; GameObject selectionObject = Selection.activeGameObject;
@ -113,7 +135,11 @@ public class UXCreateHelper : Editor
Selection.activeGameObject = instance; Selection.activeGameObject = instance;
} }
#if UNITY_6000_3_OR_NEWER
[MenuItem("GameObject/UI/UXTemplateWindow")] [MenuItem("GameObject/UI/UXTemplateWindow")]
#else
[MenuItem("GameObject/UI (Canvas)/UXTemplateWindow")]
#endif
private static void CreateTemplateWindow() private static void CreateTemplateWindow()
{ {
GameObject selectionObject = Selection.activeGameObject; GameObject selectionObject = Selection.activeGameObject;