Skip to content

Instantly share code, notes, and snippets.

@nakamura001
Created April 4, 2017 12:21
Show Gist options
  • Save nakamura001/030d3ea181f72313837fae9649c4979b to your computer and use it in GitHub Desktop.
Save nakamura001/030d3ea181f72313837fae9649c4979b to your computer and use it in GitHub Desktop.
Unityのエディタ拡張でメニューにチェックを付けるサンプル
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class MenuExpansion : MonoBehaviour {
const string kSampleMenuPath = "Test/Select";
static bool sampleFlag = false; // デフォルトがチェック済みの時には true にする
[MenuItem(kSampleMenuPath)]
public static void SampleMenu ()
{
sampleFlag = !sampleFlag;
Menu.SetChecked(kSampleMenuPath, sampleFlag);
}
[MenuItem(kSampleMenuPath, true)]
public static bool TestMenuValidate ()
{
Menu.SetChecked(kSampleMenuPath, sampleFlag);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment