Skip to content

Instantly share code, notes, and snippets.

@kirevdokimov
Last active August 4, 2017 21:34
Show Gist options
  • Save kirevdokimov/5d6fcbae9b28d9737999b36ec4c03fa4 to your computer and use it in GitHub Desktop.
Save kirevdokimov/5d6fcbae9b28d9737999b36ec4c03fa4 to your computer and use it in GitHub Desktop.
Generic Menu
if (GUILayout.Button("Select GUI Color")){
GenericMenu menu = new GenericMenu();
// GUIContent, IsOn, listener, userData
menu.AddItem(new GUIContent(menuPath), m_Color.Equals(color), OnColorSelected, color);
...
menu.AddSeparator(""); // an empty string will create a separator at the top level
menu.AddSeparator("CMYK/"); // a trailing slash will nest a separator in a submenu
menu.ShowAsContext();
}
void OnColorSelected(object color){
m_Color = (Color)color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment