本文整理汇总了C#中GenericMenu类的典型用法代码示例。如果您正苦于以下问题:C# GenericMenu类的具体用法?C# GenericMenu怎么用?C# GenericMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericMenu类属于命名空间,在下文中一共展示了GenericMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnFlowCreateMenuGUI
public override void OnFlowCreateMenuGUI(string prefix, GenericMenu menu) {
if (this.InstallationNeeded() == false) {
menu.AddSeparator(prefix);
menu.AddItem(new GUIContent(prefix + "Social"), on: false, func: () => {
this.flowEditor.CreateNewItem(() => {
var window = FlowSystem.CreateWindow(FlowWindow.Flags.IsSmall | FlowWindow.Flags.CantCompiled | FlowWindow.Flags.Tag1);
window.smallStyleDefault = "flow node 1";
window.smallStyleSelected = "flow node 1 on";
window.title = "Social";
window.rect.width = 150f;
window.rect.height = 100f;
return window;
});
});
}
}
示例2: OnAddEvent
private void OnAddEvent(){
AddTweener (Selection.activeGameObject);
if (sequence == null) {
AddSequence (tweener);
}
if (sequence.events == null) {
sequence.events= new List<EventNode>();
}
GenericMenu menu = new GenericMenu ();
//Component[] components=selectedGameObject.GetComponents<Component>();
List<Type> types = new List<Type> ();
//types.AddRange (components.Select (x => x.GetType ()));
types.AddRange (GetSupportedTypes ());
foreach (Type type in types) {
List<MethodInfo> functions= GetValidFunctions(type,!(type.IsSubclassOf(typeof(Component)) || type.IsSubclassOf(typeof(MonoBehaviour))) || selectedGameObject.GetComponent(type)==null);
foreach(MethodInfo mi in functions){
if(mi != null){
EventNode node = new EventNode ();
node.time = timeline.CurrentTime;
node.SerializedType=type;
node.method=mi.Name;
node.arguments=GetMethodArguments(mi);
menu.AddItem(new GUIContent(type.Name+"/"+mi.Name),false,AddEvent,node);
}
}
}
menu.ShowAsContext ();
}
示例3: addTrackContext
/// <summary>
/// Create and show a context menu for adding new Timeline Tracks.
/// </summary>
protected override void addTrackContext()
{
TrackGroup trackGroup = TrackGroup.Behaviour as TrackGroup;
if(trackGroup != null)
{
// Get the possible tracks that this group can contain.
List<Type> trackTypes = trackGroup.GetAllowedTrackTypes();
GenericMenu createMenu = new GenericMenu();
// Get the attributes of each track.
foreach (Type t in trackTypes)
{
MemberInfo info = t;
string label = string.Empty;
foreach (TimelineTrackAttribute attribute in info.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
{
label = attribute.Label;
break;
}
createMenu.AddItem(new GUIContent(string.Format("Add {0}", label)), false, addTrack, new TrackContextData(label, t, trackGroup));
}
createMenu.ShowAsContext();
}
}
示例4: OnAddDropDown
private void OnAddDropDown(Rect buttonRect, ReorderableList list)
{
var menu = new GenericMenu();
if (kModule._inputData.Length >= 2) return;
if (kModule._inputData.Length == 0)
{
menu.AddItem(new GUIContent("Right Hand"),
false, OnClickHandler,
new DataParams() { jointType = KinectUIHandType.Right });
menu.AddItem(new GUIContent("Left Hand"),
false, OnClickHandler,
new DataParams() { jointType = KinectUIHandType.Left });
}
else if (kModule._inputData.Length == 1)
{
DataParams param;
string name;
if (kModule._inputData[0].trackingHandType == KinectUIHandType.Left){
param = new DataParams() { jointType = KinectUIHandType.Right };
name = "Right Hand";
}
else
{
param = new DataParams() { jointType = KinectUIHandType.Left };
name = "Left Hand";
}
menu.AddItem(new GUIContent(name),false, OnClickHandler, param);
}
menu.ShowAsContext();
}
示例5: OnGUI
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
//SerializedProperty me = prop.FindPropertyRelative("this");
//SerializedProperty scale = prop.FindPropertyRelative("scale");
//SerializedProperty curve = prop.FindPropertyRelative("curve");
//EditorGUI.LabelField(pos, "hi" + resources);
var rowRect = new Rect(pos.x, pos.y, pos.width, base.GetPropertyHeight(prop, label));
isFoldedOut = EditorGUI.Foldout(new Rect(rowRect.x, rowRect.y, rowRect.width - 20, rowRect.height), isFoldedOut, "Resources");
if (isFoldedOut) {
var resources = prop.FindPropertyRelative("Resources");
if (GUI.Button(new Rect(rowRect.x + rowRect.width - 22, rowRect.y + 1, 22, rowRect.height - 2), "+")) {
resources.InsertArrayElementAtIndex(resources.arraySize);
}
rowRect.y += rowRect.height;
for (int i = 0; i < resources.arraySize; ++i) {
var item = resources.GetArrayElementAtIndex(i);
var minusClick = GUI.Button(new Rect(rowRect.x, rowRect.y, 22, rowRect.height), "-");
EditorGUI.PropertyField(new Rect(rowRect.x + 20, rowRect.y, rowRect.width - 21, rowRect.height), item);
if (minusClick) {
if (Event.current.button == 1) {
// Now create the menu, add items and show it
var menu = new GenericMenu();
if (i > 0)
menu.AddItem(new GUIContent("Move Up"), false, (itm) => { resources.MoveArrayElement((int)itm, (int)itm - 1); }, i);
if (i < resources.arraySize - 1)
menu.AddItem(new GUIContent("Move Down"), false, (itm) => { resources.MoveArrayElement((int)itm, (int)itm + 1); }, i);
menu.ShowAsContext();
} else {
resources.DeleteArrayElementAtIndex(i--);
}
}
rowRect.y += rowRect.height;
}
}
}
示例6: OnGUI
void OnGUI()
{
Rect curWindowRect = EditorGUILayout.BeginVertical();
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
{
// Create drop down
Rect createBtnRect = GUILayoutUtility.GetRect(new GUIContent("Create"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
if (GUI.Button(createBtnRect, "Create", EditorStyles.toolbarDropDown))
{
GenericMenu menu = new GenericMenu();
menu.DropDown(createBtnRect);
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
BuildSettingEditor.Show();
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
示例7: showHeaderContextMenu
protected override void showHeaderContextMenu()
{
GenericMenu createMenu = new GenericMenu();
createMenu.AddItem(new GUIContent("Select"), false, focusActor);
createMenu.AddItem(new GUIContent("Delete"), false, delete);
createMenu.ShowAsContext();
}
示例8: GetSettingsMenu
public override GenericMenu GetSettingsMenu(GenericMenu menu) {
if (menu == null) menu = new GenericMenu();
menu.AddItem(new GUIContent("Reinstall"), false, () => { this.Reinstall(); });
return menu;
}
示例9: updateHeaderControl3
private int controlID; // The control ID for this track control.
/// <summary>
/// Header Control 3 is typically the "Add" control.
/// </summary>
/// <param name="position">The position that this control is drawn at.</param>
protected override void updateHeaderControl3(UnityEngine.Rect position)
{
TimelineTrack track = TargetTrack.Behaviour as TimelineTrack;
if (track == null) return;
Color temp = GUI.color;
GUI.color = (track.GetTimelineItems().Length > 0) ? Color.green : Color.red;
controlID = GUIUtility.GetControlID(track.GetInstanceID(), FocusType.Passive, position);
if (GUI.Button(position, string.Empty, TrackGroupControl.styles.addIcon))
{
// Get the possible items that this track can contain.
List<Type> trackTypes = track.GetAllowedCutsceneItems();
if (trackTypes.Count == 1)
{
// Only one option, so just create it.
ContextData data = getContextData(trackTypes[0]);
if (data.PairedType == null)
{
addCutsceneItem(data);
}
else
{
showObjectPicker(data);
}
}
else if (trackTypes.Count > 1)
{
// Present context menu for selection.
GenericMenu createMenu = new GenericMenu();
foreach (Type t in trackTypes)
{
ContextData data = getContextData(t);
createMenu.AddItem(new GUIContent(string.Format("{0}/{1}", data.Category, data.Label)), false, addCutsceneItem, data);
}
createMenu.ShowAsContext();
}
}
// Handle the case where the object picker has a value selected.
if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "ObjectSelectorClosed")
{
if (EditorGUIUtility.GetObjectPickerControlID() == controlID)
{
UnityEngine.Object pickedObject = EditorGUIUtility.GetObjectPickerObject();
if(pickedObject != null)
addCutsceneItem(savedData, pickedObject);
Event.current.Use();
}
}
GUI.color = temp;
}
示例10: OpenContextMenu
void OpenContextMenu()
{
GenericMenu menu = new GenericMenu();
menu.AddItem (new GUIContent("Open As Floating Window", ""), false, Menu_OpenAsFloatingWindow);
menu.AddItem (new GUIContent("Open As Dockable Window", ""), false, Menu_OpenAsDockableWindow);
menu.ShowAsContext ();
}
示例11: ClearConnectionMenu
public void ClearConnectionMenu()
{
GenericMenu menu = new GenericMenu ();
menu.AddSeparator ("ARE YOU SURE YOU WANT TO CLEAR?");
menu.AddSeparator ("");
menu.AddItem(new GUIContent ("Clear"), false, ClearConnections, "");
menu.AddItem(new GUIContent ("Don't Clear"), false, DontClearConnections, "");
menu.ShowAsContext ();
}
示例12: DrawAddTabGUI
public static void DrawAddTabGUI(List<AlloyTabAdd> tabsToAdd) {
if (tabsToAdd.Count <= 0) {
return;
}
GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
GUILayout.Label("");
var rect = GUILayoutUtility.GetLastRect();
rect.x -= 35.0f;
rect.width += 10.0f;
GUI.color = Color.clear;
bool add = GUI.Button(rect, new GUIContent(""), "Box");
GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
Rect subRect = rect;
foreach (var tab in tabsToAdd) {
GUI.color = tab.Color;
GUI.Box(subRect, "", "ShurikenModuleTitle");
subRect.x += rect.width / tabsToAdd.Count;
subRect.width -= rect.width / tabsToAdd.Count;
}
GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
var delRect = rect;
delRect.xMin = rect.xMax;
delRect.xMax += 40.0f;
if (GUI.Button(delRect, "", "ShurikenModuleTitle") || add) {
var menu = new GenericMenu();
foreach (var tab in tabsToAdd) {
menu.AddItem(new GUIContent(tab.Name), false, tab.Enable);
}
menu.ShowAsContext();
}
delRect.x += 10.0f;
GUI.Label(delRect, "+");
rect.x += EditorGUIUtility.currentViewWidth / 2.0f - 30.0f;
// Ensures tab text is always white, even when using light skin in pro.
GUI.color = EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.9f, 0.9f, 0.9f);
GUI.Label(rect, "Add tab", EditorStyles.whiteLabel);
GUI.color = Color.white;
}
示例13: OnEnable
private void OnEnable() {
list = new ReorderableList(serializedObject,
serializedObject.FindProperty("Waves"),
true, true, true, true);
list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
var element = list.serializedProperty.GetArrayElementAtIndex(index);
rect.y += 2;
EditorGUI.PropertyField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Type"), GUIContent.none);
EditorGUI.PropertyField(new Rect(rect.x + 60, rect.y, rect.width - 60 - 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Prefab"), GUIContent.none);
EditorGUI.PropertyField(new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Count"), GUIContent.none);
};
list.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "Monster Waves");
};
list.onSelectCallback = (ReorderableList l) => {
var prefab = l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("Prefab").objectReferenceValue as GameObject;
if (prefab) EditorGUIUtility.PingObject(prefab.gameObject);
};
list.onCanRemoveCallback = (ReorderableList l) => {
return l.count > 1;
};
list.onRemoveCallback = (ReorderableList l) => {
if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete the wave?", "Yes", "No"))
{
ReorderableList.defaultBehaviours.DoRemoveButton(l);
}
};
list.onAddCallback = (ReorderableList l) => {
var index = l.serializedProperty.arraySize;
l.serializedProperty.arraySize++;
l.index = index;
var element = l.serializedProperty.GetArrayElementAtIndex(index);
element.FindPropertyRelative("Type").enumValueIndex = 0;
element.FindPropertyRelative("Count").intValue = 20;
element.FindPropertyRelative("Prefab").objectReferenceValue = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Mobs/Cube.prefab", typeof(GameObject)) as GameObject;
};
list.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
var menu = new GenericMenu();
var guids = AssetDatabase.FindAssets("", new[]{"Assets/Prefabs/Mobs"});
foreach (var guid in guids) {
var path = AssetDatabase.GUIDToAssetPath(guid);
menu.AddItem(new GUIContent("Mobs/" + Path.GetFileNameWithoutExtension(path)), false, clickHandler, new WaveCreationParams() {Type = MobWave.WaveType.Mobs, Path = path});
}
guids = AssetDatabase.FindAssets("", new[]{"Assets/Prefabs/Bosses"});
foreach (var guid in guids) {
var path = AssetDatabase.GUIDToAssetPath(guid);
menu.AddItem(new GUIContent("Bosses/" + Path.GetFileNameWithoutExtension(path)), false, clickHandler, new WaveCreationParams() {Type = MobWave.WaveType.Boss, Path = path});
}
menu.ShowAsContext();
};
}
示例14: OnGUI
void OnGUI()
{
windowRect = new Rect(0, 0, Screen.width, Screen.height);
if(Event.current.type == EventType.ContextClick)
{
Vector2 mousePos = Event.current.mousePosition;
if(windowRect.Contains(mousePos))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("CreateCube"), false, createMenu, "createCube");
menu.ShowAsContext();
}
}
}
示例15: Selector
void Selector(SerializedProperty property) {
SpineSlot attrib = (SpineSlot)attribute;
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
if (data == null)
return;
GenericMenu menu = new GenericMenu();
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
menu.AddSeparator("");
for (int i = 0; i < data.Slots.Count; i++) {
string name = data.Slots.Items[i].Name;
if (name.StartsWith(attrib.startsWith)) {
if (attrib.containsBoundingBoxes) {
int slotIndex = i;
List<Attachment> attachments = new List<Attachment>();
foreach (var skin in data.Skins) {
skin.FindAttachmentsForSlot(slotIndex, attachments);
}
bool hasBoundingBox = false;
foreach (var attachment in attachments) {
if (attachment is BoundingBoxAttachment) {
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
hasBoundingBox = true;
break;
}
}
if (!hasBoundingBox)
menu.AddDisabledItem(new GUIContent(name));
} else {
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
}
}
}
menu.ShowAsContext();
}