fix: Fixed error when executing menu item

Close #27
main
Haruki Yano 2022-11-11 12:22:16 +09:00 committed by mob-sakai
parent 0a70db88bf
commit 9f0afa19a4
1 changed files with 6 additions and 1 deletions

View File

@ -9,7 +9,12 @@ namespace Coffee.UIExtensions.Editors
[MenuItem("GameObject/UI/Unmask/Tutorial Button")] [MenuItem("GameObject/UI/Unmask/Tutorial Button")]
private static void CreateTutorialButton2(MenuCommand menuCommand) private static void CreateTutorialButton2(MenuCommand menuCommand)
{ {
EditorApplication.ExecuteMenuItem("GameObject/UI/Button"); #if UNITY_2021_2_OR_NEWER
const string menuItemName = "GameObject/UI/Legacy/Button";
#else
const string menuItemName = "GameObject/UI/Button";
#endif
EditorApplication.ExecuteMenuItem(menuItemName);
var button = Selection.activeGameObject.GetComponent<Button>(); var button = Selection.activeGameObject.GetComponent<Button>();
button.name = "Tutorial Button"; button.name = "Tutorial Button";