本文整理汇总了C#中UnityEditor.GenericMenu类的典型用法代码示例。如果您正苦于以下问题:C# GenericMenu类的具体用法?C# GenericMenu怎么用?C# GenericMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericMenu类属于UnityEditor命名空间,在下文中一共展示了GenericMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateVCContextMenu
public static void CreateVCContextMenu(ref GenericMenu menu, string assetPath, Object instance = null)
{
if (VCUtility.ValidAssetPath(assetPath))
{
bool ready = VCCommands.Instance.Ready;
if (ready)
{
var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);
if (instance && ObjectUtilities.ChangesStoredInScene(instance)) assetPath = SceneManagerUtilities.GetCurrentScenePath();
var validActions = GetValidActions(assetPath, instance);
if (validActions.showDiff) menu.AddItem(new GUIContent(Terminology.diff), false, () => VCUtility.DiffWithBase(assetPath));
if (validActions.showAdd) menu.AddItem(new GUIContent(Terminology.add), false, () => VCCommands.Instance.Add(new[] { assetPath }));
if (validActions.showOpen) menu.AddItem(new GUIContent(Terminology.getlock), false, () => GetLock(assetPath, instance));
if (validActions.showOpenLocal) menu.AddItem(new GUIContent(Terminology.allowLocalEdit), false, () => AllowLocalEdit(assetPath, instance));
if (validActions.showForceOpen) menu.AddItem(new GUIContent("Force " + Terminology.getlock),false, () => GetLock(assetPath, instance, OperationMode.Force));
if (validActions.showCommit) menu.AddItem(new GUIContent(Terminology.commit), false, () => Commit(assetPath, instance));
if (validActions.showUnlock) menu.AddItem(new GUIContent(Terminology.unlock), false, () => VCCommands.Instance.ReleaseLock(new[] { assetPath }));
if (validActions.showDisconnect)menu.AddItem(new GUIContent("Disconnect"), false, () => PrefabHelper.DisconnectPrefab(instance as GameObject));
if (validActions.showDelete) menu.AddItem(new GUIContent(Terminology.delete), false, () => VCCommands.Instance.Delete(new[] { assetPath }));
if (validActions.showRevert) menu.AddItem(new GUIContent(Terminology.revert), false, () => Revert(assetPath, instance));
}
else
{
menu.AddDisabledItem(new GUIContent("..Busy.."));
}
}
}
示例2: GUIContent
void IHasCustomMenu.AddItemsToMenu(GenericMenu menu)
{
menu.AddItem(new GUIContent("Lock"), locked, () =>
{
locked = !locked;
});
}
示例3: MenuItem
public MenuItem(GUIContent _content, bool _separator, bool _on, GenericMenu.MenuFunction _func)
{
this.content = _content;
this.separator = _separator;
this.on = _on;
this.func = _func;
}
示例4: AddSetToValueOfTargetMenuItems
internal static void AddSetToValueOfTargetMenuItems(GenericMenu menu, SerializedProperty property, TargetChoiceHandler.TargetChoiceMenuFunction func)
{
SerializedProperty property2 = property.serializedObject.FindProperty(property.propertyPath);
UnityEngine.Object[] targetObjects = property.serializedObject.targetObjects;
List<string> list = new List<string>();
UnityEngine.Object[] array = targetObjects;
for (int i = 0; i < array.Length; i++)
{
UnityEngine.Object @object = array[i];
string text = "Set to Value of " + @object.name;
if (list.Contains(text))
{
int num = 1;
while (true)
{
text = string.Concat(new object[]
{
"Set to Value of ",
@object.name,
" (",
num,
")"
});
if (!list.Contains(text))
{
break;
}
num++;
}
}
list.Add(text);
menu.AddItem(EditorGUIUtility.TextContent(text), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.TargetChoiceForwardFunction), new PropertyAndTargetHandler(property2, @object, func));
}
}
示例5: OnContextClick
public void OnContextClick(int itemIndex)
{
GenericMenu genericMenu = new GenericMenu();
genericMenu.AddItem(new GUIContent("Unexpose"), false, (GenericMenu.MenuFunction2) (data => this.Delete((int) data)), (object) itemIndex);
genericMenu.AddItem(new GUIContent("Rename"), false, (GenericMenu.MenuFunction2) (data => this.m_ReorderableListWithRenameAndScrollView.BeginRename((int) data, 0.0f)), (object) itemIndex);
genericMenu.ShowAsContext();
}
示例6: Show
internal static void Show(int savedFilterInstanceID)
{
GUIContent content = new GUIContent("Delete");
GenericMenu genericMenu = new GenericMenu();
genericMenu.AddItem(content, false, new GenericMenu.MenuFunction(new ProjectBrowser.SavedFiltersContextMenu(savedFilterInstanceID).Delete));
genericMenu.ShowAsContext();
}
示例7: AddMenuItem
void AddMenuItem(GenericMenu mnu, string item, GenericMenu.MenuFunction func, bool enabled=true)
{
if (enabled)
mnu.AddItem(new GUIContent(item), false, func);
else
mnu.AddDisabledItem(new GUIContent(item));
}
示例8: SystemEditor
// ================================================================================================================
public SystemEditor()
{
addSceneMenu = new GenericMenu();
addSceneMenu.AddItem(new GUIContent("Browse"), false, OnAddScene, 0);
addSceneMenu.AddItem(new GUIContent("New Scene"), false, OnAddScene, 1);
for (int i = 0; i < inputSettingsFoldout.Length; i++) inputSettingsFoldout[i] = true;
}
示例9: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var left = position; left.xMax -= 40;
var right = position; right.xMin = left.xMax + 2;
EditorGUI.PropertyField(left, property);
if (GUI.Button(right, "List") == true)
{
var menu = new GenericMenu();
if (LeanLocalization.Instance != null)
{
for (var j = 0; j < LeanLocalization.Instance.Languages.Count; j++)
{
var language = LeanLocalization.Instance.Languages[j];
menu.AddItem(new GUIContent(language), property.stringValue == language, () => { property.stringValue = language; property.serializedObject.ApplyModifiedProperties(); });
}
}
if (menu.GetItemCount() > 0)
{
menu.DropDown(right);
}
else
{
Debug.LogWarning("Your scene doesn't contain any languages, so the language name list couldn't be created.");
}
}
}
示例10: AddNodeItemsToMenu
// Add menu items to a given menu.
public static void AddNodeItemsToMenu(GenericMenu menu, GenericMenu.MenuFunction2 callback)
{
if (_nodeTypes == null) EnumerateNodeTypes();
foreach (var nodeType in _nodeTypes)
menu.AddItem(nodeType.label, false, callback, nodeType.type);
}
示例11: ContextMenu
private void ContextMenu(Model instance)
{
var menu = new GenericMenu();
menu.AddItem(new GUIContent("New"), false, New);
if (instance != null) {
menu.AddItem(new GUIContent("Edit"), false, ShowEditWindow, instance);
} else {
menu.AddDisabledItem(new GUIContent("Edit"));
}
menu.AddSeparator("");
if (instance != null) {
menu.AddItem(new GUIContent("Copy"), false, Copy, instance);
} else {
menu.AddDisabledItem(new GUIContent("Copy"));
}
if (CanPaste()) {
menu.AddItem(new GUIContent("Paste"), false, Paste);
} else {
menu.AddDisabledItem(new GUIContent("Paste"));
}
if (instance != null) {
menu.AddItem(new GUIContent("Delete"), false, Delete, instance);
} else {
menu.AddDisabledItem(new GUIContent("Delete"));
}
menu.ShowAsContext();
}
示例12: AddSetToValueOfTargetMenuItems
internal static void AddSetToValueOfTargetMenuItems(GenericMenu menu, SerializedProperty property, TargetChoiceMenuFunction func)
{
SerializedProperty property2 = property.serializedObject.FindProperty(property.propertyPath);
UnityEngine.Object[] targetObjects = property.serializedObject.targetObjects;
List<string> list = new List<string>();
foreach (UnityEngine.Object obj2 in targetObjects)
{
string item = "Set to Value of " + obj2.name;
if (list.Contains(item))
{
int num2 = 1;
while (true)
{
object[] objArray1 = new object[] { "Set to Value of ", obj2.name, " (", num2, ")" };
item = string.Concat(objArray1);
if (!list.Contains(item))
{
break;
}
num2++;
}
}
list.Add(item);
menu.AddItem(EditorGUIUtility.TextContent(item), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.TargetChoiceForwardFunction), new PropertyAndTargetHandler(property2, obj2, func));
}
}
示例13: AddDefaultItemsToMenu
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view)
{
if (menu.GetItemCount() != 0)
{
menu.AddSeparator(string.Empty);
}
if (base.parent.window.showMode == ShowMode.MainWindow)
{
menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Maximize), view);
}
else
{
menu.AddDisabledItem(EditorGUIUtility.TextContent("Maximize"));
}
menu.AddItem(EditorGUIUtility.TextContent("Close Tab"), false, new GenericMenu.MenuFunction2(this.Close), view);
menu.AddSeparator(string.Empty);
System.Type[] paneTypes = base.GetPaneTypes();
GUIContent content = EditorGUIUtility.TextContent("Add Tab");
foreach (System.Type type in paneTypes)
{
if (type != null)
{
GUIContent content2;
content2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)) {
text = content.text + "/" + content2.text
};
menu.AddItem(content2, false, new GenericMenu.MenuFunction2(this.AddTabToHere), type);
}
}
}
示例14: AddItemsToMenu
public void AddItemsToMenu(GenericMenu menu)
{
if (Application.platform == RuntimePlatform.OSXEditor)
{
menu.AddItem(new GUIContent("Open Player Log"), false, new GenericMenu.MenuFunction(InternalEditorUtility.OpenPlayerConsole));
}
menu.AddItem(new GUIContent("Open Editor Log"), false, new GenericMenu.MenuFunction(InternalEditorUtility.OpenEditorConsole));
IEnumerator enumerator = Enum.GetValues(typeof(StackTraceLogType)).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
StackTraceLogType current = (StackTraceLogType) ((int) enumerator.Current);
menu.AddItem(new GUIContent("Stack Trace Logging/" + current), Application.stackTraceLogType == current, new GenericMenu.MenuFunction2(this.ToggleLogStackTraces), current);
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable == null)
{
}
disposable.Dispose();
}
}
示例15: ExtractMenuItemWithPath
public static void ExtractMenuItemWithPath(string menuString, GenericMenu menu, string replacementMenuString, UnityEngine.Object[] temporaryContext)
{
MenuUtils.MenuCallbackObject menuCallbackObject = new MenuUtils.MenuCallbackObject();
menuCallbackObject.menuItemPath = menuString;
menuCallbackObject.temporaryContext = temporaryContext;
menu.AddItem(new GUIContent(replacementMenuString), false, new GenericMenu.MenuFunction2(MenuUtils.MenuCallback), menuCallbackObject);
}