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(); }
/// <summary> /// Shows a context menu to add a new parent. /// </summary> void OnContextMenu() { var menu = new UnityEditor.GenericMenu(); // Get the active game object var gameObject = Selection.activeGameObject; // The selected game object is not null? if (gameObject != null) { // Gets all scripts that inherits from ParentBehaviour class MonoScript[] scripts = FileUtility.GetScripts <ParentBehaviour>(); for (int i = 0; i < scripts.Length; i++) { var type = scripts[i].GetClass(); // Get the component path string componentPath = "Add Parent/"; AddComponentMenu componentMenu = AttributeUtility.GetAttribute <AddComponentMenu>(type, false); if (componentMenu == null || componentMenu.componentMenu != string.Empty) { componentMenu = AttributeUtility.GetAttribute <AddComponentMenu>(type, true); if (componentMenu != null && componentMenu.componentMenu != string.Empty) { componentPath += componentMenu.componentMenu; } else { componentPath += type.ToString().Replace('.', '/'); } // Add to menu menu.AddItem(new GUIContent(componentPath), false, delegate() { BehaviourWindow.activeParent = StateUtility.AddState(gameObject, type) as ParentBehaviour; }); } } } else { menu.AddDisabledItem(new GUIContent("Add Parent/")); ShowNotification(new GUIContent("Select a Game Object and right click in this window!")); } // Add option to paste states if (Selection.activeGameObject != null && StateUtility.statesToPaste != null && StateUtility.statesToPaste.Length > 0) { menu.AddItem(new GUIContent("Paste State"), false, delegate() { StateUtility.CloneStates(Selection.activeGameObject, StateUtility.statesToPaste, null); }); } else { menu.AddDisabledItem(new GUIContent("Paste State")); } // Refresh window? // menu.AddSeparator(""); // menu.AddItem(new GUIContent("Refresh"), false ,Refresh); // Shows the controller menu menu.ShowAsContext(); }
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); } } }
//yeah this is very special but.... public static void ShowConfiguredTypeSelectionMenu(Type type, Action <Type> callback, bool showInterfaces = true) { GenericMenu.MenuFunction2 Selected = delegate(object t){ callback((Type)t); }; var menu = new UnityEditor.GenericMenu(); foreach (System.Type t in NCPrefs.GetCommonlyUsedTypes(typeof(object))) { if (type.IsAssignableFrom(t) || (t.IsInterface && showInterfaces)) { var category = "Classes/"; if (t.IsInterface) { category = "Interfaces/"; } if (t.IsEnum) { category = "Enumerations/"; } var nsString = string.IsNullOrEmpty(t.Namespace)? "No Namespace/" : (t.Namespace.Replace(".", "/") + "/"); menu.AddItem(new GUIContent(category + nsString + TypeName(t)), false, Selected, t); } } menu.AddDisabledItem(new GUIContent("Add more in Type Configurator")); menu.ShowAsContext(); Event.current.Use(); }
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)); }
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..")); } } }
public void AddItemsToMenu(GenericMenu menu) { menu.AddItem(m_GUIRunOnRecompile, m_Settings.runOnRecompilation, ToggleRunOnRecompilation); menu.AddItem(m_GUIRunTestsOnNewScene, m_Settings.runTestOnANewScene, m_Settings.ToggleRunTestOnANewScene); if(!m_Settings.runTestOnANewScene) menu.AddDisabledItem(m_GUIAutoSaveSceneBeforeRun); else menu.AddItem(m_GUIAutoSaveSceneBeforeRun, m_Settings.autoSaveSceneBeforeRun, m_Settings.ToggleAutoSaveSceneBeforeRun); menu.AddItem(m_GUIShowDetailsBelowTests, m_Settings.horizontalSplit, m_Settings.ToggleHorizontalSplit); }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(this.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), (object) view); menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); menu.AddSeparator(string.Empty); System.Type[] paneTypes = this.GetPaneTypes(); GUIContent guiContent = EditorGUIUtility.TextContent("Add Tab"); foreach (System.Type t in paneTypes) { if (t != null) { GUIContent content = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(t)); content.text = guiContent.text + "/" + content.text; menu.AddDisabledItem(content); } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), view); menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); menu.AddSeparator(""); Type[] paneTypes = base.GetPaneTypes(); GUIContent content = EditorGUIUtility.TextContent("Add Tab"); foreach (Type type in paneTypes) { if (type != null) { GUIContent content2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)); content2.text = content.text + "/" + content2.text; menu.AddDisabledItem(content2); } } }
internal static void Show(SerializedProperty prop) { GUIContent content1 = new GUIContent("Copy"); GUIContent content2 = new GUIContent("Paste"); GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(content1, false, new GenericMenu.MenuFunction(new GradientContextMenu(prop).Copy)); if (ParticleSystemClipboard.HasSingleGradient()) genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(new GradientContextMenu(prop).Paste)); else genericMenu.AddDisabledItem(content2); genericMenu.ShowAsContext(); }
public static void DiaplayVCContextMenu(string assetPath, Object instance = null, float xoffset = 0.0f, float yoffset = 0.0f, bool showAssetName = false) { var menu = new GenericMenu(); if (showAssetName) { menu.AddDisabledItem(new GUIContent(Path.GetFileName(assetPath))); menu.AddSeparator(""); } CreateVCContextMenu(ref menu, assetPath, instance); menu.DropDown(new Rect(Event.current.mousePosition.x + xoffset, Event.current.mousePosition.y + yoffset, 0.0f, 0.0f)); Event.current.Use(); }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(string.Empty); } menu.AddItem(EditorGUIUtility.TextContent("DockAreaMaximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), view); menu.AddDisabledItem(EditorGUIUtility.TextContent("DockAreaCloseTab")); menu.AddSeparator(string.Empty); Type[] paneTypes = base.GetPaneTypes(); GUIContent gUIContent = EditorGUIUtility.TextContent("DockAreaAddTab"); Type[] array = paneTypes; for (int i = 0; i < array.Length; i++) { Type type = array[i]; if (type != null) { GUIContent gUIContent2 = new GUIContent(EditorGUIUtility.TextContent(type.ToString())); gUIContent2.text = gUIContent.text + "/" + gUIContent2.text; menu.AddDisabledItem(gUIContent2); } } }
/************************************************************************************************************************/ /// <summary>Adds the details of this state to the menu.</summary> protected override void AddContextMenuFunctions(UnityEditor.GenericMenu menu) { menu.AddDisabledItem(new GUIContent(DetailsPrefix + "Animation Type: " + Editor.AnimancerEditorUtilities.GetAnimationType(Target._Clip))); base.AddContextMenuFunctions(menu); menu.AddItem(new GUIContent("Inverse Kinematics/Apply Animator IK"), Target.ApplyAnimatorIK, () => Target.ApplyAnimatorIK = !Target.ApplyAnimatorIK); menu.AddItem(new GUIContent("Inverse Kinematics/Apply Foot IK"), Target.ApplyFootIK, () => Target.ApplyFootIK = !Target.ApplyFootIK); }
protected virtual void AddColumnVisibilityItems(GenericMenu menu) { for (int i = 0; i < this.state.columns.Length; i++) { MultiColumnHeaderState.Column column = this.state.columns[i]; if (column.allowToggleVisibility) { menu.AddItem(new GUIContent(column.headerText), Enumerable.Contains<int>(this.state.visibleColumns, i), new GenericMenu.MenuFunction2(this.ToggleVisibility), i); } else { menu.AddDisabledItem(new GUIContent(column.headerText)); } } }
public override void OnFlowToolsMenuGUI(string prefix, GenericMenu menu) { menu.AddSeparator(prefix); #if WEBPLAYER menu.AddDisabledItem(new GUIContent("Compile UI...")); #else menu.AddItem(new GUIContent(prefix + "Compile UI..."), on: false, func: () => { Compiler.ShowEditor(null, null); }); #endif }
internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor) { GUIContent content1 = new GUIContent("Copy"); GUIContent content2 = new GUIContent("Paste"); GenericMenu genericMenu = new GenericMenu(); bool flag1 = property != null && property2 != null; bool flag2 = flag1 && ParticleSystemClipboard.HasDoubleAnimationCurve() || !flag1 && ParticleSystemClipboard.HasSingleAnimationCurve(); AnimationCurveContextMenu curveContextMenu = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor); genericMenu.AddItem(content1, false, new GenericMenu.MenuFunction(curveContextMenu.Copy)); if (flag2) genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(curveContextMenu.Paste)); else genericMenu.AddDisabledItem(content2); genericMenu.DropDown(position); }
private void DrawItemMenu() { if (GUILayout.Button("Menu", "MiniPullDown", GUILayout.Width(56))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("New Item"), false, AddNewItem); if (template.treatItemsAsQuests) { menu.AddItem(new GUIContent("New Quest"), false, AddNewQuest); } else { menu.AddDisabledItem(new GUIContent("New Quest")); } menu.AddItem(new GUIContent("Use Quest System"), template.treatItemsAsQuests, ToggleUseQuestSystem); menu.AddItem(new GUIContent("Sort/By Name"), false, SortItemsByName); menu.AddItem(new GUIContent("Sort/By ID"), false, SortItemsByID); menu.AddItem(new GUIContent("Sync From DB"), database.syncInfo.syncItems, ToggleSyncItemsFromDB); menu.ShowAsContext(); } }
internal static void Show(Rect activatorRect, List<ExposablePopupMenu.ItemData> buttonData, ExposablePopupMenu caller) { ExposablePopupMenu.PopUpMenu.m_Data = buttonData; ExposablePopupMenu.PopUpMenu.m_Caller = caller; GenericMenu genericMenu = new GenericMenu(); foreach (ExposablePopupMenu.ItemData current in ExposablePopupMenu.PopUpMenu.m_Data) { if (current.m_Enabled) { genericMenu.AddItem(current.m_GUIContent, current.m_On, new GenericMenu.MenuFunction2(ExposablePopupMenu.PopUpMenu.SelectionCallback), current); } else { genericMenu.AddDisabledItem(current.m_GUIContent); } } genericMenu.DropDown(activatorRect); }
internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor) { GUIContent content = new GUIContent("Copy"); GUIContent content2 = new GUIContent("Paste"); GenericMenu menu = new GenericMenu(); bool flag = (property != null) && (property2 != null); bool flag2 = (flag && ParticleSystemClipboard.HasDoubleAnimationCurve()) || (!flag && ParticleSystemClipboard.HasSingleAnimationCurve()); AnimationCurveContextMenu menu2 = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor); menu.AddItem(content, false, new GenericMenu.MenuFunction(menu2.Copy)); if (flag2) { menu.AddItem(content2, false, new GenericMenu.MenuFunction(menu2.Paste)); } else { menu.AddDisabledItem(content2); } menu.DropDown(position); }
public static void Show(Rect buttonRect, string[] classNames, int initialSelectedInstanceID) { GenericMenu genericMenu = new GenericMenu(); List<UnityEngine.Object> list = AssetSelectionPopupMenu.FindAssetsOfType(classNames); if (list.Any<UnityEngine.Object>()) { list.Sort((UnityEngine.Object result1, UnityEngine.Object result2) => EditorUtility.NaturalCompare(result1.name, result2.name)); foreach (UnityEngine.Object current in list) { GUIContent content = new GUIContent(current.name); bool on = current.GetInstanceID() == initialSelectedInstanceID; genericMenu.AddItem(content, on, new GenericMenu.MenuFunction2(AssetSelectionPopupMenu.SelectCallback), current); } } else { genericMenu.AddDisabledItem(new GUIContent("No Audio Mixers found in this project")); } genericMenu.DropDown(buttonRect); }
public static void Show(Rect buttonRect, string[] classNames, int initialSelectedInstanceID) { GenericMenu genericMenu = new GenericMenu(); List<UnityEngine.Object> assetsOfType = AssetSelectionPopupMenu.FindAssetsOfType(classNames); if (assetsOfType.Any<UnityEngine.Object>()) { assetsOfType.Sort((Comparison<UnityEngine.Object>) ((result1, result2) => EditorUtility.NaturalCompare(result1.name, result2.name))); using (List<UnityEngine.Object>.Enumerator enumerator = assetsOfType.GetEnumerator()) { while (enumerator.MoveNext()) { UnityEngine.Object current = enumerator.Current; GUIContent content = new GUIContent(current.name); bool on = current.GetInstanceID() == initialSelectedInstanceID; genericMenu.AddItem(content, on, new GenericMenu.MenuFunction2(AssetSelectionPopupMenu.SelectCallback), (object) current); } } } else genericMenu.AddDisabledItem(new GUIContent("No Audio Mixers found in this project")); genericMenu.DropDown(buttonRect); }
/// <summary> /// Show the node menu. /// <param name="node">The target node.</param> /// </summary> void NodeContextMenu(ActionNode node) { // Validate Paramenters if (node == null) { return; } // Create the menu var menu = new UnityEditor.GenericMenu(); // Copy/Cut/Paste/Duplicate menu.AddItem(new GUIContent("Copy"), false, delegate() { BehaviourTreeUtility.nodeToPaste = node; }); menu.AddItem(new GUIContent("Cut"), false, delegate() { BehaviourTreeUtility.nodeToPaste = node; OnDestroyNode(node); }); ActionNode[] nodesToPaste = ActionStateUtility.GetActionsAndConditions(BehaviourTreeUtility.nodeToPaste != null ? new ActionNode[] { BehaviourTreeUtility.nodeToPaste } : new ActionNode[0]); if (nodesToPaste.Length > 0) { menu.AddItem(new GUIContent("Paste"), false, delegate() { ActionStateUtility.PasteNodes(m_ActionState, nodesToPaste); }); } else { menu.AddDisabledItem(new GUIContent("Paste")); } menu.AddItem(new GUIContent("Duplicate"), false, delegate() { ActionStateUtility.PasteNodes(m_ActionState, new ActionNode[] { node }); }); // Separator menu.AddSeparator(""); // Delete menu.AddItem(new GUIContent("Delete"), false, delegate() { this.OnDestroyNode(node); }); // Show the context menu menu.ShowAsContext(); }
//This is called outside Begin/End Windows from GraphEditor. void ShowToolbar(Event e) { var owner = this.agent != null && agent is GraphOwner && (agent as GraphOwner).graph == this? (GraphOwner)agent : null; GUILayout.BeginHorizontal(EditorStyles.toolbar); GUI.backgroundColor = new Color(1f,1f,1f,0.5f); ///FILE if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50))){ var menu = new GenericMenu(); #if !UNITY_WEBPLAYER //Import JSON menu.AddItem (new GUIContent ("Import JSON"), false, ()=> { if (allNodes.Count > 0 && !EditorUtility.DisplayDialog("Import Graph", "All current graph information will be lost. Are you sure?", "YES", "NO")) return; var path = EditorUtility.OpenFilePanel( string.Format("Import '{0}' Graph", this.GetType().Name), "Assets", exportFileExtension); if (!string.IsNullOrEmpty(path)){ if ( this.Deserialize( System.IO.File.ReadAllText(path), true, null ) == null){ //true: validate, null: this._objectReferences EditorUtility.DisplayDialog("Import Failure", "Please read the logs for more information", "OK", ""); } } }); //Expot JSON menu.AddItem (new GUIContent ("Export JSON"), false, ()=> { var path = EditorUtility.SaveFilePanelInProject (string.Format("Export '{0}' Graph", this.GetType().Name), "", exportFileExtension, ""); if (!string.IsNullOrEmpty(path)){ System.IO.File.WriteAllText( path, this.Serialize(true, null) ); //true: pretyJson, null: this._objectReferences AssetDatabase.Refresh(); } }); #else menu.AddDisabledItem(new GUIContent("Import JSON (not possible with webplayer active platform)")); menu.AddDisabledItem(new GUIContent("Export JSON (not possible with webplayer active platform)")); #endif menu.ShowAsContext(); } ///EDIT if (GUILayout.Button("Edit", EditorStyles.toolbarDropDown, GUILayout.Width(50))){ var menu = new GenericMenu(); //Bind if (!Application.isPlaying && owner != null && !owner.graphIsLocal){ menu.AddItem(new GUIContent("Bind To Owner"), false, ()=> { if (EditorUtility.DisplayDialog("Bind To Owner", "This will create a local copy of the graph binded to the owner.\nIt will allow you to assign direct scene references in the graph.\nContinue?", "YES", "NO")){ var newGraph = (Graph)EditorUtils.AddScriptableComponent(owner.gameObject, owner.graphType); newGraph.hideFlags = HideFlags.HideInInspector; EditorUtility.CopySerialized(owner.graph, newGraph); newGraph.Validate(); Undo.RegisterCreatedObjectUndo(newGraph, "New Local Graph"); Undo.RecordObject(owner, "New Local Graph"); owner.graph = newGraph; EditorUtility.SetDirty(owner); EditorUtility.SetDirty(newGraph); } }); } else menu.AddDisabledItem(new GUIContent("Bind To Owner")); //Save to asset if (owner != null && owner.graphIsLocal){ menu.AddItem(new GUIContent("Save To Asset"), false, ()=> { var newGraph = (Graph)EditorUtils.CreateAsset(this.GetType(), true); if (newGraph != null){ EditorUtility.CopySerialized(this, newGraph); newGraph.Validate(); AssetDatabase.SaveAssets(); } }); } else menu.AddDisabledItem(new GUIContent("Save To Asset")); //Create defined vars if (blackboard != null){ menu.AddItem(new GUIContent("Create Defined Blackboard Variables"), false, ()=> { if (EditorUtility.DisplayDialog("Create Defined Variables", "This will fill the current Blackboard for each defined variable parameter in the graph.\nContinue?", "YES", "NO")) CreateDefinedParameterVariables(blackboard); }); } else menu.AddDisabledItem(new GUIContent("Create Defined Blackboard Variables")); menu.ShowAsContext(); } ////// ///PREFS if (GUILayout.Button("Prefs", EditorStyles.toolbarDropDown, GUILayout.Width(50))){ var menu = new GenericMenu(); menu.AddItem (new GUIContent ("Icon Mode"), NCPrefs.iconMode, ()=> {NCPrefs.iconMode = !NCPrefs.iconMode;}); menu.AddItem (new GUIContent ("Show Node Help"), NCPrefs.showNodeInfo, ()=> {NCPrefs.showNodeInfo = !NCPrefs.showNodeInfo;}); menu.AddItem (new GUIContent ("Show Comments"), NCPrefs.showComments, ()=> {NCPrefs.showComments = !NCPrefs.showComments;}); menu.AddItem (new GUIContent ("Show Summary Info"), NCPrefs.showTaskSummary, ()=> {NCPrefs.showTaskSummary = !NCPrefs.showTaskSummary;}); menu.AddItem (new GUIContent ("Log Events"), NCPrefs.logEvents, ()=>{ NCPrefs.logEvents = !NCPrefs.logEvents; }); menu.AddItem (new GUIContent ("Grid Snap"), NCPrefs.doSnap, ()=> {NCPrefs.doSnap = !NCPrefs.doSnap;}); if (autoSort){ menu.AddItem (new GUIContent ("Automatic Hierarchical Move"), NCPrefs.hierarchicalMove, ()=> {NCPrefs.hierarchicalMove = !NCPrefs.hierarchicalMove;}); } menu.AddItem (new GUIContent ("Connection Mode/Curved"), NCPrefs.curveMode == 0, ()=> {NCPrefs.curveMode = 0;}); menu.AddItem (new GUIContent ("Connection Mode/Stepped"), NCPrefs.curveMode == 1, ()=> {NCPrefs.curveMode = 1;}); menu.AddItem (new GUIContent ("Connection Mode/Straight"), NCPrefs.curveMode == 2, ()=> {NCPrefs.curveMode = 2;}); //menu.AddItem (new GUIContent ("Use External Inspector"), NCPrefs.useExternalInspector, ()=> {NCPrefs.useExternalInspector = !NCPrefs.useExternalInspector;}); menu.AddItem( new GUIContent("Preferred Types Editor..."), false, ()=>{PreferedTypesEditorWindow.ShowWindow();} ); menu.ShowAsContext(); } ///////// GUILayout.Space(10); ////CLICK SELECT if (agent != null && GUILayout.Button("Select Owner", EditorStyles.toolbarButton, GUILayout.Width(80))){ Selection.activeObject = agent; EditorGUIUtility.PingObject(agent); } if (EditorUtility.IsPersistent(this) && GUILayout.Button("Select Graph", EditorStyles.toolbarButton, GUILayout.Width(80))){ Selection.activeObject = this; EditorGUIUtility.PingObject(this); } //////////////// GUILayout.Space(10); GUILayout.FlexibleSpace(); //DROPDOWN GRAPHOWNER JUMP SELECTION if (owner != null && !NCPrefs.isLocked){ if (GUILayout.Button(string.Format("[{0}]", owner.gameObject.name), EditorStyles.toolbarDropDown, GUILayout.Width(120))){ var menu = new GenericMenu(); foreach(var _o in FindObjectsOfType<GraphOwner>()){ var o = _o; menu.AddItem (new GUIContent(o.GetType().Name + "s/" + o.gameObject.name), false, ()=> { Selection.activeObject = o; Selection.selectionChanged(); }); } menu.ShowAsContext(); } } //////////////////////////////////// NCPrefs.isLocked = GUILayout.Toggle(NCPrefs.isLocked, "Lock", EditorStyles.toolbarButton); GUILayout.Space(2); GUI.backgroundColor = new Color(1, 0.8f, 0.8f, 1); if (GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(50))){ if (EditorUtility.DisplayDialog("Clear Canvas", "This will delete all nodes of the currently viewing graph!\nAre you sure?", "YES", "NO!")){ ClearGraph(); e.Use(); return; } } GUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; }
public void AddItemsToMenu(GenericMenu menu) { if (!string.IsNullOrEmpty(textEditor.targetPath)) { var fileName = System.IO.Path.GetFileName(textEditor.targetPath); #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 fileName = fileName.Replace('_', '\xFF3F'); #endif menu.AddItem(new GUIContent("Ping " + fileName), false, () => { EditorApplication.ExecuteMenuItem("Window/Project"); EditorGUIUtility.PingObject(targetAsset); }); #if UNITY_EDITOR_OSX menu.AddItem(new GUIContent("Reveal in Finder"), false, () => { Selection.activeObject = targetAsset; EditorApplication.ExecuteMenuItem("Assets/Reveal in Finder"); }); #else menu.AddItem(new GUIContent("Show in Explorer"), false, () => { Selection.activeObject = targetAsset; EditorApplication.ExecuteMenuItem("Assets/Show in Explorer"); }); #endif menu.AddSeparator(""); var isMaximized = IsMaximized(); menu.AddItem("Maximize", "&\n", "Maximize", "&enter", isMaximized, () => ToggleMaximized(this)); if (isMaximized) { menu.AddDisabledItem(new GUIContent("Close Tab")); menu.AddDisabledItem(new GUIContent("Close All SI Tabs")); menu.AddItem("Close Other SI Tabs", "#%w", "Close Other SI Tabs", "#%w", false, null); } else { menu.AddItem("Close Tab", "#%w", "Close Tab", "%w", false, () => { Close(); }); menu.AddItem(new GUIContent("Close All SI Tabs"), false, () => { var allWindows = new FGCodeWindow[codeWindows.Count]; codeWindows.CopyTo(allWindows); foreach (var window in allWindows) if (window) window.Close(); }); menu.AddItem("Close Other SI Tabs", "", "Close Other SI Tabs", "#%w", false, CloseOtherTabs); } menu.ShowAsContext(); GUIUtility.ExitGUI(); } }
/// <summary> /// Shows a context menu to add a new parent. /// </summary> void OnContextMenu () { var menu = new UnityEditor.GenericMenu(); // Get the active game object var gameObject = Selection.activeGameObject; // The selected game object is not null? if (gameObject != null) { // Gets all scripts that inherits from ParentBehaviour class MonoScript[] scripts = FileUtility.GetScripts<ParentBehaviour>(); for (int i = 0; i < scripts.Length; i++) { var type = scripts[i].GetClass(); // Get the component path string componentPath = "Add Parent/"; AddComponentMenu componentMenu = AttributeUtility.GetAttribute<AddComponentMenu>(type, false); if (componentMenu == null || componentMenu.componentMenu != string.Empty) { componentMenu = AttributeUtility.GetAttribute<AddComponentMenu>(type, true); if (componentMenu != null && componentMenu.componentMenu != string.Empty) componentPath += componentMenu.componentMenu; else componentPath += type.ToString().Replace('.','/'); // Add to menu menu.AddItem(new GUIContent(componentPath), false, delegate () {BehaviourWindow.activeParent = StateUtility.AddState(gameObject, type) as ParentBehaviour;}); } } } else { menu.AddDisabledItem(new GUIContent("Add Parent/")); ShowNotification(new GUIContent("Select a Game Object and right click in this window!")); } // Add option to paste states if (Selection.activeGameObject != null && StateUtility.statesToPaste != null && StateUtility.statesToPaste.Length > 0) menu.AddItem(new GUIContent("Paste State"), false, delegate () {StateUtility.CloneStates(Selection.activeGameObject, StateUtility.statesToPaste, null);}); else menu.AddDisabledItem(new GUIContent("Paste State")); // Refresh window? // menu.AddSeparator(""); // menu.AddItem(new GUIContent("Refresh"), false ,Refresh); // Shows the controller menu menu.ShowAsContext(); }
static void SetupMinMaxCurve(SerializedProperty property, GenericMenu menu, Event evt) { var canCopy = !property.hasMultipleDifferentValues; var canPasteWhole = GUI.enabled && Clipboard.HasSerializedProperty(); if (menu != null) { AddSeparator(menu); var copyContent = overrideCopyContent ?? kCopyContent; if (canCopy) { menu.AddItem(copyContent, false, o => Clipboard.SetSerializedProperty((SerializedProperty)o), property); } else { menu.AddDisabledItem(copyContent); } var pasteContent = overridePasteContent ?? kPasteContent; if (canPasteWhole) { menu.AddItem(pasteContent, false, delegate(object o) { var prop = (SerializedProperty)o; Clipboard.GetSerializedProperty(prop); prop.serializedObject.ApplyModifiedProperties(); }, property); } else if (GUI.enabled && Clipboard.hasFloat) { MinMaxCurveState state = (MinMaxCurveState)property.FindPropertyRelative("minMaxState").intValue; if (state == MinMaxCurveState.k_Scalar) { AddPasteFloatItem(property.FindPropertyRelative("scalar"), menu, pasteContent); } else if (state == MinMaxCurveState.k_TwoScalars) { // Allow the user to choose whether to paste the float on their clipboard to either the min or max AddPasteFloatItem(property.FindPropertyRelative("minScalar"), menu, kPasteMinScalarContent); AddPasteFloatItem(property.FindPropertyRelative("scalar"), menu, kPasteMaxScalarContent); } else { menu.AddDisabledItem(pasteContent); } } else if (GUI.enabled && Clipboard.hasAnimationCurve) { MinMaxCurveState state = (MinMaxCurveState)property.FindPropertyRelative("minMaxState").intValue; if (state == MinMaxCurveState.k_Curve) { AddPasteCurveItem(property.FindPropertyRelative("maxCurve"), menu, pasteContent); } else if (state == MinMaxCurveState.k_TwoCurves) { // Allow the user to choose whether to paste the color on their clipboard to either the max or min AddPasteCurveItem(property.FindPropertyRelative("maxCurve"), menu, kPasteMaxCurveContent); AddPasteCurveItem(property.FindPropertyRelative("minCurve"), menu, kPasteMinCurveContent); } else { menu.AddDisabledItem(pasteContent); } } else { menu.AddDisabledItem(pasteContent); } } if (evt != null) { if (canCopy && evt.commandName == EventCommandNames.Copy) { if (evt.type == EventType.ValidateCommand) { evt.Use(); } if (evt.type == EventType.ExecuteCommand) { Clipboard.SetSerializedProperty(property); evt.Use(); } } if (canPasteWhole && evt.commandName == EventCommandNames.Paste) { if (evt.type == EventType.ValidateCommand) { evt.Use(); } if (evt.type == EventType.ExecuteCommand) { Clipboard.GetSerializedProperty(property); property.serializedObject.ApplyModifiedProperties(); evt.Use(); } } } }
protected override GenericMenu OnContextMenu(GenericMenu menu) { if (allowAsPrime){ if (Application.isPlaying){ menu.AddItem (new GUIContent ("Enter State"), false, delegate{FSM.EnterState(this);}); } else { menu.AddDisabledItem(new GUIContent ("Enter State")); } } return menu; }
private void CreateFileMenu(Rect position) { GenericMenu fileMenu = new GenericMenu(); fileMenu.AddItem(new GUIContent("Overwrite Input Settings"), false, HandleFileMenuOption, FileMenuOptions.OverriteInputSettings); if(EditorToolbox.HasInputAdapterAddon()) fileMenu.AddItem(new GUIContent("Configure For Input Adapter"), false, HandleFileMenuOption, FileMenuOptions.ConfigureForInputAdapter); fileMenu.AddSeparator(""); if(_inputManager.inputConfigurations.Count > 0) fileMenu.AddItem(new GUIContent("Create Snapshot"), false, HandleFileMenuOption, FileMenuOptions.CreateSnapshot); else fileMenu.AddDisabledItem(new GUIContent("Create Snapshot")); if(EditorToolbox.CanLoadSnapshot()) fileMenu.AddItem(new GUIContent("Load Snapshot"), false, HandleFileMenuOption, FileMenuOptions.LoadSnapshot); else fileMenu.AddDisabledItem(new GUIContent("Load Snapshot")); fileMenu.AddSeparator(""); if(_inputManager.inputConfigurations.Count > 0) fileMenu.AddItem(new GUIContent("Export"), false, HandleFileMenuOption, FileMenuOptions.Export); else fileMenu.AddDisabledItem(new GUIContent("Export")); fileMenu.AddItem(new GUIContent("Import"), false, HandleFileMenuOption, FileMenuOptions.Import); if(EditorToolbox.HasJoystickMappingAddon()) fileMenu.AddItem(new GUIContent("Import Joystick Mapping"), false, HandleFileMenuOption, FileMenuOptions.ImportJoystickMapping); fileMenu.DropDown(position); }
void MixedLightingGUI() { if (!SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Baked)) { return; } m_ShowMixedLightsSettings = EditorGUILayout.FoldoutTitlebar(m_ShowMixedLightsSettings, Styles.MixedLightsLabel, true); if (m_ShowMixedLightsSettings) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_EnabledBakedGI, Styles.EnableBaked); if (!m_EnabledBakedGI.boolValue) { EditorGUILayout.HelpBox(Styles.BakedGIDisabledInfo.text, MessageType.Info); } using (new EditorGUI.DisabledScope(!m_EnabledBakedGI.boolValue)) { bool mixedGISupported = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Mixed); using (new EditorGUI.DisabledScope(!mixedGISupported)) { var rect = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(rect, Styles.MixedLightMode, m_MixedBakeMode); rect = EditorGUI.PrefixLabel(rect, Styles.MixedLightMode); int index = Math.Max(0, Array.IndexOf(Styles.MixedModeValues, m_MixedBakeMode.intValue)); if (EditorGUI.DropdownButton(rect, Styles.MixedModeStrings[index], FocusType.Passive)) { var menu = new GenericMenu(); for (int i = 0; i < Styles.MixedModeValues.Length; i++) { int value = Styles.MixedModeValues[i]; bool selected = (value == m_MixedBakeMode.intValue); if (!SupportedRenderingFeatures.IsMixedLightingModeSupported((MixedLightingMode)value)) { menu.AddDisabledItem(Styles.MixedModeStrings[i], selected); } else { menu.AddItem(Styles.MixedModeStrings[i], selected, OnMixedModeSelected, value); } } menu.DropDown(rect); } EditorGUI.EndProperty(); if (mixedGISupported) { if (!SupportedRenderingFeatures.IsMixedLightingModeSupported((MixedLightingMode)m_MixedBakeMode.intValue)) { string fallbackMode = Styles.MixedModeStrings[(int)SupportedRenderingFeatures.FallbackMixedLightingMode()].text; EditorGUILayout.HelpBox(Styles.MixedModeNotSupportedWarning.text + fallbackMode, MessageType.Warning); } else if (m_EnabledBakedGI.boolValue) { EditorGUILayout.HelpBox(Styles.HelpStringsMixed[m_MixedBakeMode.intValue].text, MessageType.Info); } } if (m_MixedBakeMode.intValue == (int)MixedLightingMode.Subtractive) { EditorGUILayout.PropertyField(m_SubtractiveShadowColor, Styles.SubtractiveShadowColor); m_RenderSettingsSO.ApplyModifiedProperties(); EditorGUILayout.Space(); } } } EditorGUI.indentLevel--; EditorGUILayout.Space(); } }
/// <summary> /// Invoked to generate context menu for list item. /// </summary> /// <param name="menu">Menu which can be populated.</param> /// <param name="itemIndex">Zero-based index of item which was right-clicked.</param> /// <param name="adaptor">Reorderable list adaptor.</param> protected virtual void AddItemsToMenu(GenericMenu menu, int itemIndex, IReorderableListAdaptor adaptor) { if ((Flags & ReorderableListFlags.DisableReordering) == 0) { if (itemIndex > 0) menu.AddItem(CommandMoveToTop, false, DefaultContextHandler, CommandMoveToTop); else menu.AddDisabledItem(CommandMoveToTop); if (itemIndex + 1 < adaptor.Count) menu.AddItem(CommandMoveToBottom, false, DefaultContextHandler, CommandMoveToBottom); else menu.AddDisabledItem(CommandMoveToBottom); if (HasAddButton) { menu.AddSeparator(""); menu.AddItem(CommandInsertAbove, false, DefaultContextHandler, CommandInsertAbove); menu.AddItem(CommandInsertBelow, false, DefaultContextHandler, CommandInsertBelow); if ((Flags & ReorderableListFlags.DisableDuplicateCommand) == 0) menu.AddItem(CommandDuplicate, false, DefaultContextHandler, CommandDuplicate); } } if (HasRemoveButtons) { if (menu.GetItemCount() > 0) menu.AddSeparator(""); menu.AddItem(CommandRemove, false, DefaultContextHandler, CommandRemove); menu.AddSeparator(""); menu.AddItem(CommandClearAll, false, DefaultContextHandler, CommandClearAll); } }
public void AddTangentMenuItems(GenericMenu menu, List <KeyIdentifier> keyList) { bool anyKeys = (keyList.Count > 0); // Find out which qualities apply to all the keys bool allClampedAuto = anyKeys; bool allAuto = anyKeys; bool allFreeSmooth = anyKeys; bool allFlat = anyKeys; bool allBroken = anyKeys; bool allLeftWeighted = anyKeys; bool allLeftFree = anyKeys; bool allLeftLinear = anyKeys; bool allLeftConstant = anyKeys; bool allRightWeighted = anyKeys; bool allRightFree = anyKeys; bool allRightLinear = anyKeys; bool allRightConstant = anyKeys; foreach (KeyIdentifier sel in keyList) { Keyframe key = sel.keyframe; TangentMode leftMode = AnimationUtility.GetKeyLeftTangentMode(key); TangentMode rightMode = AnimationUtility.GetKeyRightTangentMode(key); bool broken = AnimationUtility.GetKeyBroken(key); if (leftMode != TangentMode.ClampedAuto || rightMode != TangentMode.ClampedAuto) { allClampedAuto = false; } if (leftMode != TangentMode.Auto || rightMode != TangentMode.Auto) { allAuto = false; } if (broken || leftMode != TangentMode.Free || rightMode != TangentMode.Free) { allFreeSmooth = false; } if (broken || leftMode != TangentMode.Free || key.inTangent != 0 || rightMode != TangentMode.Free || key.outTangent != 0) { allFlat = false; } if (!broken) { allBroken = false; } if (!broken || leftMode != TangentMode.Free) { allLeftFree = false; } if (!broken || leftMode != TangentMode.Linear) { allLeftLinear = false; } if (!broken || leftMode != TangentMode.Constant) { allLeftConstant = false; } if (!broken || rightMode != TangentMode.Free) { allRightFree = false; } if (!broken || rightMode != TangentMode.Linear) { allRightLinear = false; } if (!broken || rightMode != TangentMode.Constant) { allRightConstant = false; } if ((key.weightedMode & WeightedMode.In) == WeightedMode.None) { allLeftWeighted = false; } if ((key.weightedMode & WeightedMode.Out) == WeightedMode.None) { allRightWeighted = false; } } if (anyKeys) { menu.AddItem(EditorGUIUtility.TrTextContent("Clamped Auto"), allClampedAuto, SetClampedAuto, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Auto"), allAuto, SetAuto, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Free Smooth"), allFreeSmooth, SetEditable, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Flat"), allFlat, SetFlat, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Broken"), allBroken, SetBroken, keyList); menu.AddSeparator(""); menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Free"), allLeftFree, SetLeftEditable, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Linear"), allLeftLinear, SetLeftLinear, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Constant"), allLeftConstant, SetLeftConstant, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Left Tangent/Weighted"), allLeftWeighted, ToggleLeftWeighted, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Free"), allRightFree, SetRightEditable, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Linear"), allRightLinear, SetRightLinear, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Constant"), allRightConstant, SetRightConstant, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Right Tangent/Weighted"), allRightWeighted, ToggleRightWeighted, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Free"), allRightFree && allLeftFree, SetBothEditable, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Linear"), allRightLinear && allLeftLinear, SetBothLinear, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Constant"), allRightConstant && allLeftConstant, SetBothConstant, keyList); menu.AddItem(EditorGUIUtility.TrTextContent("Both Tangents/Weighted"), allRightWeighted && allLeftWeighted, ToggleBothWeighted, keyList); } else { menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Weighted")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Auto")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Free Smooth")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Flat")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Broken")); menu.AddSeparator(""); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Free")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Linear")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Constant")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Left Tangent/Weighted")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Free")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Linear")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Constant")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Right Tangent/Weighted")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Free")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Linear")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Constant")); menu.AddDisabledItem(EditorGUIUtility.TrTextContent("Both Tangents/Weighted")); } }
protected override void ContextClickedItem(int id) { UnityEditor.GenericMenu menu = new UnityEditor.GenericMenu(); var item = Find(id); if (CheckWaapi()) { if (CanPlay(item)) { menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Play \u2215 Stop _SPACE"), false, () => AkWaapiUtilities.TogglePlayEvent(item.objectType, item.objectGuid)); } else { menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Play \u2215 Stop _Space")); } menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Stop All"), false, () => AkWaapiUtilities.StopAllTransports()); menu.AddSeparator(""); if (CanRenameWithLog(item, false)) { menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Rename _F2"), false, () => BeginRename(item)); } else { menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Rename")); } if (CanDelete(item, false)) { menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Delete _Delete"), false, () => AkWaapiUtilities.Delete(item.objectGuid)); } else { menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Delete")); } menu.AddSeparator(""); if (item.objectType == WwiseObjectType.Soundbank) { menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Open Folder/WorkUnit #O"), false, () => AkWaapiUtilities.OpenWorkUnitInExplorer(item.objectGuid)); menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Open Folder/SoundBank "), false, () => AkWaapiUtilities.OpenSoundBankInExplorer(item.objectGuid)); } else { menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Open Containing Folder #O"), false, () => AkWaapiUtilities.OpenWorkUnitInExplorer(item.objectGuid)); } menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Find in Project Explorer #F"), false, () => m_dataSource.SelectObjectInAuthoring(item.objectGuid)); } else { if (AkWwiseProjectInfo.GetData().currentDataSource == AkWwiseProjectInfo.DataSourceType.WwiseAuthoring) { menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Wwise Connection Settings"), false, OpenSettings); menu.AddSeparator(""); } menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Play \u2215 Stop")); menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Stop all")); menu.AddSeparator(""); menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Rename")); menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Delete")); menu.AddSeparator(""); menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Open Containing Folder")); menu.AddDisabledItem(UnityEditor.EditorGUIUtility.TrTextContent("Find in Project Explorer")); } menu.AddItem(UnityEditor.EditorGUIUtility.TrTextContent("Find References in Scene #R"), false, () => FindReferencesInScene(item)); menu.ShowAsContext(); }
/// <summary> /// Shows the context menu. /// </summary> protected virtual void OnContextMenu() { // Create the menu var menu = new UnityEditor.GenericMenu(); if (m_State != null) { // Set as start state if (m_State.fsm != null && !(m_State is InternalAnyState)) { menu.AddItem(new GUIContent("Set as Start"), false, delegate() { StateUtility.SetAsStart(m_State); this.Refresh(); }); } else { menu.AddDisabledItem(new GUIContent("Set as Start")); } // Set as concurrent state if (m_State.fsm != null && !(m_State is InternalAnyState)) { if (m_IsConcurrent) { menu.AddItem(new GUIContent("Set as Not Concurrent"), false, delegate() { StateUtility.RemoveConcurrentState(m_State.fsm); this.Refresh(); }); } else { menu.AddItem(new GUIContent("Set as Concurrent"), false, delegate() { StateUtility.SetAsConcurrent(m_State); this.Refresh(); }); } } else { menu.AddDisabledItem(new GUIContent("Set as Concurrent")); } // Set as enabled if (m_State.fsm != null /*&& m_State.fsm.enabled*/ && Application.isPlaying && !(m_State is InternalAnyState)) { menu.AddItem(new GUIContent("Set as Enabled"), false, delegate() { m_State.enabled = true; }); } else { menu.AddDisabledItem(new GUIContent("Set as Enabled")); } // Add Transitions // Add none menu.AddItem(new GUIContent("Add Transition/None"), false, delegate() { StateUtility.AddTransition(m_State, 0); CreateTransitionGUIs(); }); // Add blackboard events var blackboard = m_State.blackboard; if (blackboard != null) { foreach (var fsmEvent in blackboard.fsmEvents) { int eventId = fsmEvent.id; menu.AddItem(new GUIContent("Add Transition/" + fsmEvent.name), false, delegate() { StateUtility.AddTransition(m_State, eventId); CreateTransitionGUIs(); }); } } // Add GlobalBlackboard events // This is not The GlobalBlackboard? if (InternalGlobalBlackboard.Instance != null && blackboard != InternalGlobalBlackboard.Instance) { foreach (var globalEvent in InternalGlobalBlackboard.Instance.fsmEvents) { int eventId = globalEvent.id; var eventName = globalEvent.isSystem ? "Add Transition/System/" + globalEvent.name : "Add Transition/Global/" + globalEvent.name; menu.AddItem(new GUIContent(eventName), false, delegate() { StateUtility.AddTransition(m_State, eventId); CreateTransitionGUIs(); }); } } // Separator menu.AddSeparator(""); // Copy menu.AddItem(new GUIContent("Copy State"), false, delegate() { StateUtility.CopySelectedStates(); }); // Paste if (StateUtility.statesToPaste != null && StateUtility.statesToPaste.Length > 0 && m_State.fsm != null) { menu.AddItem(new GUIContent("Paste State"), false, delegate() { StateUtility.PasteStates(m_State.fsm); }); } else { menu.AddDisabledItem(new GUIContent("Paste State")); } // Duplicate if (m_State.fsm != null) { menu.AddItem(new GUIContent("Duplicate State"), false, delegate() { var statesToPaste = new List <InternalStateBehaviour>(BehaviourWindow.activeStates); if (!statesToPaste.Contains(m_State)) { statesToPaste.Add(m_State); } StateUtility.CloneStates(m_State.gameObject, statesToPaste.ToArray(), m_State.fsm); } ); } else { menu.AddDisabledItem(new GUIContent("Duplicate State")); } // Separator menu.AddSeparator(""); // Delete menu.AddItem(new GUIContent("Delete"), false, delegate() { StateUtility.Destroy(m_State); this.Refresh(); }); } else { menu.AddDisabledItem(new GUIContent("Set as Start")); menu.AddDisabledItem(new GUIContent("Set as Enabled")); menu.AddDisabledItem(new GUIContent("Add Transition")); menu.AddSeparator(""); menu.AddDisabledItem(new GUIContent("Copy State")); menu.AddDisabledItem(new GUIContent("Paste State")); menu.AddSeparator(""); menu.AddDisabledItem(new GUIContent("Delete")); } // Show the context menu menu.ShowAsContext(); }
static void SetupObjectReference(SerializedProperty property, GenericMenu menu, Event evt) { var hasPasteObject = Clipboard.hasObject; var hasPasteGuid = Clipboard.hasGuid; var hasPastePath = !new GUID(AssetDatabase.AssetPathToGUID(Clipboard.stringValue)).Empty(); var obj = property.objectReferenceValue; var canCopy = !property.hasMultipleDifferentValues && obj != null; var canPaste = GUI.enabled && (hasPasteGuid || hasPastePath || hasPasteObject); if (menu != null) { AddSeparator(menu); var hasAsset = canCopy && AssetDatabase.Contains(obj); if (canCopy) { menu.AddItem(kCopyContent, false, o => Clipboard.objectValue = (UnityEngine.Object)o, obj); } else { menu.AddDisabledItem(kCopyContent); } if (hasAsset) { menu.AddItem(kCopyPathContent, false, o => Clipboard.stringValue = AssetDatabase.GetAssetPath((UnityEngine.Object)o).ToString(), obj); menu.AddItem(kCopyGuidContent, false, o => Clipboard.guidValue = new GUID(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath((UnityEngine.Object)o))), obj); } else { menu.AddDisabledItem(kCopyPathContent); menu.AddDisabledItem(kCopyGuidContent); } if (canPaste) { menu.AddItem(kPasteContent, false, o => PasteObjectReference((SerializedProperty)o), property); } else { menu.AddDisabledItem(kPasteContent); } } if (evt != null) { if (canCopy && evt.commandName == EventCommandNames.Copy) { if (evt.type == EventType.ValidateCommand) { evt.Use(); } if (evt.type == EventType.ExecuteCommand) { Clipboard.objectValue = obj; evt.Use(); } } if (canPaste && evt.commandName == EventCommandNames.Paste) { if (evt.type == EventType.ValidateCommand) { evt.Use(); } if (evt.type == EventType.ExecuteCommand) { PasteObjectReference(property); evt.Use(); } } } }
public void AddTangentMenuItems(GenericMenu menu, List <KeyIdentifier> keyList) { bool flag = keyList.Count > 0; bool on = flag; bool flag3 = flag; bool flag4 = flag; bool flag5 = flag; bool flag6 = flag; bool flag7 = flag; bool flag8 = flag; bool flag9 = flag; bool flag10 = flag; bool flag11 = flag; bool flag12 = flag; foreach (KeyIdentifier identifier in keyList) { Keyframe key = identifier.keyframe; AnimationUtility.TangentMode keyLeftTangentMode = AnimationUtility.GetKeyLeftTangentMode(key); AnimationUtility.TangentMode keyRightTangentMode = AnimationUtility.GetKeyRightTangentMode(key); bool keyBroken = AnimationUtility.GetKeyBroken(key); if ((keyLeftTangentMode != AnimationUtility.TangentMode.ClampedAuto) || (keyRightTangentMode != AnimationUtility.TangentMode.ClampedAuto)) { on = false; } if ((keyLeftTangentMode != AnimationUtility.TangentMode.Auto) || (keyRightTangentMode != AnimationUtility.TangentMode.Auto)) { flag3 = false; } if ((keyBroken || (keyLeftTangentMode != AnimationUtility.TangentMode.Free)) || (keyRightTangentMode != AnimationUtility.TangentMode.Free)) { flag4 = false; } if ((keyBroken || (keyLeftTangentMode != AnimationUtility.TangentMode.Free)) || (((key.inTangent != 0f) || (keyRightTangentMode != AnimationUtility.TangentMode.Free)) || (key.outTangent != 0f))) { flag5 = false; } if (!keyBroken) { flag6 = false; } if (!keyBroken || (keyLeftTangentMode != AnimationUtility.TangentMode.Free)) { flag7 = false; } if (!keyBroken || (keyLeftTangentMode != AnimationUtility.TangentMode.Linear)) { flag8 = false; } if (!keyBroken || (keyLeftTangentMode != AnimationUtility.TangentMode.Constant)) { flag9 = false; } if (!keyBroken || (keyRightTangentMode != AnimationUtility.TangentMode.Free)) { flag10 = false; } if (!keyBroken || (keyRightTangentMode != AnimationUtility.TangentMode.Linear)) { flag11 = false; } if (!keyBroken || (keyRightTangentMode != AnimationUtility.TangentMode.Constant)) { flag12 = false; } } if (flag) { menu.AddItem(EditorGUIUtility.TextContent("Clamped Auto"), on, new GenericMenu.MenuFunction2(this.SetClampedAuto), keyList); menu.AddItem(EditorGUIUtility.TextContent("Auto"), flag3, new GenericMenu.MenuFunction2(this.SetAuto), keyList); menu.AddItem(EditorGUIUtility.TextContent("Free Smooth"), flag4, new GenericMenu.MenuFunction2(this.SetEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Flat"), flag5, new GenericMenu.MenuFunction2(this.SetFlat), keyList); menu.AddItem(EditorGUIUtility.TextContent("Broken"), flag6, new GenericMenu.MenuFunction2(this.SetBroken), keyList); menu.AddSeparator(""); menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Free"), flag7, new GenericMenu.MenuFunction2(this.SetLeftEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Linear"), flag8, new GenericMenu.MenuFunction2(this.SetLeftLinear), keyList); menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Constant"), flag9, new GenericMenu.MenuFunction2(this.SetLeftConstant), keyList); menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Free"), flag10, new GenericMenu.MenuFunction2(this.SetRightEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Linear"), flag11, new GenericMenu.MenuFunction2(this.SetRightLinear), keyList); menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Constant"), flag12, new GenericMenu.MenuFunction2(this.SetRightConstant), keyList); menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Free"), flag10 && flag7, new GenericMenu.MenuFunction2(this.SetBothEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Linear"), flag11 && flag8, new GenericMenu.MenuFunction2(this.SetBothLinear), keyList); menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Constant"), flag12 && flag9, new GenericMenu.MenuFunction2(this.SetBothConstant), keyList); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Clamped Auto")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Auto")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Free Smooth")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Flat")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Broken")); menu.AddSeparator(""); menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Free")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Linear")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Constant")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Free")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Linear")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Constant")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Free")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Linear")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Constant")); } }
public static void ShowFilterKeyTypeMenu(string current, Action<string> Selected) { var menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent(current)); menu.AddSeparator(string.Empty); for (var i = 0; i < TypeUtility.KeyTypes.Count; i++) { var type = TypeUtility.KeyTypes[i]; if (type == current) continue; menu.AddItem( new GUIContent(type), false, () => { Selected(type); } ); } menu.ShowAsContext(); }
public void ObjectPreview(Rect r) { if (r.height <= 0) { return; } if (m_ZoomablePreview == null) { m_ZoomablePreview = new ZoomableArea(true); m_ZoomablePreview.hRangeMin = 0.0f; m_ZoomablePreview.vRangeMin = 0.0f; m_ZoomablePreview.hRangeMax = 1.0f; m_ZoomablePreview.vRangeMax = 1.0f; m_ZoomablePreview.SetShownHRange(0, 1); m_ZoomablePreview.SetShownVRange(0, 1); m_ZoomablePreview.uniformScale = true; m_ZoomablePreview.scaleWithWindow = true; } // Draw background GUI.Box(r, "", "PreBackground"); // Top menu rect Rect menuRect = new Rect(r); menuRect.y += 1; menuRect.height = 18; GUI.Box(menuRect, "", EditorStyles.toolbar); // Top menu dropdown Rect dropRect = new Rect(r); dropRect.y += 1; dropRect.height = 18; dropRect.width = 120; // Drawable area Rect drawableArea = new Rect(r); drawableArea.yMin += dropRect.height; drawableArea.yMax -= 14; drawableArea.width -= 11; int index = Array.IndexOf(Styles.ObjectPreviewTextureOptions, m_SelectedObjectPreviewTexture); if (index < 0 || !LightmapVisualizationUtility.IsTextureTypeEnabled(kObjectPreviewTextureTypes[index])) { index = 0; m_SelectedObjectPreviewTexture = Styles.ObjectPreviewTextureOptions[index]; } if (EditorGUI.DropdownButton(dropRect, m_SelectedObjectPreviewTexture, FocusType.Passive, EditorStyles.toolbarPopup)) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < Styles.ObjectPreviewTextureOptions.Length; i++) { if (LightmapVisualizationUtility.IsTextureTypeEnabled(kObjectPreviewTextureTypes[i])) { menu.AddItem(Styles.ObjectPreviewTextureOptions[i], index == i, SelectPreviewTextureOption, Styles.ObjectPreviewTextureOptions.ElementAt(i)); } else { menu.AddDisabledItem(Styles.ObjectPreviewTextureOptions.ElementAt(i)); } } menu.DropDown(dropRect); } GITextureType textureType = kObjectPreviewTextureTypes[Array.IndexOf(Styles.ObjectPreviewTextureOptions, m_SelectedObjectPreviewTexture)]; if (m_CachedTexture.type != textureType || m_CachedTexture.contentHash != LightmapVisualizationUtility.GetSelectedObjectGITextureHash(textureType) || m_CachedTexture.contentHash == new Hash128()) { m_CachedTexture = LightmapVisualizationUtility.GetSelectedObjectGITexture(textureType); } if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureNotAvailable || m_CachedTexture.textureAvailability == GITextureAvailability.GITextureUnknown) { if (LightmapVisualizationUtility.IsBakedTextureType(textureType)) { if (textureType == GITextureType.BakedShadowMask) { GUI.Label(drawableArea, Styles.TextureNotAvailableBakedShadowmask); } else { GUI.Label(drawableArea, Styles.TextureNotAvailableBaked); } } else { GUI.Label(drawableArea, Styles.TextureNotAvailableRealtime); } return; } if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureLoading && m_CachedTexture.texture == null) { GUI.Label(drawableArea, Styles.TextureLoading); return; } LightmapType lightmapType = LightmapVisualizationUtility.GetLightmapType(textureType); // Framing and drawing var evt = Event.current; switch (evt.type) { // 'F' will zoom to uv bounds case EventType.ValidateCommand: case EventType.ExecuteCommand: if (Event.current.commandName == EventCommandNames.FrameSelected) { Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType); if ((textureType == GITextureType.BakedAlbedo || textureType == GITextureType.BakedEmissive) && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.ProgressiveCPU) { lightmapTilingOffset = new Vector4(1f, 1f, 0f, 0f); } Vector2 min = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w); Vector2 max = min + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y); min = Vector2.Max(min, Vector2.zero); max = Vector2.Min(max, Vector2.one); float swap = 1f - min.y; min.y = 1f - max.y; max.y = swap; // Make sure that the focus rectangle is a even square Rect rect = new Rect(min.x, min.y, max.x - min.x, max.y - min.y); rect.x -= Mathf.Clamp(rect.height - rect.width, 0, float.MaxValue) / 2; rect.y -= Mathf.Clamp(rect.width - rect.height, 0, float.MaxValue) / 2; rect.width = rect.height = Mathf.Max(rect.width, rect.height); m_ZoomablePreview.shownArea = rect; Event.current.Use(); } break; // Scale and draw texture and uv's case EventType.Repaint: Texture2D texture = m_CachedTexture.texture; if (texture && Event.current.type == EventType.Repaint) { Rect textureRect = new Rect(0, 0, texture.width, texture.height); textureRect = ResizeRectToFit(textureRect, drawableArea); //textureRect.x = -textureRect.width / 2; //textureRect.y = -textureRect.height / 2; textureRect = CenterToRect(textureRect, drawableArea); textureRect = ScaleRectByZoomableArea(textureRect, m_ZoomablePreview); // Draw texture and UV Rect uvRect = new Rect(textureRect); uvRect.x += 3; uvRect.y += drawableArea.y + 20; Rect clipRect = new Rect(drawableArea); clipRect.y += dropRect.height + 3; // fix 635838 - We need to offset the rects for rendering. { float offset = clipRect.y - 14; uvRect.y -= offset; clipRect.y -= offset; } // Texture shouldn't be filtered since it will make previewing really blurry FilterMode prevMode = texture.filterMode; texture.filterMode = FilterMode.Point; LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, clipRect, uvRect, textureType); texture.filterMode = prevMode; } break; } // Reset zoom if selection is changed if (m_PreviousSelection != Selection.activeInstanceID) { m_PreviousSelection = Selection.activeInstanceID; m_ZoomablePreview.SetShownHRange(0, 1); m_ZoomablePreview.SetShownVRange(0, 1); } // Handle zoomable area Rect zoomRect = new Rect(r); zoomRect.yMin += dropRect.height; m_ZoomablePreview.rect = zoomRect; m_ZoomablePreview.BeginViewGUI(); m_ZoomablePreview.EndViewGUI(); GUILayoutUtility.GetRect(r.width, r.height); }
void OnGUI() { Event e = Event.current; //判断是否在某个节点内部 int in_node_region_index = GetMousePositionInRegion (e.mousePosition); if (e.button == 1&&e.type==EventType.mouseUp) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("新加一个节点"),false,ContextCallback,e.mousePosition); menu.AddItem(new GUIContent("a/b/c"),false,null,null); if(in_node_region_index>=0) { this.transition_from_node = nodes[in_node_region_index]; menu.AddItem(new GUIContent("新加一条边"),false,AddTransitionCallback,this.transition_from_node); } else { menu.AddDisabledItem(new GUIContent("新加一条边")); } menu.AddItem(new GUIContent("保存所选节点"),false,SaveNodeCallback,null); menu.AddItem(new GUIContent("加载文件"),false,LoadNodeCallback,null); menu.ShowAsContext(); } if (e.button == 0 &&( e.type == EventType.mouseDown ||e.type == EventType.mouseUp)) { if(this.is_draw_curve) LinkTarget(e.mousePosition); this.is_draw_curve = false; if (in_node_region_index < 0 && e.button == 0 && e.type == EventType.mouseDown) { this.is_selected_state = true; this.pre_button_position = new Vector3 (e.mousePosition.x, e.mousePosition.y, 0); } else if (in_node_region_index < 0 && e.button == 0 && e.type == EventType.mouseUp) { this.is_selected_state = false; this.pre_button_position = Vector3.zero; } } Handles.BeginGUI(); if (this.is_selected_state) { verts[0] = this.pre_button_position; verts[1] = new Vector3(this.pre_button_position.x,e.mousePosition.y,0); verts[2] = new Vector3(e.mousePosition.x,e.mousePosition.y,0); verts[3] = new Vector3(e.mousePosition.x,this.pre_button_position.y,0); Handles.DrawSolidRectangleWithOutline(verts, new Color(1,1,1,0.2f),new Color(0,0,0,1)); CheckNodeIsSelected(verts[0],verts[2]); Repaint(); } for (int i=0; i<nodes.Count; i++) { nodes[i].DrawCurve(); } if (this.transition_from_node != null&&this.is_draw_curve) { Vector3 s = this.transition_from_node.GetCenterPosition(); Vector3 end = new Vector3(e.mousePosition.x,e.mousePosition.y,0); DrawBezierCurve(s,end); if(e.button==0&&e.type==EventType.mouseUp){ LinkTarget(e.mousePosition); } Repaint (); } Handles.EndGUI(); BeginWindows(); for (int i=0; i<nodes.Count; i++) { nodes[i].DrawNode(i,DoWindow); } EndWindows(); }
public void AddTangentMenuItems(GenericMenu menu, List <KeyIdentifier> keyList) { bool flag = keyList.Count > 0; bool on = flag; bool on2 = flag; bool on3 = flag; bool on4 = flag; bool flag2 = flag; bool flag3 = flag; bool flag4 = flag; bool flag5 = flag; bool flag6 = flag; bool flag7 = flag; foreach (KeyIdentifier current in keyList) { Keyframe keyframe = current.keyframe; TangentMode keyTangentMode = CurveUtility.GetKeyTangentMode(keyframe, 0); TangentMode keyTangentMode2 = CurveUtility.GetKeyTangentMode(keyframe, 1); bool keyBroken = CurveUtility.GetKeyBroken(keyframe); if (keyTangentMode != TangentMode.Smooth || keyTangentMode2 != TangentMode.Smooth) { on = false; } if (keyBroken || keyTangentMode != TangentMode.Editable || keyTangentMode2 != TangentMode.Editable) { on2 = false; } if (keyBroken || keyTangentMode != TangentMode.Editable || keyframe.inTangent != 0f || keyTangentMode2 != TangentMode.Editable || keyframe.outTangent != 0f) { on3 = false; } if (!keyBroken) { on4 = false; } if (!keyBroken || keyTangentMode != TangentMode.Editable) { flag2 = false; } if (!keyBroken || keyTangentMode != TangentMode.Linear) { flag3 = false; } if (!keyBroken || keyTangentMode != TangentMode.Stepped) { flag4 = false; } if (!keyBroken || keyTangentMode2 != TangentMode.Editable) { flag5 = false; } if (!keyBroken || keyTangentMode2 != TangentMode.Linear) { flag6 = false; } if (!keyBroken || keyTangentMode2 != TangentMode.Stepped) { flag7 = false; } } if (flag) { menu.AddItem(EditorGUIUtility.TextContent("Auto"), on, new GenericMenu.MenuFunction2(this.SetSmooth), keyList); menu.AddItem(EditorGUIUtility.TextContent("Free Smooth"), on2, new GenericMenu.MenuFunction2(this.SetEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Flat"), on3, new GenericMenu.MenuFunction2(this.SetFlat), keyList); menu.AddItem(EditorGUIUtility.TextContent("Broken"), on4, new GenericMenu.MenuFunction2(this.SetBroken), keyList); menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Free"), flag2, new GenericMenu.MenuFunction2(this.SetLeftEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Linear"), flag3, new GenericMenu.MenuFunction2(this.SetLeftLinear), keyList); menu.AddItem(EditorGUIUtility.TextContent("Left Tangent/Constant"), flag4, new GenericMenu.MenuFunction2(this.SetLeftConstant), keyList); menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Free"), flag5, new GenericMenu.MenuFunction2(this.SetRightEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Linear"), flag6, new GenericMenu.MenuFunction2(this.SetRightLinear), keyList); menu.AddItem(EditorGUIUtility.TextContent("Right Tangent/Constant"), flag7, new GenericMenu.MenuFunction2(this.SetRightConstant), keyList); menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Free"), flag5 && flag2, new GenericMenu.MenuFunction2(this.SetBothEditable), keyList); menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Linear"), flag6 && flag3, new GenericMenu.MenuFunction2(this.SetBothLinear), keyList); menu.AddItem(EditorGUIUtility.TextContent("Both Tangents/Constant"), flag7 && flag4, new GenericMenu.MenuFunction2(this.SetBothConstant), keyList); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Auto")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Free Smooth")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Flat")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Broken")); menu.AddSeparator(string.Empty); menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Free")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Linear")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Left Tangent/Constant")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Free")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Linear")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Right Tangent/Constant")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Free")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Linear")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Both Tangents/Constant")); } }
public void OnTreeViewContextClick(int index) { TreeViewItem treeViewItem = this.m_AudioGroupTree.FindNode(index); if (treeViewItem != null) { AudioMixerTreeViewNode audioMixerTreeViewNode = treeViewItem as AudioMixerTreeViewNode; if (audioMixerTreeViewNode != null && audioMixerTreeViewNode.group != null) { GenericMenu genericMenu = new GenericMenu(); if (!EditorApplication.isPlaying) { genericMenu.AddItem(new GUIContent("Add child group"), false, new GenericMenu.MenuFunction2(this.AddChildGroupPopupCallback), new AudioMixerGroupPopupContext(this.m_Controller, audioMixerTreeViewNode.group)); if (audioMixerTreeViewNode.group != this.m_Controller.masterGroup) { genericMenu.AddItem(new GUIContent("Add sibling group"), false, new GenericMenu.MenuFunction2(this.AddSiblingGroupPopupCallback), new AudioMixerGroupPopupContext(this.m_Controller, audioMixerTreeViewNode.group)); genericMenu.AddSeparator(string.Empty); genericMenu.AddItem(new GUIContent("Rename"), false, new GenericMenu.MenuFunction2(this.RenameGroupCallback), treeViewItem); AudioMixerGroupController[] array = this.GetGroupSelectionWithoutMasterGroup().ToArray(); genericMenu.AddItem(new GUIContent((array.Length <= 1) ? "Duplicate group (and children)" : "Duplicate groups (and children)"), false, new GenericMenu.MenuFunction2(this.DuplicateGroupPopupCallback), this); genericMenu.AddItem(new GUIContent((array.Length <= 1) ? "Remove group (and children)" : "Remove groups (and children)"), false, new GenericMenu.MenuFunction2(this.DeleteGroupsPopupCallback), this); } } else { genericMenu.AddDisabledItem(new GUIContent("Modifying group topology in play mode is not allowed")); } genericMenu.ShowAsContext(); } } }
internal static void DisplayObjectContextMenu(Rect position, Object[] context, int contextUserData) { // Don't show context menu if we're inside the side-by-side diff comparison. if (EditorGUIUtility.comparisonViewMode != EditorGUIUtility.ComparisonViewMode.None) { return; } Vector2 temp = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y)); position.x = temp.x; position.y = temp.y; GenericMenu pm = new GenericMenu(); if (context != null && context.Length == 1 && context[0] is Component) { Object targetObject = context[0]; Component targetComponent = (Component)targetObject; // Do nothing if component is not on a prefab instance. if (PrefabUtility.GetCorrespondingConnectedObjectFromSource(targetComponent.gameObject) == null) { } // Handle added component. else if (PrefabUtility.GetCorrespondingObjectFromSource(targetObject) == null && targetComponent != null) { GameObject instanceGo = targetComponent.gameObject; PrefabUtility.HandleApplyRevertMenuItems( "Added Component", instanceGo, (menuItemContent, sourceGo) => { TargetChoiceHandler.ObjectInstanceAndSourcePathInfo info = new TargetChoiceHandler.ObjectInstanceAndSourcePathInfo(); info.instanceObject = targetComponent; info.assetPath = AssetDatabase.GetAssetPath(sourceGo); GameObject rootObject = PrefabUtility.GetRootGameObject(sourceGo); if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(instanceGo)) { pm.AddDisabledItem(menuItemContent); } else { pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabAddedComponent, info); } }, (menuItemContent) => { pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabAddedComponent, targetComponent); } ); } else { SerializedObject so = new SerializedObject(targetObject); SerializedProperty property = so.GetIterator(); bool hasPrefabOverride = false; while (property.Next(property.hasChildren)) { if (property.isInstantiatedPrefab && property.prefabOverride && !property.isDefaultOverride) { hasPrefabOverride = true; break; } } // Handle modified component. if (hasPrefabOverride) { bool defaultOverrides = PrefabUtility.IsObjectOverrideAllDefaultOverridesComparedToAnySource(targetObject); PrefabUtility.HandleApplyRevertMenuItems( "Modified Component", targetObject, (menuItemContent, sourceObject) => { TargetChoiceHandler.ObjectInstanceAndSourcePathInfo info = new TargetChoiceHandler.ObjectInstanceAndSourcePathInfo(); info.instanceObject = targetObject; info.assetPath = AssetDatabase.GetAssetPath(sourceObject); GameObject rootObject = PrefabUtility.GetRootGameObject(sourceObject); if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(targetObject)) { pm.AddDisabledItem(menuItemContent); } else { pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabObjectOverride, info); } }, (menuItemContent) => { pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabObjectOverride, targetObject); }, defaultOverrides ); } } } pm.ObjectContextDropDown(position, context, contextUserData); ResetMouseDown(); }
private void CreateEditMenu(Rect position) { GenericMenu editMenu = new GenericMenu(); editMenu.AddItem(new GUIContent("New Configuration"), false, HandleEditMenuOption, EditMenuOptions.NewInputConfiguration); if(_selectionPath.Count >= 1) editMenu.AddItem(new GUIContent("New Axis"), false, HandleEditMenuOption, EditMenuOptions.NewAxisConfiguration); else editMenu.AddDisabledItem(new GUIContent("New Axis")); editMenu.AddSeparator(""); if(_selectionPath.Count > 0) editMenu.AddItem(new GUIContent("Duplicate Shift+D"), false, HandleEditMenuOption, EditMenuOptions.Duplicate); else editMenu.AddDisabledItem(new GUIContent("Duplicate Shift+D")); if(_selectionPath.Count > 0) editMenu.AddItem(new GUIContent("Delete Del"), false, HandleEditMenuOption, EditMenuOptions.Delete); else editMenu.AddDisabledItem(new GUIContent("Delete Del")); if(_inputManager.inputConfigurations.Count > 0) editMenu.AddItem(new GUIContent("Delete All"), false, HandleEditMenuOption, EditMenuOptions.DeleteAll); else editMenu.AddDisabledItem(new GUIContent("Delete All")); if(_selectionPath.Count >= 2) editMenu.AddItem(new GUIContent("Copy"), false, HandleEditMenuOption, EditMenuOptions.Copy); else editMenu.AddDisabledItem(new GUIContent("Copy")); if(_copySource != null && _selectionPath.Count >= 2) editMenu.AddItem(new GUIContent("Paste"), false, HandleEditMenuOption, EditMenuOptions.Paste); else editMenu.AddDisabledItem(new GUIContent("Paste")); editMenu.AddSeparator(""); editMenu.AddItem(new GUIContent("Select Target"), false, HandleEditMenuOption, EditMenuOptions.SelectTarget); editMenu.AddItem(new GUIContent("Ignore Timescale"), _inputManager.ignoreTimescale, HandleEditMenuOption, EditMenuOptions.IgnoreTimescale); editMenu.AddItem(new GUIContent("Dont Destroy On Load"), _inputManager.dontDestroyOnLoad, HandleEditMenuOption, EditMenuOptions.DontDestroyOnLoad); editMenu.DropDown(position); }
internal static void DoToolContextMenu() { var toolHistoryMenu = new GenericMenu() { allowDuplicateNames = true }; var foundTool = false; // Recent history if (EditorToolContext.GetLastCustomTool() != null) { foundTool = true; toolHistoryMenu.AddDisabledItem(Styles.recentTools); EditorToolContext.GetToolHistory(s_ToolList, true); for (var i = 0; i < Math.Min(k_MaxToolHistory, s_ToolList.Count); i++) { var tool = s_ToolList[i]; if (EditorToolUtility.IsCustomEditorTool(tool.GetType())) { continue; } var name = EditorToolUtility.GetToolName(tool.GetType()); if (tool.IsAvailable()) { toolHistoryMenu.AddItem(new GUIContent(name), false, () => { EditorToolContext.activeTool = tool; }); } else { toolHistoryMenu.AddDisabledItem(new GUIContent(name)); } } toolHistoryMenu.AddSeparator(""); } EditorToolContext.GetCustomEditorTools(s_ToolList, false); // Current selection if (s_ToolList.Any()) { foundTool = true; toolHistoryMenu.AddDisabledItem(Styles.selectionTools); for (var i = 0; i < s_ToolList.Count; i++) { var tool = s_ToolList[i]; if (!EditorToolUtility.IsCustomEditorTool(tool.GetType())) { continue; } var path = new GUIContent(EditorToolUtility.GetToolMenuPath(tool)); if (tool.IsAvailable()) { toolHistoryMenu.AddItem(path, false, () => { EditorToolContext.activeTool = tool; }); } else { toolHistoryMenu.AddDisabledItem(path); } } toolHistoryMenu.AddSeparator(""); } var global = EditorToolUtility.GetCustomEditorToolsForType(null); if (global.Any()) { foundTool = true; toolHistoryMenu.AddDisabledItem(Styles.availableTools); foreach (var toolType in global) { toolHistoryMenu.AddItem( new GUIContent(EditorToolUtility.GetToolMenuPath(toolType)), false, () => { EditorTools.EditorTools.SetActiveTool(toolType); }); } } if (!foundTool) { toolHistoryMenu.AddDisabledItem(Styles.noToolsAvailable); } toolHistoryMenu.ShowAsContext(); }
private GenericMenu GenerateMenu(DopeLine dopeline, bool clickedEmpty) { GenericMenu menu = new GenericMenu(); this.state.recording = true; this.state.ResampleAnimation(); string text1 = "Add Key"; if (clickedEmpty) menu.AddItem(new GUIContent(text1), false, new GenericMenu.MenuFunction2(this.AddKeyToDopeline), (object) dopeline); else menu.AddDisabledItem(new GUIContent(text1)); string text2 = this.state.selectedKeys.Count <= 1 ? "Delete Key" : "Delete Keys"; if (this.state.selectedKeys.Count > 0) menu.AddItem(new GUIContent(text2), false, new GenericMenu.MenuFunction(this.DeleteSelectedKeys)); else menu.AddDisabledItem(new GUIContent(text2)); if (AnimationWindowUtility.ContainsFloatKeyframes(this.state.selectedKeys)) { menu.AddSeparator(string.Empty); List<KeyIdentifier> keyList = new List<KeyIdentifier>(); using (List<AnimationWindowKeyframe>.Enumerator enumerator = this.state.selectedKeys.GetEnumerator()) { while (enumerator.MoveNext()) { AnimationWindowKeyframe current = enumerator.Current; if (!current.isPPtrCurve) { int keyframeIndex = current.curve.GetKeyframeIndex(AnimationKeyTime.Time(current.time, this.state.frameRate)); if (keyframeIndex != -1) { CurveRenderer curveRenderer = CurveRendererCache.GetCurveRenderer(this.state.activeAnimationClip, current.curve.binding); int curveId = CurveUtility.GetCurveID(this.state.activeAnimationClip, current.curve.binding); keyList.Add(new KeyIdentifier(curveRenderer, curveId, keyframeIndex, current.curve.binding)); } } } } new CurveMenuManager((CurveUpdater) this).AddTangentMenuItems(menu, keyList); } return menu; }
private void DrawWindowToolbar(FD.FlowWindow window) { /*if (FlowSystem.GetData().modeLayer != ModeLayer.Flow) { return; }*/ //var edit = false; var id = window.id; var buttonStyle = ME.Utilities.CacheStyle("FlowEditor.DrawWindowToolbar.Styles", "toolbarButton", (name) => { var _buttonStyle = new GUIStyle(EditorStyles.toolbarButton); _buttonStyle.stretchWidth = false; return _buttonStyle; }); var buttonDropdownStyle = ME.Utilities.CacheStyle("FlowEditor.DrawWindowToolbar.Styles", "toolbarDropDown", (name) => { var _buttonStyle = new GUIStyle(EditorStyles.toolbarDropDown); _buttonStyle.stretchWidth = false; return _buttonStyle; }); var buttonWarningStyle = ME.Utilities.CacheStyle("FlowEditor.DrawWindowToolbar.Styles", "buttonWarningStyle", (name) => { var _buttonStyle = new GUIStyle(EditorStyles.toolbarButton); _buttonStyle.stretchWidth = false; _buttonStyle.fontStyle = FontStyle.Bold; return _buttonStyle; }); GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); if (this.waitForAttach == false || this.currentAttachComponent == null) { if (this.waitForAttach == true) { if (id != this.currentAttachId) { var currentAttach = FlowSystem.GetWindow(this.currentAttachId); if (currentAttach != null) { //var attachTo = FlowSystem.GetWindow(id); //var hasContainer = currentAttach.HasContainer(); if (currentAttach.IsContainer() == false) { if (FlowSystem.AlreadyAttached(this.currentAttachId, this.currentAttachIndex, id) == true) { if (GUILayout.Button(string.Format("Detach Here{0}", (Event.current.alt == true ? " (Double Direction)" : string.Empty)), buttonStyle) == true) { FlowSystem.Detach(this.currentAttachId, this.currentAttachIndex, id, oneWay: Event.current.alt == false); if (this.onAttach != null) this.onAttach(id, this.currentAttachIndex, false); if (Event.current.shift == false) this.WaitForAttach(-1); } } else { var abTests = (window.abTests.sourceWindowId >= 0/* || currentAttach.attachItems.Any(x => FlowSystem.GetWindow(x.targetId).IsABTest() == true) == true*/); if (this.currentAttachIndex == 0 && (currentAttach.IsABTest() == true || abTests == true)) { /* if (abTests == true) { if (GUILayout.Button("Attach Here", buttonStyle) == true) { this.ShowNotification(new GUIContent("You can't connect using this method. Use `Attach` function on `A/B Test Condition`")); } }*/ } else { if (GUILayout.Button(string.Format("Attach Here{0}", (Event.current.alt == true ? " (Double Direction)" : string.Empty)), buttonStyle) == true) { FlowSystem.Attach(this.currentAttachId, this.currentAttachIndex, id, oneWay: Event.current.alt == false); if (this.onAttach != null) this.onAttach(id, this.currentAttachIndex, true); if (Event.current.shift == false) this.WaitForAttach(-1); } } } } } } else { if (GUILayout.Button("Cancel", buttonStyle) == true) { this.WaitForAttach(-1); } } } else { if (window.IsSmall() == false || window.IsFunction() == true || window.IsABTest() == true) { if (GUILayout.Button("Attach/Detach", buttonStyle) == true) { this.ShowNotification(new GUIContent("Use Attach/Detach buttons to Connect/Disconnect a window")); this.WaitForAttach(id); } } } if (window.IsSmall() == false) { //var isExit = false; var functionWindow = window.GetFunctionContainer(); if (functionWindow != null) { if (functionWindow.functionRootId == 0) functionWindow.functionRootId = id; if (functionWindow.functionExitId == 0) functionWindow.functionExitId = id; //isExit = (functionWindow.functionExitId == id); } var isRoot = (FlowSystem.GetRootWindow() == id || (functionWindow != null && functionWindow.functionRootId == id)); if (GUILayout.Toggle(isRoot, new GUIContent("R", "Set as root"), buttonStyle) != isRoot) { if (functionWindow != null) { if (isRoot == true) { // Was root // Setup root for the first window in function functionWindow.functionRootId = window.id; } else { // Was not root // Setup as root but inside this function only functionWindow.functionRootId = window.id; } } else { if (isRoot == true) { // Was root FlowSystem.SetRootWindow(-1); } else { // Was not root FlowSystem.SetRootWindow(id); } } FlowSystem.SetDirty(); } /* if (functionWindow != null) { if (GUILayout.Toggle(isExit, new GUIContent("E", "Set as exit point"), buttonStyle) != isExit) { if (isExit == true) { // Was exit // Setup exit for the first window in function functionWindow.functionExitId = window.id; } else { // Was not exit // Setup as exit but inside this function only functionWindow.functionExitId = window.id; } FlowSystem.SetDirty(); } }*/ var isDefault = FlowSystem.GetDefaultWindows().Contains(id); if (GUILayout.Toggle(isDefault, new GUIContent("D", "Set as default"), buttonStyle) != isDefault) { if (isDefault == true) { // Was as default FlowSystem.GetDefaultWindows().Remove(id); } else { // Was not as default FlowSystem.GetDefaultWindows().Add(id); } FlowSystem.SetDirty(); } } GUILayout.FlexibleSpace(); if (window.IsSmall() == false && FlowSceneView.IsActive() == false && window.storeType == FD.FlowWindow.StoreType.NewScreen) { var state = GUILayout.Button("Screen", buttonDropdownStyle); if (Event.current.type == EventType.Repaint) { this.layoutStateSelectButtonRect = GUILayoutUtility.GetLastRect(); } if (state == true) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Select Package"), on: false, func: () => { this.SelectWindow(window); }); if (window.compiled == true) { menu.AddItem(new GUIContent("Edit..."), on: false, func: () => { var path = Path.GetDirectoryName(AssetDatabase.GetAssetPath(window.GetScreen())); var filename = window.compiledDerivedClassName + ".cs"; EditorUtility.OpenWithDefaultApp(string.Format("{0}/../{1}", path, filename)); }); } menu.AddItem(new GUIContent("Create on Scene"), on: false, func: () => { this.CreateOnScene(window); }); var screen = window.GetScreen(); var methodsCount = 0; WindowSystem.CollectCallVariations(screen, (types, names) => { ++methodsCount; }); menu.AddDisabledItem(new GUIContent("Calls/Methods: " + methodsCount.ToString())); menu.AddSeparator("Calls/"); if (window.compiled == true && screen != null) { methodsCount = 0; WindowSystem.CollectCallVariations(screen, (types, names) => { var parameters = new List<string>(); for (int i = 0; i < types.Length; ++i) { parameters.Add(ME.Utilities.FormatParameter(types[i]) + " " + names[i]); } var paramsStr = parameters.Count > 0 ? "(" + string.Join(", ", parameters.ToArray()) + ")" : string.Empty; menu.AddItem(new GUIContent("Calls/OnParametersPass" + paramsStr), on: false, func: () => { Selection.activeObject = screen; }); ++methodsCount; }); if (methodsCount == 0) { menu.AddDisabledItem(new GUIContent("Calls/No `OnParametersPass` Methods Found")); } } else { menu.AddDisabledItem(new GUIContent("Calls/You need to compile window")); } Flow.OnFlowWindowScreenMenuGUI(this, window, menu); menu.DropDown(this.layoutStateSelectButtonRect); } /* if (GUILayout.Button("Edit", buttonStyle) == true) { if (window.compiled == false) { this.ShowNotification(new GUIContent("You need to compile this window to use 'Edit' command")); } else { edit = true; } }*/ } if (GUILayout.Button("X", buttonWarningStyle) == true) { if (EditorUtility.DisplayDialog("Are you sure?", "Current window will be destroyed with all links.", "Yes, destroy", "No") == true) { this.ShowNotification(new GUIContent(string.Format("The window `{0}` was successfully destroyed", window.title))); FlowSystem.DestroyWindow(id); return; } } } else { // Draw Attach/Detach component link if (this.currentAttachId == id) { // Cancel if (GUILayout.Button("Cancel", buttonStyle) == true) { this.WaitForAttach(-1); } } else { // If it's other window if (window.IsSmall() == false || window.IsFunction() == true) { if (FlowSystem.AlreadyAttached(this.currentAttachId, this.currentAttachIndex, id, this.currentAttachComponent) == true) { if (GUILayout.Button("Detach Here", buttonStyle) == true) { FlowSystem.Detach(this.currentAttachId, this.currentAttachIndex, id, oneWay: true, component: this.currentAttachComponent); if (this.onAttach != null) this.onAttach(id, this.currentAttachIndex, false); if (Event.current.shift == false) this.WaitForAttach(-1); } } else { if (GUILayout.Button("Attach Here", buttonStyle) == true) { FlowSystem.Attach(this.currentAttachId, this.currentAttachIndex, id, oneWay: true, component: this.currentAttachComponent); if (this.onAttach != null) this.onAttach(id, this.currentAttachIndex, true); if (Event.current.shift == false) this.WaitForAttach(-1); } } } } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); /*if (edit == true) { FlowSceneView.SetControl(this, window, this.OnItemProgress); }*/ }
private void CreateMultiSceneHeaderContextClick(GenericMenu menu, int contextClickedItemID) { Scene sceneByHandle = EditorSceneManager.GetSceneByHandle(contextClickedItemID); if (!SceneHierarchyWindow.IsSceneHeaderInHierarchyWindow(sceneByHandle)) { Debug.LogError((object)"Context clicked item is not a scene"); } else { if (sceneByHandle.isLoaded) { menu.AddItem(EditorGUIUtility.TextContent("Set Active Scene"), false, new GenericMenu.MenuFunction2(this.SetSceneActive), (object)contextClickedItemID); menu.AddSeparator(string.Empty); } if (sceneByHandle.isLoaded) { if (!EditorApplication.isPlaying) { menu.AddItem(EditorGUIUtility.TextContent("Save Scene"), false, new GenericMenu.MenuFunction2(this.SaveSelectedScenes), (object)contextClickedItemID); menu.AddItem(EditorGUIUtility.TextContent("Save Scene As"), false, new GenericMenu.MenuFunction2(this.SaveSceneAs), (object)contextClickedItemID); menu.AddItem(EditorGUIUtility.TextContent("Save All"), false, new GenericMenu.MenuFunction2(this.SaveAllScenes), (object)contextClickedItemID); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Save Scene")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Save Scene As")); menu.AddDisabledItem(EditorGUIUtility.TextContent("Save All")); } menu.AddSeparator(string.Empty); } bool flag1 = EditorSceneManager.loadedSceneCount != this.GetNumLoadedScenesInSelection(); if (sceneByHandle.isLoaded) { if (flag1 && !EditorApplication.isPlaying && !string.IsNullOrEmpty(sceneByHandle.path)) { menu.AddItem(EditorGUIUtility.TextContent("Unload Scene"), false, new GenericMenu.MenuFunction2(this.UnloadSelectedScenes), (object)contextClickedItemID); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Unload Scene")); } } else if (!EditorApplication.isPlaying) { menu.AddItem(EditorGUIUtility.TextContent("Load Scene"), false, new GenericMenu.MenuFunction2(this.LoadSelectedScenes), (object)contextClickedItemID); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Load Scene")); } bool flag2 = this.GetSelectedScenes().Count == SceneManager.sceneCount; if (flag1 && !flag2 && !EditorApplication.isPlaying) { menu.AddItem(EditorGUIUtility.TextContent("Remove Scene"), false, new GenericMenu.MenuFunction2(this.RemoveSelectedScenes), (object)contextClickedItemID); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Remove Scene")); } menu.AddSeparator(string.Empty); if (!string.IsNullOrEmpty(sceneByHandle.path)) { menu.AddItem(EditorGUIUtility.TextContent("Select Scene Asset"), false, new GenericMenu.MenuFunction2(this.SelectSceneAsset), (object)contextClickedItemID); } else { menu.AddDisabledItem(new GUIContent("Select Scene Asset")); } if (!sceneByHandle.isLoaded) { return; } menu.AddSeparator(string.Empty); this.AddCreateGameObjectItemsToMenu(menu, (UnityEngine.Object[])((IEnumerable <Transform>)Selection.transforms).Select <Transform, GameObject>((Func <Transform, GameObject>)(t => t.gameObject)).ToArray <GameObject>(), false, true, sceneByHandle.handle); } }
static void SetupAction(SerializedProperty property, GenericMenu menu, Event evt, Action <SerializedProperty> copyFunc, Func <SerializedProperty, bool> canPasteFunc, Action <SerializedProperty> pasteFunc) { var canCopy = !property.hasMultipleDifferentValues; var canPaste = GUI.enabled && canPasteFunc(property); if (menu != null) { AddSeparator(menu); var copyContent = overrideCopyContent ?? kCopyContent; if (canCopy) { menu.AddItem(copyContent, false, o => copyFunc((SerializedProperty)o), property); } else { menu.AddDisabledItem(copyContent); } var pasteContent = overridePasteContent ?? kPasteContent; if (canPaste) { menu.AddItem(pasteContent, false, delegate(object o) { var prop = (SerializedProperty)o; pasteFunc(prop); prop.serializedObject.ApplyModifiedProperties(); // Constrain proportions scale widget might need extra recalculation, notify if a paste ConstrainProportionsTransformScale.NotifyPropertyPasted(prop.propertyPath); }, property); } else { menu.AddDisabledItem(pasteContent); } } if (evt != null) { if (canCopy && evt.commandName == EventCommandNames.Copy) { if (evt.type == EventType.ValidateCommand) { evt.Use(); } if (evt.type == EventType.ExecuteCommand) { copyFunc(property); evt.Use(); } } if (canPaste && evt.commandName == EventCommandNames.Paste) { if (evt.type == EventType.ValidateCommand) { evt.Use(); } if (evt.type == EventType.ExecuteCommand) { pasteFunc(property); property.serializedObject.ApplyModifiedProperties(); evt.Use(); } } } }