「Unity/Editor/メニュー追加」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「CustomMenu.cs <pre> using UnityEngine; using UnityEditor; public class CustomMenu { [MenuItem("CustomMenu/CustomItem1 %i")] private static void CustomItem1()...」) |
|||
| (同じ利用者による、間の2版が非表示) | |||
| 行1: | 行1: | ||
| − | CustomMenu.cs | + | Assets/Scripts/Editor/CustomMenu.cs |
<pre> | <pre> | ||
using UnityEngine; | using UnityEngine; | ||
| 行17: | 行17: | ||
} | } | ||
</pre> | </pre> | ||
| + | |||
| + | ==namespace name 'MenuItem'エラーが出る場合== | ||
| + | 以下エラーが出るとき | ||
| + | namespace name 'MenuItem' could not be found (are you missing a using directive or an assembly reference?) | ||
| + | using UnityEditor;を追加 | ||
2021年8月6日 (金) 18:55時点における最新版
Assets/Scripts/Editor/CustomMenu.cs
using UnityEngine;
using UnityEditor;
public class CustomMenu
{
[MenuItem("CustomMenu/CustomItem1 %i")]
private static void CustomItem1()
{
Debug.Log("item1");
}
[MenuItem("CustomMenu/CustomItem2 %h")]
private static void CustomItem2()
{
Debug.Log("item2");
}
}
namespace name 'MenuItem'エラーが出る場合
以下エラーが出るとき
namespace name 'MenuItem' could not be found (are you missing a using directive or an assembly reference?)
using UnityEditor;を追加
