AddSeparator() 공개 메소드

public AddSeparator ( string path ) : void
path string
리턴 void
예제 #1
0
 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);
         }
     }
 }
예제 #2
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Sort groups alphabetically"), this.m_SortGroupsAlphabetically, () => this.m_SortGroupsAlphabetically = !this.m_SortGroupsAlphabetically);
     menu.AddItem(new GUIContent("Show referenced groups"), this.m_ShowReferencedBuses, () => this.m_ShowReferencedBuses = !this.m_ShowReferencedBuses);
     menu.AddItem(new GUIContent("Show group connections"), this.m_ShowBusConnections, () => this.m_ShowBusConnections = !this.m_ShowBusConnections);
     if (this.m_ShowBusConnections)
     {
         menu.AddItem(new GUIContent("Only highlight selected group connections"), this.m_ShowBusConnectionsOfSelection, () => this.m_ShowBusConnectionsOfSelection = !this.m_ShowBusConnectionsOfSelection);
     }
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Vertical layout"), this.layoutMode == LayoutMode.Vertical, () => this.layoutMode = LayoutMode.Vertical);
     menu.AddItem(new GUIContent("Horizontal layout"), this.layoutMode == LayoutMode.Horizontal, () => this.layoutMode = LayoutMode.Horizontal);
     menu.AddSeparator("");
     if (<>f__am$cache0 == null)
     {
예제 #3
0
 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();
 }
예제 #4
0
 public void DeleteLinkMenuAndReLink <T>(List <T> nodes, UnityEditor.GenericMenu menu, string title, Action act) where T : LogicNodeBase
 {
     if (nodes.Count == 0)
     {
         return;
     }
     menu.AddSeparator("");
     nodes.ForEach(x => menu.AddItem(new GUIContent(title + "/" + x.ShowName), false, () => { nodes.Remove(x); act(); }));
 }
 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);
     }
   }
 }
 public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
 {
   EditorGUI.BeginChangeCheck();
   float fieldWidth = EditorGUIUtility.fieldWidth;
   string fieldFormatString = EditorGUI.kFloatFieldFormatString;
   bool flag = controller.ContainsExposedParameter(path.parameter);
   EditorGUIUtility.fieldWidth = 70f;
   EditorGUI.kFloatFieldFormatString = "F2";
   EditorGUI.s_UnitString = unit;
   GUIContent label1 = label;
   if (flag)
     label1 = GUIContent.Temp(label.text + " ➔", label.tooltip);
   float num1 = value * displayScale;
   float num2 = EditorGUILayout.PowerSlider(label1, num1, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
   EditorGUI.s_UnitString = (string) null;
   EditorGUI.kFloatFieldFormatString = fieldFormatString;
   EditorGUIUtility.fieldWidth = fieldWidth;
   if (Event.current.type == EventType.ContextClick && GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
   {
     Event.current.Use();
     GenericMenu genericMenu = new GenericMenu();
     if (!flag)
       genericMenu.AddItem(new GUIContent("Expose '" + path.ResolveStringPath(false) + "' to script"), false, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ExposePopupCallback), (object) new AudioMixerEffectGUI.ExposedParamContext(controller, path));
     else
       genericMenu.AddItem(new GUIContent("Unexpose"), false, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.UnexposePopupCallback), (object) new AudioMixerEffectGUI.ExposedParamContext(controller, path));
     ParameterTransitionType type;
     controller.TargetSnapshot.GetTransitionTypeOverride(path.parameter, out type);
     genericMenu.AddSeparator(string.Empty);
     genericMenu.AddItem(new GUIContent("Linear Snapshot Transition"), type == ParameterTransitionType.Lerp, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object) new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Lerp));
     genericMenu.AddItem(new GUIContent("Smoothstep Snapshot Transition"), type == ParameterTransitionType.Smoothstep, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object) new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Smoothstep));
     genericMenu.AddItem(new GUIContent("Squared Snapshot Transition"), type == ParameterTransitionType.Squared, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object) new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Squared));
     genericMenu.AddItem(new GUIContent("SquareRoot Snapshot Transition"), type == ParameterTransitionType.SquareRoot, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object) new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.SquareRoot));
     genericMenu.AddItem(new GUIContent("BrickwallStart Snapshot Transition"), type == ParameterTransitionType.BrickwallStart, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object) new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallStart));
     genericMenu.AddItem(new GUIContent("BrickwallEnd Snapshot Transition"), type == ParameterTransitionType.BrickwallEnd, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object) new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallEnd));
     genericMenu.AddSeparator(string.Empty);
     genericMenu.ShowAsContext();
   }
   if (!EditorGUI.EndChangeCheck())
     return false;
   value = num2 / displayScale;
   return true;
 }
		public override void OnFlowToolsMenuGUI(string prefix, GenericMenu menu) {
			
			menu.AddSeparator(string.Empty);

			menu.AddItem(new GUIContent(prefix + "Open Device Preview"), on: false, func: () => {
				
				DevicePreview.ShowEditor();

			});
			
		}
예제 #8
0
 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("");
     }
     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);
         }
     }
 }
		private void OpenGroupContextMenu(AudioMixerTreeViewNode audioNode, bool visible)
		{
			GenericMenu genericMenu = new GenericMenu();
			if (this.NodeWasToggled != null)
			{
				genericMenu.AddItem(new GUIContent((!visible) ? "Show Group" : "Hide group"), false, delegate
				{
					this.NodeWasToggled(audioNode, !visible);
				});
			}
			genericMenu.AddSeparator(string.Empty);
			AudioMixerColorCodes.AddColorItemsToGenericMenu(genericMenu, audioNode.group);
			genericMenu.ShowAsContext();
		}
예제 #11
0
		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);
				}
			}
		}
			public static void Show(Rect buttonRect, AudioMixerSnapshotController snapshot, AudioMixerSnapshotListView list)
			{
				GenericMenu genericMenu = new GenericMenu();
				AudioMixerSnapshotListView.SnapshotMenu.data userData = new AudioMixerSnapshotListView.SnapshotMenu.data
				{
					snapshot = snapshot,
					list = list
				};
				genericMenu.AddItem(new GUIContent("Set as start Snapshot"), false, new GenericMenu.MenuFunction2(AudioMixerSnapshotListView.SnapshotMenu.SetAsStartupSnapshot), userData);
				genericMenu.AddSeparator(string.Empty);
				genericMenu.AddItem(new GUIContent("Rename"), false, new GenericMenu.MenuFunction2(AudioMixerSnapshotListView.SnapshotMenu.Rename), userData);
				genericMenu.AddItem(new GUIContent("Duplicate"), false, new GenericMenu.MenuFunction2(AudioMixerSnapshotListView.SnapshotMenu.Duplicate), userData);
				genericMenu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(AudioMixerSnapshotListView.SnapshotMenu.Delete), userData);
				genericMenu.DropDown(buttonRect);
			}
예제 #13
0
		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

		}
예제 #14
0
        public void CreateMenuItems(GenericMenu genericMenu)
        {
            var groups = Commands.GroupBy(p => p==null? "" : p.Group).OrderBy(p => p.Key).ToArray();

            foreach (var group in groups)
            {

                //genericMenu.AddDisabledItem(new GUIContent(group.Key));
                var groupCount = 0;
                foreach (var editorCommand in group.OrderBy(p => p.Order))
                {
                    ICommand command = editorCommand.Command;
                    genericMenu.AddItem(new GUIContent(editorCommand.Title),editorCommand.Checked, () =>
                    {
                        InvertApplication.Execute(command);
                    } );
                    groupCount ++;
                }
                if (group != groups.Last() && groupCount > 0)
                    genericMenu.AddSeparator(null);
            }
        }
예제 #15
0
        /// <summary>
        /// Shows a context menu for the supplied transition.
        /// <param name="transition">The target transition.</param>
        /// </summary>
        void ShowContextMenu(StateTransition transition)
        {
            var menu           = new UnityEditor.GenericMenu();
            var currentEventID = transition.eventID;

            // Add none
            menu.AddItem(new GUIContent("None"), currentEventID == 0, delegate() { StateUtility.SetNewEvent(m_State, transition, 0); this.Refresh(); });

            // 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(fsmEvent.name), currentEventID == fsmEvent.id, delegate() { StateUtility.SetNewEvent(m_State, transition, eventId); this.Refresh(); });
                }
            }

            // 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 ? "System/" + globalEvent.name : "Global/" + globalEvent.name;
                    menu.AddItem(new GUIContent(eventName), currentEventID == globalEvent.id, delegate() { StateUtility.SetNewEvent(m_State, transition, eventId); this.Refresh(); });
                }
            }

            menu.AddSeparator("");  // Separator

            menu.AddItem(new GUIContent("Delete"), false, delegate() { StateUtility.RemoveTransition(m_State, transition); this.Refresh(); });

            // Shows the context menu
            menu.ShowAsContext();
        }
예제 #16
0
        /// <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();
        }
 private void OpenGroupContextMenu(AudioMixerTreeViewNode audioNode, bool visible)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   AudioGroupTreeViewGUI.\u003COpenGroupContextMenu\u003Ec__AnonStorey64 menuCAnonStorey64 = new AudioGroupTreeViewGUI.\u003COpenGroupContextMenu\u003Ec__AnonStorey64();
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey64.audioNode = audioNode;
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey64.visible = visible;
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey64.\u003C\u003Ef__this = this;
   GenericMenu menu = new GenericMenu();
   if (this.NodeWasToggled != null)
   {
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated method
     menu.AddItem(new GUIContent(!menuCAnonStorey64.visible ? "Show Group" : "Hide group"), false, new GenericMenu.MenuFunction(menuCAnonStorey64.\u003C\u003Em__B2));
   }
   menu.AddSeparator(string.Empty);
   AudioMixerGroupController[] groups;
   // ISSUE: reference to a compiler-generated field
   if (this.m_Controller.CachedSelection.Contains(menuCAnonStorey64.audioNode.group))
   {
     groups = this.m_Controller.CachedSelection.ToArray();
   }
   else
   {
     // ISSUE: reference to a compiler-generated field
     groups = new AudioMixerGroupController[1]
     {
       menuCAnonStorey64.audioNode.group
     };
   }
   AudioMixerColorCodes.AddColorItemsToGenericMenu(menu, groups);
   menu.ShowAsContext();
 }
예제 #18
0
        private void DrawMainToolbar()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            // Graph types
            Rect popupRect = GUILayoutUtility.GetRect(Styles.addArea, EditorStyles.toolbarDropDown, GUILayout.Width(Chart.kSideWidth));

            if (EditorGUI.DropdownButton(popupRect, Styles.addArea, FocusType.Passive, EditorStyles.toolbarDropDown))
            {
                int length   = m_Charts.Length;
                var names    = new string[length];
                var enabled  = new bool[length];
                var selected = new int[length];
                for (int c = 0; c < length; ++c)
                {
                    names[c]    = L10n.Tr(((ProfilerArea)c).ToString());
                    enabled[c]  = true;
                    selected[c] = m_Charts[c].active ? c : -1;
                }
                EditorUtility.DisplayCustomMenu(popupRect, names, enabled, selected, AddAreaClick, null);
            }

            // Engine attach
            ConnectionGUILayout.AttachToPlayerDropdown(m_AttachProfilerState, EditorStyles.toolbarDropDown);

            // Record
            var profilerEnabled = GUILayout.Toggle(m_Recording, m_Recording ? Styles.profilerRecordOn : Styles.profilerRecordOff, EditorStyles.toolbarButton);

            if (profilerEnabled != m_Recording)
            {
                ProfilerDriver.enabled = profilerEnabled;
                m_Recording            = profilerEnabled;
                SessionState.SetBool(kProfilerEnabledSessionKey, profilerEnabled);
            }

            FrameNavigationControls();

            using (new EditorGUI.DisabledScope(ProfilerDriver.lastFrameIndex == -1))
            {
                // Clear
                if (GUILayout.Button(Styles.clearData, EditorStyles.toolbarButton))
                {
                    Clear();
                }
            }

            // Separate File/Stream control elements from toggles
            GUILayout.FlexibleSpace();

            // Clear on Play
            SetClearOnPlay(GUILayout.Toggle(GetClearOnPlay(), Styles.clearOnPlay, EditorStyles.toolbarButton));

            using (new EditorGUI.DisabledScope(m_AttachProfilerState.connectedToTarget != ConnectionTarget.Editor))
            {
                // Deep profiling
                SetProfileDeepScripts(GUILayout.Toggle(ProfilerDriver.deepProfiling, Styles.deepProfile, EditorStyles.toolbarButton));
            }

            // Allocation callstacks
            AllocationCallstacksToolbarItem();

            // keep more space between the toggles and the overflow/help icon buttons on the far right, keep deep profiling closer to the other controls
            GUILayout.FlexibleSpace();
            GUILayout.FlexibleSpace();
            GUILayout.FlexibleSpace();

            // Load profile
            if (GUILayout.Button(Styles.loadProfilingData, EditorStyles.toolbarButton, GUILayout.MaxWidth(25)))
            {
                LoadProfilingData(Event.current.shift);
            }

            // Save profile
            using (new EditorGUI.DisabledScope(ProfilerDriver.lastFrameIndex == -1))
            {
                if (GUILayout.Button(Styles.saveProfilingData, EditorStyles.toolbarButton))
                {
                    SaveProfilingData();
                }
            }

            // Open Manual
            if (GUILayout.Button(Styles.helpButtonContent, EditorStyles.toolbarButton))
            {
                Application.OpenURL(Styles.linkToManual);
            }

            // Overflow Menu
            var overflowMenuRect = GUILayoutUtility.GetRect(Styles.optionsButtonContent, EditorStyles.toolbarButton);

            if (GUI.Button(overflowMenuRect, Styles.optionsButtonContent, EditorStyles.toolbarButton))
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(Styles.accessibilityModeLabel, UserAccessiblitySettings.colorBlindCondition != ColorBlindCondition.Default, OnToggleColorBlindMode);
                menu.AddSeparator("");
                menu.AddItem(Styles.preferencesButtonContent, false, OpenProfilerPreferences);
                menu.DropDown(overflowMenuRect);
            }

            GUILayout.EndHorizontal();
        }
예제 #19
0
	private void OnGUI()
	{
		if (Event.current.isKey && TabSwitcher.OnGUIGlobal())
			return;
		
		var isOSX = Application.platform == RuntimePlatform.OSXEditor;
		
		//if (TabSwitcher.instance)
		//{
		//	/*if ((Event.current.modifiers & (isOSX ? EventModifiers.Alt : EventModifiers.Control)) == 0)
		//	{
		//		TabSwitcher.instance.Close();
		//		addRecentLocationForNextAsset = true;
		//		OpenAssetInTab(TabSwitcher.GetSelectedGUID());
		//	}
		//	else*/ if (Event.current.isKey)// || Event.current.isMouse)
		//	{
		//		TabSwitcher.instance.OnGUI();
		//		return;
		//	}
		//}
		
		switch (Event.current.type)
		{
			case EventType.layout:
				if (IsFloating() && FGTextBuffer.activeEditor == textEditor)
					defaultPosition = position;
				break;
				
			case EventType.KeyDown:
				//if (!TabSwitcher.instance && Event.current.keyCode == KeyCode.Tab)
				//{
				//	if (isOSX ?
				//		Event.current.alt && !EditorGUI.actionKey :
				//		!Event.current.alt && EditorGUI.actionKey)
				//	{
				//		var isShift = Event.current.shift;
				//		EditorApplication.delayCall += () =>
				//		{
				//			TabSwitcher.instance = TabSwitcher.Create(!isShift);
				//		};
				//	}
				//}
				if ((Event.current.modifiers & ~(EventModifiers.FunctionKey | EventModifiers.Numeric | EventModifiers.CapsLock)) == EventModifiers.Control &&
					(Event.current.keyCode == KeyCode.PageUp || Event.current.keyCode == KeyCode.PageDown))
				{
					SelectAdjacentCodeTab(Event.current.keyCode == KeyCode.PageDown);
					Event.current.Use();
					GUIUtility.ExitGUI();
				}
				else if (Event.current.alt && Event.current.control)
				{
					if (Event.current.keyCode == KeyCode.RightArrow || Event.current.keyCode == KeyCode.LeftArrow)
					{
						if (Event.current.shift)
						{
							MoveThisTab(Event.current.keyCode == KeyCode.RightArrow);
						}
						else
						{
							SelectAdjacentCodeTab(Event.current.keyCode == KeyCode.RightArrow);
						}
						Event.current.Use();
						GUIUtility.ExitGUI();
					}
				}
				else if (!Event.current.alt && isOSX == Event.current.shift && EditorGUI.actionKey)
				{
					if (Event.current.keyCode == KeyCode.W || Event.current.keyCode == KeyCode.F4)
					{
						Event.current.Use();
						if (!IsMaximized())
							Close();
					}
				}
				else if (!isOSX && !Event.current.alt && Event.current.shift && EditorGUI.actionKey)
				{
					if (Event.current.keyCode == KeyCode.W || Event.current.keyCode == KeyCode.F4)
					{
						CloseOtherTabs();
					}
				}
				else if (Event.current.alt && !Event.current.shift && !EditorGUI.actionKey && Event.current.keyCode == KeyCode.Return)
				{
					Event.current.Use();
					ToggleMaximized(this);
					GUIUtility.ExitGUI();
				}
				break;
				
			case EventType.DragUpdated:
			case EventType.DragPerform:
				if (DragAndDrop.objectReferences.Length > 0)
				{
					bool ask = false;

					HashSet<Object> accepted = new HashSet<Object>();
					foreach (Object obj in DragAndDrop.objectReferences)
					{
						var assetPath = AssetDatabase.GetAssetPath(obj);
						if (assetPath.EndsWith(".dll", System.StringComparison.OrdinalIgnoreCase) ||
							assetPath.EndsWith(".exe", System.StringComparison.OrdinalIgnoreCase))
						{
							continue;
						}
						
						if (assetPath.StartsWith("Assets/", System.StringComparison.OrdinalIgnoreCase))
						{
							if (obj is MonoScript)
								accepted.Add(obj);
							else if (obj is TextAsset || obj is Shader)
								accepted.Add(obj);
							else if (obj is Material)
							{
								Material material = obj as Material;
								if (material.shader != null)
								{
									int shaderID = material.shader.GetInstanceID();
									if (shaderID != 0)
									{
										assetPath = AssetDatabase.GetAssetPath(shaderID);
										if (!string.IsNullOrEmpty(assetPath) && assetPath.StartsWith("Assets/", System.StringComparison.OrdinalIgnoreCase))
											accepted.Add(material.shader);
									}
								}
							}
						}
						else if (obj is GameObject)
						{
							GameObject gameObject = obj as GameObject;
							MonoBehaviour[] monoBehaviours = gameObject.GetComponents<MonoBehaviour>();
							foreach (MonoBehaviour mb in monoBehaviours)
							{
								MonoScript monoScript = MonoScript.FromMonoBehaviour(mb);
								if (monoScript != null)
								{
									assetPath = AssetDatabase.GetAssetPath(monoScript);
									if (!string.IsNullOrEmpty(assetPath) &&
										assetPath.StartsWith("Assets/", System.StringComparison.OrdinalIgnoreCase) &&
										!assetPath.EndsWith(".dll", System.StringComparison.OrdinalIgnoreCase))
									{
										accepted.Add(monoScript);
										ask = true;
									}
								}
							}
						}
					}
					
					if (accepted.Count > 0)
					{
						DragAndDrop.AcceptDrag();
						DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
						if (Event.current.type == EventType.DragPerform)
						{
							Object[] sorted = accepted.OrderBy(x => x.name, System.StringComparer.OrdinalIgnoreCase).ToArray();

							if (ask && sorted.Length > 1)
							{
								GenericMenu popupMenu = new GenericMenu();
								foreach (Object target in sorted)
								{
									Object tempTarget = target;
									string fileName = System.IO.Path.GetFileName(AssetDatabase.GetAssetPath(target));
#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
									popupMenu.AddItem(
										new GUIContent("Open " + fileName),
										false,
										() => { OpenNewWindow(tempTarget, this, true); });
								}
								popupMenu.AddSeparator("");
								popupMenu.AddItem(
									new GUIContent("Open All"),
									false,
									() => { foreach (Object target in sorted) OpenNewWindow(target, this, true); });
								
								popupMenu.ShowAsContext();
							}
							else
							{
								foreach (Object target in sorted)
									OpenNewWindow(target, this, true);
							}
						}
						Event.current.Use();
						return;
					}
				}
				break;

			case EventType.ValidateCommand:
				if (Event.current.commandName == "ScriptInspector.AddTab")
				{
					Event.current.Use();
					return;
				}
				break;

			case EventType.ExecuteCommand:
				if (Event.current.commandName == "ScriptInspector.AddTab")
				{
					Event.current.Use();
					OpenNewWindow(targetAsset, this, false);
					return;
				}
				break;
		}
		
		if (!wantsMouseMove)
			wantsMouseMove = true;
		textEditor.OnWindowGUI(this, new RectOffset(0, 0, 19, 1));
	}
예제 #20
0
		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);

			}*/
			
		}
예제 #21
0
    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();
    }
예제 #22
0
        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"));
            }
        }
예제 #23
0
        ///----------------------------------------------------------------------------------------------

        ///Graph events AFTER nodes
        static void HandlePostNodesGraphEvents(Graph graph, Vector2 canvasMousePos)
        {
            //Shortcuts
            if (GUIUtility.keyboardControl == 0)
            {
                //Copy/Cut/Paste
                if (e.type == EventType.ValidateCommand || e.type == EventType.Used)
                {
                    if (e.commandName == "Copy" || e.commandName == "Cut")
                    {
                        List <Node> selection = null;
                        if (GraphEditorUtility.activeNode != null)
                        {
                            selection = new List <Node> {
                                GraphEditorUtility.activeNode
                            };
                        }
                        if (GraphEditorUtility.activeElements != null && GraphEditorUtility.activeElements.Count > 0)
                        {
                            selection = GraphEditorUtility.activeElements.Cast <Node>().ToList();
                        }
                        if (selection != null)
                        {
                            CopyBuffer.Set <Node[]>(Graph.CloneNodes(selection).ToArray());
                            if (e.commandName == "Cut")
                            {
                                foreach (Node node in selection)
                                {
                                    graph.RemoveNode(node);
                                }
                            }
                        }
                        e.Use();
                    }
                    if (e.commandName == "Paste")
                    {
                        if (CopyBuffer.Has <Node[]>())
                        {
                            TryPasteNodesInGraph(graph, CopyBuffer.Get <Node[]>(), canvasMousePos + new Vector2(500, 500) / graph.zoomFactor);
                        }
                        e.Use();
                    }
                }

                if (e.type == EventType.KeyUp)
                {
                    //Delete
                    if (e.keyCode == KeyCode.Delete || e.keyCode == KeyCode.Backspace)
                    {
                        if (GraphEditorUtility.activeElements != null && GraphEditorUtility.activeElements.Count > 0)
                        {
                            foreach (var obj in GraphEditorUtility.activeElements.ToArray())
                            {
                                if (obj is Node)
                                {
                                    graph.RemoveNode(obj as Node);
                                }
                                if (obj is Connection)
                                {
                                    graph.RemoveConnection(obj as Connection);
                                }
                            }
                            GraphEditorUtility.activeElements = null;
                        }

                        if (GraphEditorUtility.activeNode != null)
                        {
                            graph.RemoveNode(GraphEditorUtility.activeNode);
                            GraphEditorUtility.activeElement = null;
                        }

                        if (GraphEditorUtility.activeConnection != null)
                        {
                            graph.RemoveConnection(GraphEditorUtility.activeConnection);
                            GraphEditorUtility.activeElement = null;
                        }
                        e.Use();
                    }

                    //Duplicate
                    if (e.keyCode == KeyCode.D && e.control && !e.alt)
                    {
                        if (GraphEditorUtility.activeElements != null && GraphEditorUtility.activeElements.Count > 0)
                        {
                            TryPasteNodesInGraph(graph, GraphEditorUtility.activeElements.OfType <Node>().ToArray(), default(Vector2));
                        }
                        if (GraphEditorUtility.activeNode != null)
                        {
                            GraphEditorUtility.activeElement = GraphEditorUtility.activeNode.Duplicate(graph);
                        }
                        //Connections can't be duplicated by themselves. They do so as part of multiple node duplication.
                        e.Use();
                    }
                }
            }

            //No panel is obscuring
            if (GraphEditorUtility.allowClick)
            {
                #region 自定义快捷键

                if ((currentGraph.GetType() == typeof(FlowGraph) || currentGraph.GetType().IsSubclassOf(typeof(FlowGraph))) && GUIUtility.keyboardControl == 0)
                {
                    if (e.keyCode == KeyCode.F && e.control && !e.alt)
                    {
                        //Debug.Log("ctrl +f ");

                        FindNode toolNode = currentGraph.GetAllNodesOfType <FindNode>().FirstOrDefault();
                        if (toolNode != null)
                        {
                            NodeCanvas.Editor.GraphEditorUtility.activeElement = toolNode;
                        }
                        else
                        {
                            FindNode newNode = currentGraph.AddNode <FindNode>(ViewToCanvas(e.mousePosition));

                            NodeCanvas.Editor.GraphEditorUtility.activeElement = newNode;
                            //Debug.Log("There is no Find Node,Create a new node!");
                        }
                        //e.Use();
                    }


                    if (e.keyCode == KeyCode.A && e.control && !e.alt && !e.shift)
                    {
                        NodeCanvas.Editor.GraphEditorUtility.activeElements = null;
                        NodeCanvas.Editor.GraphEditorUtility.activeElement  = null;

                        if (currentGraph.allNodes == null)
                        {
                            return;
                        }

                        if (currentGraph.allNodes.Count > 1)
                        {
                            NodeCanvas.Editor.GraphEditorUtility.activeElements = currentGraph.allNodes.Cast <object>().ToList();
                            //e.Use();
                            return;
                        }
                        else
                        {
                            NodeCanvas.Editor.GraphEditorUtility.activeElement = currentGraph.allNodes[0];
                            //e.Use();
                        }
                    }
                    if (e.keyCode == KeyCode.C && e.type == EventType.KeyUp && !e.control && !e.alt && !e.shift && GUIUtility.keyboardControl == 0)
                    {
                        if (GraphEditorUtility.activeElement != null ||
                            GraphEditorUtility.activeElements != null && GraphEditorUtility.activeElements.Count > 0)
                        {
                            List <Node> node = new List <Node>();
                            if (GraphEditorUtility.activeElement != null)
                            {
                                node.Add((Node)GraphEditorUtility.activeElement);
                            }
                            else
                            {
                                node = GraphEditorUtility.activeElements.Cast <Node>().ToList();
                            }

                            Undo.RegisterCompleteObjectUndo(currentGraph, "Create Group");
                            if (currentGraph.canvasGroups == null)
                            {
                                currentGraph.canvasGroups = new List <Framework.CanvasGroup>();
                            }
                            Framework.CanvasGroup group = new Framework.CanvasGroup(GetNodeBounds(node).ExpandBy(100f), "New Canvas Group");
                            currentGraph.canvasGroups.Add(group);
                            group.isRenaming = true;
                        }
                    }
                    if (e.keyCode == KeyCode.G && !e.control && !e.alt && e.shift && GUIUtility.keyboardControl == 0)
                    {
                        if (NodeCanvas.Editor.GraphEditorUtility.activeElements == null ||
                            NodeCanvas.Editor.GraphEditorUtility.activeElements.Count < 2 && NodeCanvas.Editor.GraphEditorUtility.activeElement != null &&
                            NodeCanvas.Editor.GraphEditorUtility.activeElement.GetType() == typeof(MacroNodeWrapper))
                        {
                            //Debug.Log("current select is group node");
                            MacroNodeWrapper n = (MacroNodeWrapper)NodeCanvas.Editor.GraphEditorUtility.activeElement;

                            if (n.macro.allNodes.Count <= 2)
                            {
                                return;
                            }
                            List <Node> childNode = new List <Node>();

                            foreach (var c in n.macro.allNodes)
                            {
                                if (c.GetType() != typeof(MacroInputNode) && c.GetType() != typeof(MacroOutputNode))
                                {
                                    childNode.Add(c);
                                }
                            }

                            var newNodes = Graph.CopyNodesToGraph(childNode, currentGraph);

                            currentGraph.RemoveNode(n);
                            NodeCanvas.Editor.GraphEditorUtility.activeElement = null;

                            if (NodeCanvas.Editor.GraphEditorUtility.activeElements != null)
                            {
                                NodeCanvas.Editor.GraphEditorUtility.activeElements = newNodes.Cast <object>().ToList();
                            }
                        }
                    }

                    if (e.keyCode == KeyCode.G && e.control && !e.alt && !e.shift && GUIUtility.keyboardControl == 0)
                    {
                        //Debug.Log("ctrl +g ");
                        if (NodeCanvas.Editor.GraphEditorUtility.activeElements == null || NodeCanvas.Editor.GraphEditorUtility.activeElements.Count < 1)
                        {
                            //e.Use();
                            return;
                        }

                        List <Node> ns            = NodeCanvas.Editor.GraphEditorUtility.activeElements.Cast <Node>().ToList();
                        Rect        groupNodeRect = GetNodeBounds(ns, viewRect, false);
                        var         wrapper       = currentGraph.AddNode <MacroNodeWrapper>(groupNodeRect.center);
                        wrapper.macro              = NestedUtility.CreateBoundNested <GroupMacro>(wrapper, currentGraph);
                        wrapper.macro.name         = "NewGroup";
                        wrapper.macro.CategoryPath = (currentGraph.agent != null ? currentGraph.agent.name : currentGraph.name) + "/";
                        wrapper.macro.agent        = currentGraph.agent;

                        wrapper.macro.entry.position = new Vector2(groupNodeRect.x - 200f,
                                                                   groupNodeRect.y + 0.5f * groupNodeRect.height);
                        wrapper.macro.exit.position = new Vector2(groupNodeRect.x + groupNodeRect.width + 100f,
                                                                  groupNodeRect.y + 0.5f * groupNodeRect.height);

                        wrapper.macro.translation = -groupNodeRect.center + new Vector2(500f, 500f);

                        Graph.CopyNodesToGraph(NodeCanvas.Editor.GraphEditorUtility.activeElements.OfType <Node>().ToList(), wrapper.macro);

                        foreach (var c in ns)
                        {
                            currentGraph.RemoveNode(c);
                        }
                        NodeCanvas.Editor.GraphEditorUtility.activeElements.Clear();
                        NodeCanvas.Editor.GraphEditorUtility.activeElement = wrapper;
                    }
                    if (e.type == EventType.KeyDown && e.keyCode == KeyCode.I && GUIUtility.keyboardControl == 0)
                    {
                        List <Node> allNodes = currentGraph.GetAllNodesOfType <Node>();
                        if (allNodes != null && allNodes.Count < 2)
                        {
                            return;
                        }

                        if (NodeCanvas.Editor.GraphEditorUtility.activeElement != null)
                        {
                            if (allNodes.Contains((Node)NodeCanvas.Editor.GraphEditorUtility.activeElement))
                            {
                                allNodes.Remove((Node)NodeCanvas.Editor.GraphEditorUtility.activeElement);
                                NodeCanvas.Editor.GraphEditorUtility.activeElement = null;
                                NodeCanvas.Editor.GraphEditorUtility.activeElements.Clear();
                                NodeCanvas.Editor.GraphEditorUtility.activeElements = allNodes.Cast <object>().ToList();
                            }
                            return;
                        }

                        if (NodeCanvas.Editor.GraphEditorUtility.activeElements != null && NodeCanvas.Editor.GraphEditorUtility.activeElements.Count > 1)
                        {
                            List <object> invertNodeList = NodeCanvas.Editor.GraphEditorUtility.activeElements;
                            invertNodeList.ForEach(x =>
                            {
                                if (allNodes.Contains((Node)x))
                                {
                                    allNodes.Remove((Node)x);
                                }
                            });
                            NodeCanvas.Editor.GraphEditorUtility.activeElements.Clear();
                            if (allNodes.Count == 0)
                            {
                                NodeCanvas.Editor.GraphEditorUtility.activeElement = null;
                            }
                            else if (allNodes.Count == 1)
                            {
                                NodeCanvas.Editor.GraphEditorUtility.activeElement = allNodes[0];
                            }
                            else
                            {
                                NodeCanvas.Editor.GraphEditorUtility.activeElements = allNodes.Cast <object>().ToList();
                            }

                            return;
                        }
                        e.Use();
                    }
                    if (e.type == EventType.KeyUp && e.alt && e.control)
                    {
                        //Type genericType;

                        UnityEditor.GenericMenu.MenuFunction2 S = (obj) =>
                        {
                            NodeCanvas.Editor.GraphEditorUtility.activeElement = GraphEditor.currentGraph.AddNode(obj.GetType(),
                                                                                                                  ViewToCanvas(e.mousePosition));
                        };

                        UnityEditor.GenericMenu.MenuFunction2 D = (obj) =>
                        {
                            var genericT = typeof(SimplexNodeWrapper <>).MakeGenericType(obj.GetType());
                            NodeCanvas.Editor.GraphEditorUtility.activeElement = GraphEditor.currentGraph.AddNode(genericT, ViewToCanvas(e.mousePosition));
                        };


                        if (e.keyCode == KeyCode.S)
                        {
                            var menu = new UnityEditor.GenericMenu();

                            menu.AddItem(new GUIContent("Split"), false, S, new Split());
                            menu.AddItem(new GUIContent("Sequence"), false, S, new Sequence());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("SetActive"), false, D, new S_Active());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("SendEvent"), false, D, new SendEvent());
                            menu.AddItem(new GUIContent("SendEvent<T>"), false, D, new SendEvent <object>());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("Self"), false, S, new OwnerVariable());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("SwitchByIndex"), false, S, new Switch <object>());
                            menu.AddItem(new GUIContent("Switch Value"), false, D, new SwitchValue <object>());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("SwitchFlow/Switch Bool"), false, S, new SwitchBool());
                            menu.AddItem(new GUIContent("SwitchFlow/Switch String"), false, S, new SwitchString());
                            menu.AddItem(new GUIContent("SwitchFlow/Switch Int"), false, S, new SwitchInt());
                            menu.AddItem(new GUIContent("SwitchFlow/Switch Enum"), false, S, new SwitchEnum());
                            menu.AddItem(new GUIContent("SwitchFlow/Switch Tag"), false, S, new SwitchTag());
                            menu.AddItem(new GUIContent("SwitchFlow/Switch Comparison"), false, S, new SwitchComparison());

                            menu.ShowAsContext();
                            //e.Use();
                            return;
                        }

                        if (e.keyCode == KeyCode.A)
                        {
                            var menu = new UnityEditor.GenericMenu();

                            menu.AddItem(new GUIContent("Awake"), false, S, new ConstructionEvent());
                            menu.AddItem(new GUIContent("OnEnable"), false, S, new EnableEvent());
                            menu.AddItem(new GUIContent("Start"), false, S, new StartEvent());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("Update"), false, S, new UpdateEvent());
                            menu.AddItem(new GUIContent("FixedUpdate"), false, S, new FixedUpdateEvent());
                            menu.AddItem(new GUIContent("LateUpdate"), false, S, new LateUpdateEvent());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("OnDisable"), false, S, new DisableEvent());
                            menu.ShowAsContext();
                            return;
                        }
                        if (e.keyCode == KeyCode.C)
                        {
                            var menu = new UnityEditor.GenericMenu();
                            menu.AddItem(new GUIContent("Cache"), false, D, new Cache <object>());

                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("Coroutine"), false, S, new CoroutineState());
                            menu.AddItem(new GUIContent("Cooldown"), false, S, new Cooldown());
                            menu.AddItem(new GUIContent("Chance"), false, S, new Chance());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("CustomEvent"), false, S, new CustomEvent());
                            menu.AddItem(new GUIContent("CustomEvent<T>"), false, S, new CustomEvent <object>());

                            menu.ShowAsContext();
                            return;
                        }

                        if (e.keyCode == KeyCode.E)
                        {
                            var menu = new UnityEditor.GenericMenu();
                            menu.AddItem(new GUIContent("KeyBoard"), false, S, new KeyboardEvents());
                            menu.AddItem(new GUIContent("UnityEventAutoCallbackEvent"), false, S, new UnityEventAutoCallbackEvent());
                            menu.AddItem(new GUIContent("CSharpAutoCallbackEvent"), false, S, new CSharpAutoCallbackEvent());
                            menu.AddItem(new GUIContent("DelegateCallbackEvent"), false, S, new DelegateCallbackEvent());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("UnityEventCallbackEvent"), false, S, new UnityEventCallbackEvent());
                            menu.AddItem(new GUIContent("CSharpEventCallback"), false, S, new CSharpEventCallback());
                            menu.ShowAsContext();
                            return;
                        }
                        if (e.keyCode == KeyCode.D)
                        {
                            var menu = new UnityEditor.GenericMenu();

                            menu.AddItem(new GUIContent("Debug log OnScreen"), false, S, new G_LogOnScreen());
                            menu.AddItem(new GUIContent("Debug log"), false, D, new LogText());
                            menu.AddItem(new GUIContent("Debug Event"), false, D, new DebugEvent());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("DummyFlow"), false, S, new Dummy());
                            menu.AddItem(new GUIContent("DummyValue"), false, D, new Identity <object>());

                            menu.AddItem(new GUIContent("DoOnce"), false, S, new DoOnce());
                            menu.ShowAsContext();
                            e.Use();
                        }

                        if (e.keyCode == KeyCode.R)
                        {
                            var menu = new UnityEditor.GenericMenu();

                            menu.AddItem(new GUIContent("RelayFlowInput"), false, S, new RelayFlowInput());
                            menu.AddItem(new GUIContent("RelayFlowOutput"), false, S, new RelayFlowOutput());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("RelayValueInput"), false, S, new RelayValueInput <object>());
                            menu.AddItem(new GUIContent("RelayValueOutput"), false, S, new RelayValueOutput <object>());

                            menu.ShowAsContext();
                            e.Use();
                        }

                        if (e.keyCode == KeyCode.W)
                        {
                            var menu = new UnityEditor.GenericMenu();

                            menu.AddItem(new GUIContent("Wait"), false, D, new Wait());
                            menu.AddItem(new GUIContent("While"), false, S, new While());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("WaitForOneFrame"), false, D, new WaitForOneFrame());
                            menu.AddItem(new GUIContent("WaitForEndOfFrame"), false, D, new FlowCanvas.Nodes.WaitForEndOfFrame());
                            menu.AddItem(new GUIContent("WaitForFixedUpdate"), false, D, new WaitForFixedUpdate());
                            menu.AddItem(new GUIContent("WaitForPhysicsFrame"), false, D, new WaitForPhysicsFrame());
                            menu.ShowAsContext();
                            e.Use();
                        }

                        if (e.keyCode == KeyCode.F)
                        {
                            Selection.activeGameObject = null;  //防止快捷键冲突
                            var menu = new UnityEditor.GenericMenu();
                            menu.AddItem(new GUIContent("Find"), false, D, new G_FindGameObject());
                            menu.AddItem(new GUIContent("FindChild"), false, D, new G_FindChild());
                            menu.AddItem(new GUIContent("FindGameObjectWithTag"), false, D, new G_FindGameObjectWithTag());
                            menu.AddItem(new GUIContent("FindGameObjectsWithTag"), false, D, new G_FindGameObjectsWithTag());
                            menu.AddItem(new GUIContent("FindObjectOfType"), false, D, new FindObjectOfType());
                            menu.AddItem(new GUIContent("FindObjectsOfType"), false, D, new FindObjectsOfType());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("Finish"), false, S, new Finish());
                            menu.AddItem(new GUIContent("CustomFunction"), false, S, new CustomFunctionEvent());
                            menu.AddItem(new GUIContent("CallCustomFunction"), false, S, new CustomFunctionCall());
                            menu.AddItem(new GUIContent("CallCustomFunction(CustomPort)"), false, S, new FunctionCall());
                            menu.AddItem(new GUIContent("FunctionCustomReturn"), false, S, new Return());

                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("ForLoop"), false, S, new ForLoop());
                            menu.AddItem(new GUIContent("ForEach"), false, S, new ForEach <float>());
                            menu.AddItem(new GUIContent("FlipFlop"), false, S, new FlipFlop());

                            menu.ShowAsContext();
                            e.Use();
                        }

                        if (e.keyCode == KeyCode.G)
                        {
                            var menu = new UnityEditor.GenericMenu();
                            menu.AddItem(new GUIContent("GetName"), false, D, new G_Name());
                            menu.AddItem(new GUIContent("GetAcive"), false, D, new G_Active());
                            menu.AddItem(new GUIContent("GetPosition"), false, D, new G_Position());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("GetChildByIndex"), false, D, new G_Child());
                            menu.AddItem(new GUIContent("GetChildCount"), false, D, new G_ChildCount());
                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("GetComponentByType"), false, D, new G_Component());
                            menu.AddItem(new GUIContent("GetComponentsByType"), false, D, new G_Components());
                            menu.AddItem(new GUIContent("GetComponentByName"), false, D, new G_ComponentByTypeName());
                            menu.AddItem(new GUIContent("GetComponentsInChildren"), false, D, new G_ComponentsInChildren());
                            menu.AddItem(new GUIContent("GetComponentInChildren"), false, D, new G_ComponentInChildren());
                            menu.AddItem(new GUIContent("GetComponentInParent"), false, D, new G_ComponentInParent());

                            menu.ShowAsContext();
                            e.Use();
                        }
                    }

                    if (e.type == EventType.KeyUp && e.alt)
                    {
                        Type genericType;

                        switch (e.keyCode)
                        {
                        case KeyCode.Alpha1:
                            genericType = typeof(GetVariable <>).MakeGenericType(typeof(float));
                            break;

                        case KeyCode.Alpha2:
                            genericType = typeof(GetVariable <>).MakeGenericType(typeof(Vector2));
                            break;

                        case KeyCode.Alpha3:
                            genericType = typeof(GetVariable <>).MakeGenericType(typeof(Vector3));
                            break;

                        case KeyCode.Alpha4:
                            genericType = typeof(GetVariable <>).MakeGenericType(typeof(Quaternion));
                            break;

                        case KeyCode.Alpha5:
                            genericType = typeof(GetVariable <>).MakeGenericType(typeof(Color));
                            break;

                        default:
                            //genericType = typeof(GetVariable<>).MakeGenericType(typeof(float));
                            return;
                            //break;
                        }

                        var varN = (FlowNode)GraphEditor.currentGraph.AddNode(genericType);
                        varN.position = ViewToCanvas(e.mousePosition - varN.rect.center * 0.5f);

                        NodeCanvas.Editor.GraphEditorUtility.activeElement = varN;

                        e.Use();
                    }
                }
                if (e.type == EventType.KeyDown && e.keyCode == KeyCode.F && GUIUtility.keyboardControl == 0)
                {
                    FocusSelection();
                }

                #endregion


                //'Tilt' or 'Space' keys, opens up the complete context menu browser
                if (e.type == EventType.KeyDown && !e.shift && (e.keyCode == KeyCode.BackQuote || e.keyCode == KeyCode.Space))
                {
                    GenericMenuBrowser.Show(GetAddNodeMenu(graph, canvasMousePos), e.mousePosition, string.Format("Add {0} Node", graph.GetType().FriendlyName()), graph.baseNodeType);
                    e.Use();
                }

                //Right click canvas context menu. Basicaly for adding new nodes.
                if (e.type == EventType.ContextClick)
                {
                    var menu = GetAddNodeMenu(graph, canvasMousePos);
                    if (CopyBuffer.Has <Node[]>() && CopyBuffer.Peek <Node[]>()[0].GetType().IsSubclassOf(graph.baseNodeType))
                    {
                        menu.AddSeparator("/");
                        var copiedNodes = CopyBuffer.Get <Node[]>();
                        if (copiedNodes.Length == 1)
                        {
                            menu.AddItem(new GUIContent(string.Format("Paste Node ({0})", copiedNodes[0].GetType().FriendlyName())), false, () => { TryPasteNodesInGraph(graph, copiedNodes, canvasMousePos); });
                        }
                        else if (copiedNodes.Length > 1)
                        {
                            menu.AddItem(new GUIContent(string.Format("Paste Nodes ({0})", copiedNodes.Length.ToString())), false, () => { TryPasteNodesInGraph(graph, copiedNodes, canvasMousePos); });
                        }
                    }

                    if (NCPrefs.useBrowser)
                    {
                        menu.ShowAsBrowser(e.mousePosition, string.Format("Add {0} Node", graph.GetType().FriendlyName()), graph.baseNodeType);
                    }
                    else
                    {
                        menu.ShowAsContext();
                    }
                    e.Use();
                }
            }
        }
예제 #24
0
        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 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"));
            }
        }
예제 #26
0
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                PresetLibraryEditor <T> .SettingsMenu.s_Owner = owner;
                GenericMenu genericMenu = new GenericMenu();
                int         num         = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.x;
                int         num2        = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.y;
                List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData> list;

                if (num == num2)
                {
                    list = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Grid"),
                            itemHeight = num
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("List"),
                            itemHeight = num,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    };
                }
                else
                {
                    list = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Small Grid"),
                            itemHeight = num
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Large Grid"),
                            itemHeight = num2
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Small List"),
                            itemHeight = num,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Large List"),
                            itemHeight = num2,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    };
                }
                for (int i = 0; i < list.Count; i++)
                {
                    bool on = PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode == list[i].viewmode && (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight == list[i].itemHeight;
                    genericMenu.AddItem(list[i].text, on, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.ViewModeChange), list[i]);
                }
                genericMenu.AddSeparator(string.Empty);
                List <string> list2;
                List <string> list3;

                ScriptableSingleton <PresetLibraryManager> .instance.GetAvailableLibraries <T>(PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper, out list2, out list3);

                list2.Sort();
                list3.Sort();
                string a   = PresetLibraryEditor <T> .SettingsMenu.s_Owner.currentLibraryWithoutExtension + "." + PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;
                string str = " (Project)";

                foreach (string current in list2)
                {
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current);
                    genericMenu.AddItem(new GUIContent(fileNameWithoutExtension), a == current, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), current);
                }
                foreach (string current2 in list3)
                {
                    string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(current2);
                    genericMenu.AddItem(new GUIContent(fileNameWithoutExtension2 + str), a == current2, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), current2);
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Create New Library..."), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.CreateLibrary), 0);
                if (PresetLibraryEditor <T> .SettingsMenu.HasDefaultPresets())
                {
                    genericMenu.AddSeparator(string.Empty);
                    genericMenu.AddItem(new GUIContent("Add Factory Presets To Current Library"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.AddDefaultPresetsToCurrentLibrary), 0);
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Reveal Current Library Location"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.RevealCurrentLibrary), 0);
                genericMenu.DropDown(activatorRect);
            }
예제 #27
0
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                PresetLibraryEditor <T> .SettingsMenu.s_Owner = owner;
                GenericMenu genericMenu = new GenericMenu();
                int         x           = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.x;
                int         y           = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.y;
                List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData> viewModeDataList;

                if (x == y)
                {
                    viewModeDataList = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>()
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Grid"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("List"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    }
                }
                ;
                else
                {
                    viewModeDataList = new List <PresetLibraryEditor <T> .SettingsMenu.ViewModeData>()
                    {
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Small Grid"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Large Grid"),
                            itemHeight = y,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Small List"),
                            itemHeight = x,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData()
                        {
                            text       = new GUIContent("Large List"),
                            itemHeight = y,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.List
                        }
                    }
                };
                for (int index = 0; index < viewModeDataList.Count; ++index)
                {
                    bool on = PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode == viewModeDataList[index].viewmode && (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight == viewModeDataList[index].itemHeight;
                    genericMenu.AddItem(viewModeDataList[index].text, on, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.ViewModeChange), (object)viewModeDataList[index]);
                }
                genericMenu.AddSeparator(string.Empty);
                List <string> preferencesLibs;
                List <string> projectLibs;

                ScriptableSingleton <PresetLibraryManager> .instance.GetAvailableLibraries <T>(PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper, out preferencesLibs, out projectLibs);

                preferencesLibs.Sort();
                projectLibs.Sort();
                string str1 = PresetLibraryEditor <T> .SettingsMenu.s_Owner.currentLibraryWithoutExtension + "." + PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;
                string str2 = " (Project)";

                using (List <string> .Enumerator enumerator = preferencesLibs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current          = enumerator.Current;
                        string withoutExtension = Path.GetFileNameWithoutExtension(current);
                        genericMenu.AddItem(new GUIContent(withoutExtension), str1 == current, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), (object)current);
                    }
                }
                using (List <string> .Enumerator enumerator = projectLibs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current          = enumerator.Current;
                        string withoutExtension = Path.GetFileNameWithoutExtension(current);
                        genericMenu.AddItem(new GUIContent(withoutExtension + str2), str1 == current, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), (object)current);
                    }
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Create New Library..."), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.CreateLibrary), (object)0);
                if (PresetLibraryEditor <T> .SettingsMenu.HasDefaultPresets())
                {
                    genericMenu.AddSeparator(string.Empty);
                    genericMenu.AddItem(new GUIContent("Add Factory Presets To Current Library"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.AddDefaultPresetsToCurrentLibrary), (object)0);
                }
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Reveal Current Library Location"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.RevealCurrentLibrary), (object)0);
                genericMenu.DropDown(activatorRect);
            }
        void ShowEditorButtonGUI()
        {
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                if (m_ParticleEffectUI != null)
                {
                    m_ParticleEffectUI.m_SubEmitterSelected = false;
                }

                if (m_ParticleEffectUI == null || !m_ParticleEffectUI.multiEdit)
                {
                    bool       alreadySelected  = selectedInParticleSystemWindow;
                    GameObject targetGameObject = (target as ParticleSystem).gameObject;

                    // Show a button to select the sub-emitter owner, if this system is a sub-emitter
                    List <ParticleSystem> owners = new List <ParticleSystem>();
                    var parent = targetGameObject.transform.parent;
                    while (parent != null)
                    {
                        var ps = parent.GetComponent <ParticleSystem>();
                        if (ps != null)
                        {
                            var subEmitters = ps.subEmitters;
                            if (subEmitters.enabled)
                            {
                                for (int i = 0; i < subEmitters.subEmittersCount; i++)
                                {
                                    var subEmitter = subEmitters.GetSubEmitterSystem(i);
                                    if (subEmitter != null && subEmitter.gameObject == targetGameObject)
                                    {
                                        owners.Add(ps);
                                        break;
                                    }
                                }
                            }
                        }

                        parent = parent.parent;
                    }
                    if (owners.Count > 0)
                    {
                        if (m_ParticleEffectUI != null)
                        {
                            m_ParticleEffectUI.m_SubEmitterSelected = true;
                        }

                        if (owners.Count == 1)
                        {
                            if (GUILayout.Button(GUIContent.Temp(selectSubEmitterOwner.text, owners[0].name), EditorStyles.miniButton, GUILayout.Width(160)))
                            {
                                Selection.activeGameObject = owners[0].gameObject;
                            }
                        }
                        else
                        {
                            if (EditorGUILayout.DropdownButton(selectSubEmitterOwner, FocusType.Passive, EditorStyles.miniButton, GUILayout.Width(160)))
                            {
                                GenericMenu menu = new GenericMenu();

                                foreach (var owner in owners)
                                {
                                    menu.AddItem(new GUIContent(owner.name), false, OnOwnerSelected, owner);
                                }
                                menu.AddSeparator("");
                                menu.AddItem(new GUIContent("Select All"), false, OnOwnersSelected, owners);

                                Rect buttonRect = GUILayoutUtility.topLevel.GetLast();
                                menu.DropDown(buttonRect);
                            }
                        }
                    }

                    // When editing a preset the GameObject will have the NotEditable flag.
                    // We do not support the ParticleSystemWindow for Presets for two reasons:
                    // - When selected the Preset editor creates a temporary GameObject which it then uses to edit the properties.
                    // The ParticleSystemWindow also uses the Selection system which triggers a selection change, the Preset
                    // editor cleans up the temp object and the ParticleSystemWindow is now unable to edit the system.
                    // - A preset will only contain a single system, so there is no benefit to using the window. (case 1198545)
                    if ((targetGameObject.hideFlags & HideFlags.NotEditable) != 0)
                    {
                        return;
                    }

                    GUIContent           text   = null;
                    ParticleSystemWindow window = ParticleSystemWindow.GetInstance();
                    if (window)
                    {
                        window.customEditor = this; // window can be created by LoadWindowLayout, when Editor starts up, so always make sure the custom editor member is set up (case 930005)
                    }
                    if (window && window.IsVisible() && alreadySelected)
                    {
                        if (window.GetNumTabs() > 1)
                        {
                            text = hideWindowText;
                        }
                        else
                        {
                            text = closeWindowText;
                        }
                    }
                    else
                    {
                        text = showWindowText;
                    }

                    if (GUILayout.Button(text, EditorStyles.miniButton, GUILayout.Width(110)))
                    {
                        if (window && window.IsVisible() && alreadySelected)
                        {
                            // Hide window (close instead if not possible)
                            if (!window.ShowNextTabIfPossible())
                            {
                                window.Close();
                            }
                        }
                        else
                        {
                            if (!alreadySelected)
                            {
                                ParticleSystemEditorUtils.lockedParticleSystem = null;
                                Selection.activeGameObject = targetGameObject;
                            }

                            if (window)
                            {
                                if (!alreadySelected)
                                {
                                    window.Clear();
                                }

                                // Show window
                                window.Focus();
                            }
                            else
                            {
                                // Kill inspector gui first to ensure playback time is cached properly
                                Clear();

                                // Create new window
                                ParticleSystemWindow.CreateWindow();
                                window = ParticleSystemWindow.GetInstance();
                                window.customEditor = this;
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                }
            }
        }
예제 #29
0
        // private

        static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : Object, new()
        {
            GenericMenu gm = new GenericMenu();

            int selectedInstanceID = serializedProperty.objectReferenceValue != null?serializedProperty.objectReferenceValue.GetInstanceID() : 0;


            bool foundDefaultAsset = false;
            var  type    = UnityEditor.UnityType.FindTypeByName(typeName);
            int  classID = type != null ? type.persistentTypeID : 0;

            BuiltinResource[] resourceList = null;

            // Check the assets for one that matches the default name.
            if (classID > 0)
            {
                resourceList = EditorGUIUtility.GetBuiltinResourceList(classID);
                foreach (var resource in resourceList)
                {
                    if (resource.m_Name == defaultFieldName)
                    {
                        gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                        resourceList      = resourceList.Where(x => x != resource).ToArray();
                        foundDefaultAsset = true;
                        break;
                    }
                }
            }

            // If no defalut asset was found, add defualt null value.
            if (!foundDefaultAsset)
            {
                gm.AddItem(new GUIContent(defaultFieldName), selectedInstanceID == 0, AssetPopupMenuCallback, new object[] { 0, serializedProperty });
            }

            // Add items from asset database
            var property     = new HierarchyProperty(HierarchyType.Assets);
            var searchFilter = new SearchFilter()
            {
                classNames = new[] { typeName }
            };

            property.SetSearchFilter(searchFilter);
            property.Reset();
            while (property.Next(null))
            {
                gm.AddItem(new GUIContent(property.name), property.instanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { property.instanceID, serializedProperty });
            }

            // Add builtin items, except for the already added default item.
            if (classID > 0 && resourceList != null)
            {
                foreach (var resource in resourceList)
                {
                    gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                }
            }

            // Create item
            gm.AddSeparator("");
            gm.AddItem(EditorGUIUtility.TrTextContent("Create New..."), false, delegate
            {
                var newAsset = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(newAsset, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = newAsset;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });

            gm.DropDown(buttonRect);
        }
        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);
            }
        }
예제 #31
0
        private static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension) where T : Object, new()
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AssetPopupBackend.\u003CShowAssetsPopupMenu\u003Ec__AnonStorey76 <T> menuCAnonStorey76 = new AssetPopupBackend.\u003CShowAssetsPopupMenu\u003Ec__AnonStorey76 <T>();
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.typeName = typeName;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.fileExtension = fileExtension;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.serializedProperty = serializedProperty;
            GenericMenu genericMenu = new GenericMenu();
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            int num = !(menuCAnonStorey76.serializedProperty.objectReferenceValue != (Object)null) ? 0 : menuCAnonStorey76.serializedProperty.objectReferenceValue.GetInstanceID();

            // ISSUE: reference to a compiler-generated field
            genericMenu.AddItem(new GUIContent("Default"), (num == 0 ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
            {
                (object)0,
                (object)menuCAnonStorey76.serializedProperty
            });
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            // ISSUE: reference to a compiler-generated field
            SearchFilter filter = new SearchFilter()
            {
                classNames = new string[1] {
                    menuCAnonStorey76.typeName
                }
            };

            hierarchyProperty.SetSearchFilter(filter);
            hierarchyProperty.Reset();
            while (hierarchyProperty.Next((int[])null))
            {
                // ISSUE: reference to a compiler-generated field
                genericMenu.AddItem(new GUIContent(hierarchyProperty.name), (hierarchyProperty.instanceID == num ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
                {
                    (object)hierarchyProperty.instanceID,
                    (object)menuCAnonStorey76.serializedProperty
                });
            }
            // ISSUE: reference to a compiler-generated field
            int classId = BaseObjectTools.StringToClassID(menuCAnonStorey76.typeName);

            if (classId > 0)
            {
                foreach (BuiltinResource builtinResource in EditorGUIUtility.GetBuiltinResourceList(classId))
                {
                    // ISSUE: reference to a compiler-generated field
                    genericMenu.AddItem(new GUIContent(builtinResource.m_Name), (builtinResource.m_InstanceID == num ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
                    {
                        (object)builtinResource.m_InstanceID,
                        (object)menuCAnonStorey76.serializedProperty
                    });
                }
            }
            genericMenu.AddSeparator(string.Empty);
            // ISSUE: reference to a compiler-generated method
            genericMenu.AddItem(new GUIContent("Create New..."), false, new GenericMenu.MenuFunction(menuCAnonStorey76.\u003C\u003Em__10A));
            genericMenu.DropDown(buttonRect);
        }
예제 #32
0
        public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
        {
            EditorGUI.BeginChangeCheck();
            float  fieldWidth = EditorGUIUtility.fieldWidth;
            string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
            bool   flag = controller.ContainsExposedParameter(path.parameter);

            EditorGUIUtility.fieldWidth       = 70f;
            EditorGUI.kFloatFieldFormatString = "F2";
            EditorGUI.s_UnitString            = unit;
            GUIContent label2 = label;

            if (flag)
            {
                label2 = GUIContent.Temp(label.text + " ➔", label.tooltip);
            }
            float num = value * displayScale;

            num = EditorGUILayout.PowerSlider(label2, num, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
            EditorGUI.s_UnitString            = null;
            EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
            EditorGUIUtility.fieldWidth       = fieldWidth;
            if (Event.current.type == EventType.ContextClick)
            {
                if (GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    GenericMenu genericMenu = new GenericMenu();
                    if (!flag)
                    {
                        GenericMenu arg_11E_0 = genericMenu;
                        GUIContent  arg_11E_1 = new GUIContent("Expose '" + path.ResolveStringPath(false) + "' to script");
                        bool        arg_11E_2 = false;
                        if (AudioMixerEffectGUI.< > f__mg$cache0 == null)
                        {
                            AudioMixerEffectGUI.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ExposePopupCallback);
                        }
                        arg_11E_0.AddItem(arg_11E_1, arg_11E_2, AudioMixerEffectGUI.< > f__mg$cache0, new AudioMixerEffectGUI.ExposedParamContext(controller, path));
                    }
                    else
                    {
                        GenericMenu arg_15B_0 = genericMenu;
                        GUIContent  arg_15B_1 = new GUIContent("Unexpose");
                        bool        arg_15B_2 = false;
                        if (AudioMixerEffectGUI.< > f__mg$cache1 == null)
                        {
                            AudioMixerEffectGUI.< > f__mg$cache1 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.UnexposePopupCallback);
                        }
                        arg_15B_0.AddItem(arg_15B_1, arg_15B_2, AudioMixerEffectGUI.< > f__mg$cache1, new AudioMixerEffectGUI.ExposedParamContext(controller, path));
                    }
                    ParameterTransitionType parameterTransitionType;
                    bool transitionTypeOverride = controller.TargetSnapshot.GetTransitionTypeOverride(path.parameter, out parameterTransitionType);
                    genericMenu.AddSeparator(string.Empty);
                    GenericMenu arg_1C0_0 = genericMenu;
                    GUIContent  arg_1C0_1 = new GUIContent("Linear Snapshot Transition");
                    bool        arg_1C0_2 = parameterTransitionType == ParameterTransitionType.Lerp;
                    if (AudioMixerEffectGUI.< > f__mg$cache2 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache2 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_1C0_0.AddItem(arg_1C0_1, arg_1C0_2, AudioMixerEffectGUI.< > f__mg$cache2, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Lerp));
                    GenericMenu arg_202_0 = genericMenu;
                    GUIContent  arg_202_1 = new GUIContent("Smoothstep Snapshot Transition");
                    bool        arg_202_2 = parameterTransitionType == ParameterTransitionType.Smoothstep;
                    if (AudioMixerEffectGUI.< > f__mg$cache3 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache3 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_202_0.AddItem(arg_202_1, arg_202_2, AudioMixerEffectGUI.< > f__mg$cache3, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Smoothstep));
                    GenericMenu arg_244_0 = genericMenu;
                    GUIContent  arg_244_1 = new GUIContent("Squared Snapshot Transition");
                    bool        arg_244_2 = parameterTransitionType == ParameterTransitionType.Squared;
                    if (AudioMixerEffectGUI.< > f__mg$cache4 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache4 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_244_0.AddItem(arg_244_1, arg_244_2, AudioMixerEffectGUI.< > f__mg$cache4, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Squared));
                    GenericMenu arg_286_0 = genericMenu;
                    GUIContent  arg_286_1 = new GUIContent("SquareRoot Snapshot Transition");
                    bool        arg_286_2 = parameterTransitionType == ParameterTransitionType.SquareRoot;
                    if (AudioMixerEffectGUI.< > f__mg$cache5 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache5 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_286_0.AddItem(arg_286_1, arg_286_2, AudioMixerEffectGUI.< > f__mg$cache5, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.SquareRoot));
                    GenericMenu arg_2C8_0 = genericMenu;
                    GUIContent  arg_2C8_1 = new GUIContent("BrickwallStart Snapshot Transition");
                    bool        arg_2C8_2 = parameterTransitionType == ParameterTransitionType.BrickwallStart;
                    if (AudioMixerEffectGUI.< > f__mg$cache6 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache6 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_2C8_0.AddItem(arg_2C8_1, arg_2C8_2, AudioMixerEffectGUI.< > f__mg$cache6, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallStart));
                    GenericMenu arg_30A_0 = genericMenu;
                    GUIContent  arg_30A_1 = new GUIContent("BrickwallEnd Snapshot Transition");
                    bool        arg_30A_2 = parameterTransitionType == ParameterTransitionType.BrickwallEnd;
                    if (AudioMixerEffectGUI.< > f__mg$cache7 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache7 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_30A_0.AddItem(arg_30A_1, arg_30A_2, AudioMixerEffectGUI.< > f__mg$cache7, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallEnd));
                    genericMenu.AddSeparator(string.Empty);
                    genericMenu.ShowAsContext();
                }
            }
            bool result;

            if (EditorGUI.EndChangeCheck())
            {
                value  = num / displayScale;
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
        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);
        }
예제 #34
0
        private static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : UnityEngine.Object, new()
        {
            GenericMenu genericMenu = new GenericMenu();
            int         num         = (!(serializedProperty.objectReferenceValue != null)) ? 0 : serializedProperty.objectReferenceValue.GetInstanceID();
            bool        flag        = false;
            int         num2        = BaseObjectTools.StringToClassID(typeName);

            BuiltinResource[] array = null;
            if (num2 > 0)
            {
                array = EditorGUIUtility.GetBuiltinResourceList(num2);
                BuiltinResource[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    BuiltinResource resource = array2[i];
                    if (resource.m_Name == defaultFieldName)
                    {
                        GenericMenu arg_10E_0 = genericMenu;
                        GUIContent  arg_10E_1 = new GUIContent(resource.m_Name);
                        bool        arg_10E_2 = resource.m_InstanceID == num;
                        if (AssetPopupBackend.< > f__mg$cache0 == null)
                        {
                            AssetPopupBackend.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                        }
                        arg_10E_0.AddItem(arg_10E_1, arg_10E_2, AssetPopupBackend.< > f__mg$cache0, new object[]
                        {
                            resource.m_InstanceID,
                            serializedProperty
                        });
                        array = (from x in array
                                 where x != resource
                                 select x).ToArray <BuiltinResource>();
                        flag = true;
                        break;
                    }
                }
            }
            if (!flag)
            {
                GenericMenu arg_190_0 = genericMenu;
                GUIContent  arg_190_1 = new GUIContent(defaultFieldName);
                bool        arg_190_2 = num == 0;
                if (AssetPopupBackend.< > f__mg$cache1 == null)
                {
                    AssetPopupBackend.< > f__mg$cache1 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                }
                arg_190_0.AddItem(arg_190_1, arg_190_2, AssetPopupBackend.< > f__mg$cache1, new object[]
                {
                    0,
                    serializedProperty
                });
            }
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            SearchFilter      searchFilter      = new SearchFilter
            {
                classNames = new string[]
                {
                    typeName
                }
            };

            hierarchyProperty.SetSearchFilter(searchFilter);
            hierarchyProperty.Reset();
            while (hierarchyProperty.Next(null))
            {
                GenericMenu arg_227_0 = genericMenu;
                GUIContent  arg_227_1 = new GUIContent(hierarchyProperty.name);
                bool        arg_227_2 = hierarchyProperty.instanceID == num;
                if (AssetPopupBackend.< > f__mg$cache2 == null)
                {
                    AssetPopupBackend.< > f__mg$cache2 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                }
                arg_227_0.AddItem(arg_227_1, arg_227_2, AssetPopupBackend.< > f__mg$cache2, new object[]
                {
                    hierarchyProperty.instanceID,
                    serializedProperty
                });
            }
            if (num2 > 0 && array != null)
            {
                BuiltinResource[] array3 = array;
                for (int j = 0; j < array3.Length; j++)
                {
                    BuiltinResource builtinResource = array3[j];
                    GenericMenu     arg_2B1_0       = genericMenu;
                    GUIContent      arg_2B1_1       = new GUIContent(builtinResource.m_Name);
                    bool            arg_2B1_2       = builtinResource.m_InstanceID == num;
                    if (AssetPopupBackend.< > f__mg$cache3 == null)
                    {
                        AssetPopupBackend.< > f__mg$cache3 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                    }
                    arg_2B1_0.AddItem(arg_2B1_1, arg_2B1_2, AssetPopupBackend.< > f__mg$cache3, new object[]
                    {
                        builtinResource.m_InstanceID,
                        serializedProperty
                    });
                }
            }
            genericMenu.AddSeparator("");
            genericMenu.AddItem(new GUIContent("Create New..."), false, delegate
            {
                T t = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(t, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = t;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });
            genericMenu.DropDown(buttonRect);
        }
예제 #35
0
        private static void ShowEffectContextMenu(AudioMixerGroupController group, AudioMixerEffectController effect, int effectIndex, AudioMixerController controller, Rect buttonRect)
        {
            GenericMenu genericMenu = new GenericMenu();

            if (!effect.IsReceive())
            {
                if (!effect.IsAttenuation() && !effect.IsSend() && !effect.IsDuckVolume())
                {
                    genericMenu.AddItem(new GUIContent("Allow Wet Mixing (causes higher memory usage)"), effect.enableWetMix, delegate
                    {
                        effect.enableWetMix = !effect.enableWetMix;
                    });
                    genericMenu.AddItem(new GUIContent("Bypass"), effect.bypass, delegate
                    {
                        effect.bypass = !effect.bypass;
                        controller.UpdateBypass();
                        AudioMixerUtility.RepaintAudioMixerAndInspectors();
                    });
                    genericMenu.AddSeparator(string.Empty);
                }
                genericMenu.AddItem(new GUIContent("Copy effect settings to all snapshots"), false, delegate
                {
                    Undo.RecordObject(controller, "Copy effect settings to all snapshots");
                    if (effect.IsAttenuation())
                    {
                        controller.CopyAttenuationToAllSnapshots(group, controller.TargetSnapshot);
                    }
                    else
                    {
                        controller.CopyEffectSettingsToAllSnapshots(group, effectIndex, controller.TargetSnapshot, effect.IsSend());
                    }
                    AudioMixerUtility.RepaintAudioMixerAndInspectors();
                });
                if (!effect.IsAttenuation() && !effect.IsSend() && !effect.IsDuckVolume() && effect.enableWetMix)
                {
                    genericMenu.AddItem(new GUIContent("Copy effect settings to all snapshots, including wet level"), false, delegate
                    {
                        Undo.RecordObject(controller, "Copy effect settings to all snapshots, including wet level");
                        controller.CopyEffectSettingsToAllSnapshots(group, effectIndex, controller.TargetSnapshot, true);
                        AudioMixerUtility.RepaintAudioMixerAndInspectors();
                    });
                }
                genericMenu.AddSeparator(string.Empty);
            }
            AudioMixerGroupController[] groups = new AudioMixerGroupController[]
            {
                group
            };
            AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groups, effectIndex, "Add effect before/", genericMenu);
            AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groups, effectIndex + 1, "Add effect after/", genericMenu);
            if (!effect.IsAttenuation())
            {
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Remove this effect"), false, delegate
                {
                    controller.ClearSendConnectionsTo(effect);
                    controller.RemoveEffect(effect, group);
                    AudioMixerUtility.RepaintAudioMixerAndInspectors();
                });
            }
            genericMenu.DropDown(buttonRect);
        }
예제 #36
0
        /// <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();
        }
예제 #37
0
        protected void DrawToolbarGUI()
        {
            EditorGUILayout.BeginHorizontal("Toolbar");
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);

            if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                var menu = new GenericMenu();

                foreach (System.Collections.Generic.KeyValuePair <Type, NodeCanvasTypeData> data in NodeCanvasManager.CanvasTypes)
                {
                    menu.AddItem(new GUIContent("New Canvas/" + data.Value.DisplayString), false, newCanvasTypeCallback, data.Value);
                }

                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Load Canvas", "Loads an Specified Empty CanvasType"), false, LoadCanvas);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                menu.AddSeparator("");

                // Load from canvas
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
                }

                // Save Canvas to Scene
                menu.AddItem(new GUIContent("Save Canvas to Scene"), false, () =>
                {
                    showModalPanel = true;
                    Debug.Log(showModalPanel);
                });

                menu.ShowAsContext();
            }

            if (GUILayout.Button("Debug", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                var menu = new GenericMenu();

                // Toggles side panel
                menu.AddItem(new GUIContent("Sidebar"), showSideWindow, () => { showSideWindow = !showSideWindow; });

                menu.ShowAsContext();
            }

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            GUILayout.Label(new GUIContent("" + canvasCache.nodeCanvas.saveName + " (" + (canvasCache.nodeCanvas.livesInScene? "Scene Save" : "Asset Save") + ")", "Opened Canvas path: " + canvasCache.nodeCanvas.savePath), "ToolbarButton");
            GUILayout.Label("Type: " + canvasCache.typeData.DisplayString + "/" + canvasCache.nodeCanvas.GetType().Name + "", "ToolbarButton");

            GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);

            if (GUILayout.Button("Force Re-init", EditorStyles.toolbarButton, GUILayout.Width(80)))
            {
                NodeEditor.ReInit(true);
            }

            EditorGUILayout.EndHorizontal();
            GUI.backgroundColor = Color.white;
        }
		private void DrawContextTestMenu (TestResult test)
		{
			if (EditorApplication.isPlayingOrWillChangePlaymode) return;

			var m = new GenericMenu ();
			var localTest = test;
			if(selectedTests.Count > 1)
				m.AddItem(guiRunSelected,
						false,
						data => RunTest(selectedTests.Select (t=>t.TestComponent).ToList ()),
						"");
			m.AddItem (guiRun,
						false,
						data => RunTest(new List<TestComponent> { localTest.TestComponent}),
						"");
			m.AddItem (guiRunAll,
						false,
						data => RunTest (GetVisibleNotIgnoredTests ()),
						"");
			m.AddItem (guiRunAllIncludingIgnored,
						false,
						data => RunTest (GetVisibleTestsIncludingIgnored ()),
						"");
			m.AddSeparator ("");
			m.AddItem (guiDelete,
						false,
						data => RemoveTest (localTest),
						"");

			m.ShowAsContext ();
		}
예제 #39
0
        static Object DoObjectField(Rect position, Rect dropRect, int id, Object obj, Object objBeingEdited, System.Type objType, System.Type additionalType, SerializedProperty property, ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style, GUIStyle buttonStyle, Action <Object> onObjectSelectorClosed = null, Action <Object> onObjectSelectedUpdated = null)
        {
            if (validator == null)
            {
                validator = ValidateObjectFieldAssignment;
            }
            if (property != null)
            {
                obj = property.objectReferenceValue;
            }
            Event     evt       = Event.current;
            EventType eventType = evt.type;

            // special case test, so we continue to ping/select objects with the object field disabled
            if (!GUI.enabled && GUIClip.enabled && (Event.current.rawType == EventType.MouseDown))
            {
                eventType = Event.current.rawType;
            }

            bool hasThumbnail = EditorGUIUtility.HasObjectThumbnail(objType);

            // Determine visual type
            ObjectFieldVisualType visualType = ObjectFieldVisualType.IconAndText;

            if (hasThumbnail && position.height <= kObjectFieldMiniThumbnailHeight && position.width <= kObjectFieldMiniThumbnailWidth)
            {
                visualType = ObjectFieldVisualType.MiniPreview;
            }
            else if (hasThumbnail && position.height > kSingleLineHeight)
            {
                visualType = ObjectFieldVisualType.LargePreview;
            }

            Vector2 oldIconSize = EditorGUIUtility.GetIconSize();

            if (visualType == ObjectFieldVisualType.IconAndText)
            {
                EditorGUIUtility.SetIconSize(new Vector2(12, 12));  // Have to be this small to fit inside a single line height ObjectField
            }
            else if (visualType == ObjectFieldVisualType.LargePreview)
            {
                EditorGUIUtility.SetIconSize(new Vector2(64, 64));
            }

            if ((eventType == EventType.MouseDown && Event.current.button == 1 ||
                 (eventType == EventType.ContextClick && visualType == ObjectFieldVisualType.IconAndText)) &&
                position.Contains(Event.current.mousePosition))
            {
                var actualObject = property != null ? property.objectReferenceValue : obj;
                var contextMenu  = new GenericMenu();

                if (FillPropertyContextMenu(property, null, contextMenu) != null)
                {
                    contextMenu.AddSeparator("");
                }
                contextMenu.AddItem(GUIContent.Temp("Properties..."), false, () => PropertyEditor.OpenPropertyEditor(actualObject));
                contextMenu.DropDown(position);
                Event.current.Use();
            }

            switch (eventType)
            {
            case EventType.DragExited:
                if (GUI.enabled)
                {
                    HandleUtility.Repaint();
                }

                break;

            case EventType.DragUpdated:
            case EventType.DragPerform:

                if (eventType == EventType.DragPerform)
                {
                    string errorString;
                    if (!ValidDroppedObject(DragAndDrop.objectReferences, objType, out errorString))
                    {
                        Object reference = DragAndDrop.objectReferences[0];
                        EditorUtility.DisplayDialog("Can't assign script", errorString, "OK");
                        break;
                    }
                }

                if (dropRect.Contains(Event.current.mousePosition) && GUI.enabled)
                {
                    Object[] references      = DragAndDrop.objectReferences;
                    Object   validatedObject = validator(references, objType, property, ObjectFieldValidatorOptions.None);

                    if (validatedObject != null)
                    {
                        // If scene objects are not allowed and object is a scene object then clear
                        if (!allowSceneObjects && !EditorUtility.IsPersistent(validatedObject))
                        {
                            validatedObject = null;
                        }
                    }

                    if (validatedObject != null)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                        if (eventType == EventType.DragPerform)
                        {
                            if (property != null)
                            {
                                property.objectReferenceValue = validatedObject;
                            }
                            else
                            {
                                obj = validatedObject;
                            }

                            GUI.changed = true;
                            DragAndDrop.AcceptDrag();
                            DragAndDrop.activeControlID = 0;
                        }
                        else
                        {
                            DragAndDrop.activeControlID = id;
                        }
                        Event.current.Use();
                    }
                }
                break;

            case EventType.MouseDown:
                if (position.Contains(Event.current.mousePosition) && Event.current.button == 0)
                {
                    // Get button rect for Object Selector
                    Rect buttonRect = GetButtonRect(visualType, position);

                    EditorGUIUtility.editingTextField = false;

                    if (buttonRect.Contains(Event.current.mousePosition))
                    {
                        if (GUI.enabled)
                        {
                            GUIUtility.keyboardControl = id;
                            var types = additionalType == null ? new Type[] { objType } : new Type[] { objType, additionalType };
                            if (property != null)
                            {
                                ObjectSelector.get.Show(types, property, allowSceneObjects, onObjectSelectorClosed: onObjectSelectorClosed, onObjectSelectedUpdated: onObjectSelectedUpdated);
                            }
                            else
                            {
                                ObjectSelector.get.Show(obj, types, objBeingEdited, allowSceneObjects, onObjectSelectorClosed: onObjectSelectorClosed, onObjectSelectedUpdated: onObjectSelectedUpdated);
                            }
                            ObjectSelector.get.objectSelectorID = id;

                            evt.Use();
                            GUIUtility.ExitGUI();
                        }
                    }
                    else
                    {
                        Object    actualTargetObject = property != null ? property.objectReferenceValue : obj;
                        Component com = actualTargetObject as Component;
                        if (com)
                        {
                            actualTargetObject = com.gameObject;
                        }
                        if (showMixedValue)
                        {
                            actualTargetObject = null;
                        }

                        // One click shows where the referenced object is, or pops up a preview
                        if (Event.current.clickCount == 1)
                        {
                            GUIUtility.keyboardControl = id;

                            PingObjectOrShowPreviewOnClick(actualTargetObject, position);
                            var selectedMaterial = actualTargetObject as Material;
                            if (selectedMaterial != null)
                            {
                                PingObjectInSceneViewOnClick(selectedMaterial);
                            }
                            evt.Use();
                        }
                        // Double click opens the asset in external app or changes selection to referenced object
                        else if (Event.current.clickCount == 2)
                        {
                            if (actualTargetObject)
                            {
                                AssetDatabase.OpenAsset(actualTargetObject);
                                evt.Use();
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                }
                break;

            case EventType.ExecuteCommand:
                string commandName = evt.commandName;
                if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id && (property == null || !property.isScript))
                {
                    return(AssignSelectedObject(property, validator, objType, evt));
                }
                else if (commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id && property != null && property.isScript)
                {
                    if (ObjectSelector.get.GetInstanceID() == 0)
                    {
                        // User canceled object selection; don't apply
                        evt.Use();
                        break;
                    }
                    return(AssignSelectedObject(property, validator, objType, evt));
                }
                else if ((evt.commandName == EventCommandNames.Delete || evt.commandName == EventCommandNames.SoftDelete) && GUIUtility.keyboardControl == id)
                {
                    if (property != null)
                    {
                        property.objectReferenceValue = null;
                    }
                    else
                    {
                        obj = null;
                    }

                    GUI.changed = true;
                    evt.Use();
                }
                break;

            case EventType.ValidateCommand:
                if ((evt.commandName == EventCommandNames.Delete || evt.commandName == EventCommandNames.SoftDelete) && GUIUtility.keyboardControl == id)
                {
                    evt.Use();
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.keyboardControl == id)
                {
                    if (evt.keyCode == KeyCode.Backspace || (evt.keyCode == KeyCode.Delete && (evt.modifiers & EventModifiers.Shift) == 0))
                    {
                        if (property != null)
                        {
                            if (property.propertyPath.EndsWith("]"))
                            {
                                var  parentArrayPropertyPath = property.propertyPath.Substring(0, property.propertyPath.LastIndexOf(".Array.data[", StringComparison.Ordinal));
                                var  parentArrayProperty     = property.serializedObject.FindProperty(parentArrayPropertyPath);
                                bool isReorderableList       = PropertyHandler.s_reorderableLists.ContainsKey(ReorderableListWrapper.GetPropertyIdentifier(parentArrayProperty));

                                // If it's an element of an non-orderable array and it is displayed inside a list, remove that element from the array (cases 1379541 & 1335322)
                                if (!isReorderableList && GUI.isInsideList && GetInsideListDepth() == parentArrayProperty.depth)
                                {
                                    TargetChoiceHandler.DeleteArrayElement(property);
                                }
                                else
                                {
                                    property.objectReferenceValue = null;
                                }
                            }
                            else
                            {
                                property.objectReferenceValue = null;
                            }
                        }
                        else
                        {
                            obj = null;
                        }

                        GUI.changed = true;
                        evt.Use();
                    }

                    // Apparently we have to check for the character being space instead of the keyCode,
                    // otherwise the Inspector will maximize upon pressing space.
                    if (evt.MainActionKeyForControl(id))
                    {
                        var types = additionalType == null ? new Type[] { objType } : new Type[] { objType, additionalType };
                        if (property != null)
                        {
                            ObjectSelector.get.Show(types, property, allowSceneObjects);
                        }
                        else
                        {
                            ObjectSelector.get.Show(obj, types, objBeingEdited, allowSceneObjects);
                        }
                        ObjectSelector.get.objectSelectorID = id;
                        evt.Use();
                        GUIUtility.ExitGUI();
                    }
                }
                break;

            case EventType.Repaint:
                GUIContent temp;
                if (showMixedValue)
                {
                    temp = s_MixedValueContent;
                }
                else
                {
                    // If obj or objType are both null, we have to rely on
                    // property.objectReferenceStringValue to display None/Missing and the
                    // correct type. But if not, EditorGUIUtility.ObjectContent is more reliable.
                    // It can take a more specific object type specified as argument into account,
                    // and it gets the icon at the same time.
                    if (obj == null && objType == null && property != null)
                    {
                        temp = EditorGUIUtility.TempContent(property.objectReferenceStringValue);
                    }
                    else
                    {
                        // In order for ObjectContext to be able to distinguish between None/Missing,
                        // we need to supply an instanceID. For some reason, getting the instanceID
                        // from property.objectReferenceValue is not reliable, so we have to
                        // explicitly check property.objectReferenceInstanceIDValue if a property exists.
                        if (property != null)
                        {
                            temp = EditorGUIUtility.ObjectContent(obj, objType, property.objectReferenceInstanceIDValue);
                        }
                        else
                        {
                            temp = EditorGUIUtility.ObjectContent(obj, objType);
                        }
                    }

                    if (property != null)
                    {
                        if (obj != null)
                        {
                            Object[] references = { obj };
                            if (EditorSceneManager.preventCrossSceneReferences && CheckForCrossSceneReferencing(obj, property.serializedObject.targetObject))
                            {
                                if (!EditorApplication.isPlaying)
                                {
                                    temp = s_SceneMismatch;
                                }
                                else
                                {
                                    temp.text = temp.text + string.Format(" ({0})", GetGameObjectFromObject(obj).scene.name);
                                }
                            }
                            else if (validator(references, objType, property, ObjectFieldValidatorOptions.ExactObjectTypeValidation) == null)
                            {
                                temp = s_TypeMismatch;
                            }
                        }
                    }
                }

                switch (visualType)
                {
                case ObjectFieldVisualType.IconAndText:
                    BeginHandleMixedValueContentColor();
                    style.Draw(position, temp, id, DragAndDrop.activeControlID == id, position.Contains(Event.current.mousePosition));

                    Rect buttonRect = buttonStyle.margin.Remove(GetButtonRect(visualType, position));
                    buttonStyle.Draw(buttonRect, GUIContent.none, id, DragAndDrop.activeControlID == id, buttonRect.Contains(Event.current.mousePosition));
                    EndHandleMixedValueContentColor();
                    break;

                case ObjectFieldVisualType.LargePreview:
                    DrawObjectFieldLargeThumb(position, id, obj, temp);
                    break;

                case ObjectFieldVisualType.MiniPreview:
                    DrawObjectFieldMiniThumb(position, id, obj, temp);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }

            EditorGUIUtility.SetIconSize(oldIconSize);

            return(obj);
        }
예제 #40
0
        /// <summary> 
        /// Displays a context menu to add variables to a blackboard.
        /// <param name="blackboard">The target blackboard to add a new variable.</param> 
        /// </summary>
        public static void OnAddContextMenu (InternalBlackboard blackboard) {
            GUIUtility.hotControl = 0;
            GUIUtility.keyboardControl = 0;

            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("Float"), false, delegate () {BlackboardUtility.AddFloatVar(blackboard);});
            menu.AddItem(new GUIContent("Int"), false, delegate () {BlackboardUtility.AddIntVar(blackboard);});
            menu.AddItem(new GUIContent("Bool"), false, delegate () {BlackboardUtility.AddBoolVar(blackboard);});
            menu.AddItem(new GUIContent("String"), false, delegate () {BlackboardUtility.AddStringVar(blackboard);});
            menu.AddItem(new GUIContent("Vector3"), false, delegate () {BlackboardUtility.AddVector3Var(blackboard);});
            menu.AddItem(new GUIContent("Rect"), false, delegate () {BlackboardUtility.AddRectVar(blackboard);});
            menu.AddItem(new GUIContent("Color"), false, delegate () {BlackboardUtility.AddColorVar(blackboard);});
            menu.AddItem(new GUIContent("Quaternion"), false, delegate () {BlackboardUtility.AddQuaternionVar(blackboard);});
            menu.AddItem(new GUIContent("GameObject"), false, delegate () {BlackboardUtility.AddGameObjectVar(blackboard);});
            menu.AddItem(new GUIContent("Texture"), false, delegate () {BlackboardUtility.AddTextureVar(blackboard);});
            menu.AddItem(new GUIContent("Material"), false, delegate () {BlackboardUtility.AddMaterialVar(blackboard);});
            menu.AddItem(new GUIContent("Object"), false, delegate () {BlackboardUtility.AddObjectVar(blackboard);});
            menu.AddItem(new GUIContent("DynamicList"), false, delegate () {BlackboardUtility.AddDynamicList(blackboard);});
            menu.AddItem(new GUIContent("FsmEvent"), false, delegate () {BlackboardUtility.AddFsmEvent(blackboard);});
            
            if (!(blackboard is InternalGlobalBlackboard)) {
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Global Blackboard"), false, delegate () {EditorApplication.ExecuteMenuItem("Tools/BehaviourMachine/Global Blackboard");});
            }

            menu.ShowAsContext();
        }
        private static void DisplayDropDown(Rect position, List<Type> types, Type selectedType, ClassGrouping grouping)
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("(None)"), selectedType == null, s_OnSelectedTypeName, null);
            menu.AddSeparator("");

            for (int i = 0; i < types.Count; ++i) {
                var type = types[i];

                string menuLabel = FormatGroupedTypeName(type, grouping);
                if (string.IsNullOrEmpty(menuLabel))
                    continue;

                var content = new GUIContent(menuLabel);
                menu.AddItem(content, type == selectedType, s_OnSelectedTypeName, type);
            }

            menu.DropDown(position);
        }
예제 #42
0
        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();
        }
예제 #43
0
	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();
		}
	}
		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();
				}
			}
		}
예제 #45
0
        private void VertexEditing(UnityEngine.Object unused, SceneView sceneView)
        {
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(300f) };
            GUILayout.BeginVertical(options);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label("Visualization: ", optionArray2);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            if (EditorGUILayout.ButtonMouseDown(this.GetModeString(this.drawMode), FocusType.Passive, EditorStyles.toolbarDropDown, new GUILayoutOption[0]))
            {
                Rect last = GUILayoutUtility.topLevel.GetLast();
                GenericMenu menu = new GenericMenu();
                menu.AddItem(this.GetModeString(DrawMode.MaxDistance), this.drawMode == DrawMode.MaxDistance, new GenericMenu.MenuFunction(this.VisualizationMenuSetMaxDistanceMode));
                menu.AddItem(this.GetModeString(DrawMode.CollisionSphereDistance), this.drawMode == DrawMode.CollisionSphereDistance, new GenericMenu.MenuFunction(this.VisualizationMenuSetCollisionSphereMode));
                menu.AddSeparator(string.Empty);
                menu.AddItem(new GUIContent("Manipulate Backfaces"), this.state.ManipulateBackfaces, new GenericMenu.MenuFunction(this.VisualizationMenuToggleManipulateBackfaces));
                menu.DropDown(last);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label(this.m_MinVisualizedValue[(int) this.drawMode].ToString(), optionArray3);
            this.DrawColorBox(s_ColorTexture, Color.clear);
            GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label(this.m_MaxVisualizedValue[(int) this.drawMode].ToString(), optionArray4);
            GUILayout.Label("Unconstrained:", new GUILayoutOption[0]);
            GUILayout.Space(-24f);
            GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.Width(20f) };
            GUILayout.BeginHorizontal(optionArray5);
            this.DrawColorBox(null, Color.black);
            GUILayout.EndHorizontal();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginVertical("Box", new GUILayoutOption[0]);
            if (Tools.current != Tool.None)
            {
                this.state.ToolMode = ~ToolMode.Select;
            }
            ToolMode toolMode = this.state.ToolMode;
            this.state.ToolMode = (ToolMode) GUILayout.Toolbar((int) this.state.ToolMode, s_ToolIcons, new GUILayoutOption[0]);
            if (this.state.ToolMode != toolMode)
            {
                GUIUtility.keyboardControl = 0;
                SceneView.RepaintAll();
                this.SetupSelectionMeshColors();
                this.SetupSelectedMeshColors();
            }
            switch (this.state.ToolMode)
            {
                case ToolMode.Select:
                    Tools.current = Tool.None;
                    this.SelectionGUI();
                    break;

                case ToolMode.Paint:
                    Tools.current = Tool.None;
                    this.PaintGUI();
                    break;
            }
            GUILayout.EndVertical();
            if (!this.IsConstrained())
            {
                EditorGUILayout.HelpBox("No constraints have been set up, so the cloth will move freely. Set up vertex constraints here to restrict it.", MessageType.Info);
            }
            GUILayout.EndVertical();
            GUILayout.Space(-4f);
        }
예제 #46
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Sort groups alphabetically"), this.m_SortGroupsAlphabetically, delegate
     {
         this.m_SortGroupsAlphabetically = !this.m_SortGroupsAlphabetically;
     });
     menu.AddItem(new GUIContent("Show referenced groups"), this.m_ShowReferencedBuses, delegate
     {
         this.m_ShowReferencedBuses = !this.m_ShowReferencedBuses;
     });
     menu.AddItem(new GUIContent("Show group connections"), this.m_ShowBusConnections, delegate
     {
         this.m_ShowBusConnections = !this.m_ShowBusConnections;
     });
     if (this.m_ShowBusConnections)
     {
         menu.AddItem(new GUIContent("Only highlight selected group connections"), this.m_ShowBusConnectionsOfSelection, delegate
         {
             this.m_ShowBusConnectionsOfSelection = !this.m_ShowBusConnectionsOfSelection;
         });
     }
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Vertical layout"), this.layoutMode == AudioMixerWindow.LayoutMode.Vertical, delegate
     {
         this.layoutMode = AudioMixerWindow.LayoutMode.Vertical;
     });
     menu.AddItem(new GUIContent("Horizontal layout"), this.layoutMode == AudioMixerWindow.LayoutMode.Horizontal, delegate
     {
         this.layoutMode = AudioMixerWindow.LayoutMode.Horizontal;
     });
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Use RMS metering for display"), EditorPrefs.GetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true), delegate
     {
         EditorPrefs.SetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true);
     });
     menu.AddItem(new GUIContent("Use peak metering for display"), !EditorPrefs.GetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true), delegate
     {
         EditorPrefs.SetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, false);
     });
     if (Unsupported.IsDeveloperBuild())
     {
         menu.AddSeparator("");
         menu.AddItem(new GUIContent("DEVELOPER/Groups Rendered Above"), this.m_GroupsRenderedAboveSections, delegate
         {
             this.m_GroupsRenderedAboveSections = !this.m_GroupsRenderedAboveSections;
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 10 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 10);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 20 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 20);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 40 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 40);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 80 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 80);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 160 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 160);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 10 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 10);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 20 groups "), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 20);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 40 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 40);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 80 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 80);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Show overlays"), this.m_ShowDeveloperOverlays, delegate
         {
             this.m_ShowDeveloperOverlays = !this.m_ShowDeveloperOverlays;
         });
     }
 }
		void SpawnHierarchyContextMenu () {
			GenericMenu menu = new GenericMenu();

			menu.AddItem(new GUIContent("Follow"), false, SpawnFollowHierarchy);
			menu.AddItem(new GUIContent("Follow (Root Only)"), false, SpawnFollowHierarchyRootOnly);
			menu.AddSeparator("");
			menu.AddItem(new GUIContent("Override"), false, SpawnOverrideHierarchy);
			menu.AddItem(new GUIContent("Override (Root Only)"), false, SpawnOverrideHierarchyRootOnly);

			menu.ShowAsContext();
		}
예제 #48
0
		private void ShowGraphAreaPopMenu()
		{
			if (currGraph == null) return;

			GenericMenu menu = new GenericMenu();

			menu.AddItem(new GUIContent("Add Dialogue Node"), false, OnGraphPopMenu, new object[] { 1, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add GiveQuest Node"), false, OnGraphPopMenu, new object[] { 4, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add UpdateCondition Node"), false, OnGraphPopMenu, new object[] { 10, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add GiveReward Node"), false, OnGraphPopMenu, new object[] { 8, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add UniRPGEvent Node"), false, OnGraphPopMenu, new object[] { 11, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add QuestCheck Node"), false, OnGraphPopMenu, new object[] { 12, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add Decision Node"), false, OnGraphPopMenu, new object[] { 2, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add RandomPath Node"), false, OnGraphPopMenu, new object[] { 9, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add SetVariable Node"), false, OnGraphPopMenu, new object[] { 7, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add SendMessage Node"), false, OnGraphPopMenu, new object[] { 6, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add DebugLog Node"), false, OnGraphPopMenu, new object[] { 5, Event.current.mousePosition });
			menu.AddItem(new GUIContent("Add End Node"), false, OnGraphPopMenu, new object[] { 3, Event.current.mousePosition });
			menu.AddSeparator("");
			menu.AddItem(new GUIContent("Reset view"), false, OnGraphPopMenu, new object[] { 200 });
			if (currNode!=null) menu.AddItem(new GUIContent("Clear selected"), false, OnGraphPopMenu, new object[] { 201 });
			menu.AddSeparator("");
			menu.AddItem(new GUIContent("Delete Graph"), false, OnGraphPopMenu, new object[] { 300 });

			menu.ShowAsContext();
		}
        private void Initialize()
        {
            baseFilter = s => false;
            guiFilter = s => true;

            columnSelection = new MultiColumnState.Column(new GUIContent("[]"), data => new GUIContent(masterSelection.Contains(data) ? " ☑" : " ☐"));
            columnAssetPath = new MultiColumnState.Column(new GUIContent("AssetPath"), data => new GUIContent(data.assetPath.Compose()));
            columnOwner = new MultiColumnState.Column(new GUIContent("Owner"), data => new GUIContent(data.owner, data.lockToken));
            columnFileStatus = new MultiColumnState.Column(new GUIContent("Status"), GetFileStatusContent);
            columnMetaStatus = new MultiColumnState.Column(new GUIContent("Meta"), data => GetFileStatusContent(data.MetaStatus()));
            columnFileType = new MultiColumnState.Column(new GUIContent("Type"), data => new GUIContent(GetFileType(data.assetPath.Compose())));
            columnConflict = new MultiColumnState.Column(new GUIContent("Conflict"), data => new GUIContent(data.treeConflictStatus.ToString()));
            columnChangelist = new MultiColumnState.Column(new GUIContent("ChangeList"), data => new GUIContent(data.changelist.Compose()));

            var guiSkin = EditorGUIUtility.GetBuiltinSkin( EditorGUIUtility.isProSkin ? EditorSkin.Scene : EditorSkin.Inspector);
            multiColumnState = new MultiColumnState();

            multiColumnState.Comparer = (r1, r2, c) =>
            {
                var r1Text = c.GetContent(r1.data).text;
                var r2Text = c.GetContent(r2.data).text;
                if (r1Text == null) r1Text = "";
                if (r2Text == null) r2Text = "";
                //D.Log("Comparing: " + r1Text + " with " + r2Text + " : " + r1Text.CompareTo(r2Text));
                return String.CompareOrdinal(r1Text, r2Text);
            };

            Func<GenericMenu> rowRightClickMenu = () =>
            {
                var selected = multiColumnState.GetSelected().Select(status => status.assetPath.Compose());
                if (!selected.Any()) return new GenericMenu();
                GenericMenu menu = new GenericMenu();
                if (selected.Count() == 1) VCGUIControls.CreateVCContextMenu(ref menu, selected.First());
                else VCGUIControls.CreateVCContextMenu(ref menu, selected);
                var selectedObjs = selected.Select(a => AssetDatabase.LoadMainAssetAtPath(a)).ToArray();
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Show in Project"), false, () =>
                {
                    Selection.objects = selectedObjs;
                    EditorGUIUtility.PingObject(Selection.activeObject);
                });
                menu.AddItem(new GUIContent("Show on Harddisk"), false, () =>
                {
                    Selection.objects = selectedObjs;
                    EditorApplication.ExecuteMenuItem((Application.platform == RuntimePlatform.OSXEditor ? "Assets/Reveal in Finder" : "Assets/Show in Explorer"));
                });
                return menu;
            };

            Func<MultiColumnState.Column, GenericMenu> headerRightClickMenu = column =>
            {
                var menu = new GenericMenu();
                //menu.AddItem(new GUIContent("Remove"), false, () => { ToggleColumn(column); });
                return menu;
            };

            // Return value of true steals the click from normal selection, false does not.
            Func<MultiColumnState.Row, MultiColumnState.Column, bool> cellClickAction = (row, column) =>
            {
                GUI.FocusControl("");
                if (column == columnSelection)
                {
                    var currentSelection = multiColumnState.GetSelected();
                    if (currentSelection.Contains(row.data))
                    {
                        bool currentRowSelection = masterSelection.Contains(row.data);
                        foreach (var selectionIt in currentSelection)
                        {
                            if (currentRowSelection)
                                masterSelection.Remove(selectionIt);
                            else
                                masterSelection.Add(selectionIt);
                        }
                    }
                    else
                    {
                        if (masterSelection.Contains(row.data))
                            masterSelection.Remove(row.data);
                        else
                            masterSelection.Add(row.data);
                    }
                    return true;
                }
                return false;
                //D.Log(row.data.assetPath.Compose() + " : "  + column.GetContent(row.data).text);
            };

            options = new MultiColumnViewOption
            {
                headerStyle = new GUIStyle(guiSkin.button),
                rowStyle = new GUIStyle(guiSkin.label),
                rowRightClickMenu = rowRightClickMenu,
                headerRightClickMenu = headerRightClickMenu,
                cellClickAction = cellClickAction,
                widths = new float[] { 200 },
                doubleClickAction = status =>
                {
                    if (VCUtility.IsDiffableAsset(status.assetPath) && VCUtility.ManagedByRepository(status) && status.fileStatus == VCFileStatus.Modified)
                        VCUtility.DiffWithBase(status.assetPath.Compose());
                    else
                        AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(status.assetPath.Compose()));
                }
            };

            options.headerStyle.fixedHeight = 20.0f;
            options.rowStyle.onNormal.background = IconUtils.CreateSquareTexture(4, 1, new Color(0.24f, 0.5f, 0.87f, 0.75f));
            options.rowStyle.margin = new RectOffset(2, 2, 2, 1);
            options.rowStyle.border = new RectOffset(0, 0, 0, 0);
            options.rowStyle.padding = new RectOffset(0, 0, 0, 0);

            if (showMasterSelection)
            {
                multiColumnState.AddColumn(columnSelection);
                options.widthTable.Add(columnSelection.GetHeader().text, 25);
            }

            multiColumnState.AddColumn(columnAssetPath);
            options.widthTable.Add(columnAssetPath.GetHeader().text, 500);

            multiColumnState.AddColumn(columnFileStatus);
            options.widthTable.Add(columnFileStatus.GetHeader().text, 90);

            multiColumnState.AddColumn(columnMetaStatus);
            options.widthTable.Add(columnMetaStatus.GetHeader().text, 100);

            multiColumnState.AddColumn(columnFileType);
            options.widthTable.Add(columnFileType.GetHeader().text, 80);

            multiColumnState.AddColumn(columnOwner);
            options.widthTable.Add(columnOwner.GetHeader().text, 60);

            multiColumnState.AddColumn(columnChangelist);
            options.widthTable.Add(columnChangelist.GetHeader().text, 120);

            //columnConflictState.AddColumn(columnConflict);
            options.widthTable.Add(columnConflict.GetHeader().text, 80);
        }
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                List <ViewModeData <T> > list;
                List <string>            list2;
                List <string>            list3;
                List <ViewModeData <T> > list4;
                ViewModeData <T>         data;

                PresetLibraryEditor <T> .SettingsMenu.s_Owner = owner;
                GenericMenu menu = new GenericMenu();
                int         x    = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.x;
                int         y    = (int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.minMaxPreviewHeight.y;

                if (x == y)
                {
                    list4 = new List <ViewModeData <T> >();
                    data  = new ViewModeData <T> {
                        text       = new GUIContent("Grid"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("List"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.List
                    };
                    list4.Add(data);
                    list = list4;
                }
                else
                {
                    list4 = new List <ViewModeData <T> >();
                    data  = new ViewModeData <T> {
                        text       = new GUIContent("Small Grid"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("Large Grid"),
                        itemHeight = y,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("Small List"),
                        itemHeight = x,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.List
                    };
                    list4.Add(data);
                    data = new ViewModeData <T> {
                        text       = new GUIContent("Large List"),
                        itemHeight = y,
                        viewmode   = PresetLibraryEditorState.ItemViewMode.List
                    };
                    list4.Add(data);
                    list = list4;
                }
                for (int i = 0; i < list.Count; i++)
                {
                    bool on = (PresetLibraryEditor <T> .SettingsMenu.s_Owner.itemViewMode == list[i].viewmode) && (((int)PresetLibraryEditor <T> .SettingsMenu.s_Owner.previewHeight) == list[i].itemHeight);
                    menu.AddItem(list[i].text, on, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.ViewModeChange), list[i]);
                }
                menu.AddSeparator(string.Empty);
                ScriptableSingleton <PresetLibraryManager> .instance.GetAvailableLibraries <T>(PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper, out list2, out list3);

                list2.Sort();
                list3.Sort();
                string str  = PresetLibraryEditor <T> .SettingsMenu.s_Owner.currentLibraryWithoutExtension + "." + PresetLibraryEditor <T> .SettingsMenu.s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;
                string str2 = " (Project)";

                foreach (string str3 in list2)
                {
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(str3);
                    menu.AddItem(new GUIContent(fileNameWithoutExtension), str == str3, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), str3);
                }
                foreach (string str5 in list3)
                {
                    string str6 = Path.GetFileNameWithoutExtension(str5);
                    menu.AddItem(new GUIContent(str6 + str2), str == str5, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.LibraryModeChange), str5);
                }
                menu.AddSeparator(string.Empty);
                menu.AddItem(new GUIContent("Create New Library..."), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.CreateLibrary), 0);
                if (PresetLibraryEditor <T> .SettingsMenu.HasDefaultPresets())
                {
                    menu.AddSeparator(string.Empty);
                    menu.AddItem(new GUIContent("Add Factory Presets To Current Library"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.AddDefaultPresetsToCurrentLibrary), 0);
                }
                menu.AddSeparator(string.Empty);
                menu.AddItem(new GUIContent("Reveal Current Library Location"), false, new GenericMenu.MenuFunction2(PresetLibraryEditor <T> .SettingsMenu.RevealCurrentLibrary), 0);
                menu.DropDown(activatorRect);
            }
예제 #51
0
		/// <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);
			}
		}
예제 #52
0
        public static void HandleBindingDragAndDrop(TrackAsset dropTarget, Type requiredBindingType)
        {
            var objectBeingDragged = DragAndDrop.objectReferences[0];

            var action = BindingUtility.GetBindingAction(requiredBindingType, objectBeingDragged);

            DragAndDrop.visualMode = action == BindingAction.DoNotBind
                ? DragAndDropVisualMode.Rejected
                : DragAndDropVisualMode.Link;

            if (action == BindingAction.DoNotBind || Event.current.type != EventType.DragPerform)
            {
                return;
            }

            var director = TimelineEditor.inspectedDirector;

            switch (action)
            {
            case BindingAction.BindDirectly:
            {
                BindingUtility.Bind(director, dropTarget, objectBeingDragged);
                break;
            }

            case BindingAction.BindToExistingComponent:
            {
                var gameObjectBeingDragged = objectBeingDragged as GameObject;
                Debug.Assert(gameObjectBeingDragged != null, "The object being dragged was detected as being a GameObject");

                BindingUtility.Bind(director, dropTarget, gameObjectBeingDragged.GetComponent(requiredBindingType));
                break;
            }

            case BindingAction.BindToMissingComponent:
            {
                var gameObjectBeingDragged = objectBeingDragged as GameObject;
                Debug.Assert(gameObjectBeingDragged != null, "The object being dragged was detected as being a GameObject");

                var typeNameOfComponent = requiredBindingType.ToString().Split(".".ToCharArray()).Last();
                var bindMenu            = new GenericMenu();

                bindMenu.AddItem(
                    EditorGUIUtility.TextContent("Create " + typeNameOfComponent + " on " + gameObjectBeingDragged.name),
                    false,
                    nullParam => BindingUtility.Bind(director, dropTarget, Undo.AddComponent(gameObjectBeingDragged, requiredBindingType)),
                    null);

                bindMenu.AddSeparator("");
                bindMenu.AddItem(EditorGUIUtility.TrTextContent("Cancel"), false, userData => {}, null);
                bindMenu.ShowAsContext();

                break;
            }

            default:
            {
                //no-op
                return;
            }
            }

            DragAndDrop.AcceptDrag();
        }
예제 #53
0
        /// <summary>
        /// Provides input handling for the panel
        /// </summary>
        public override void ProcessInput()
        {
            Event     lCurrentEvent     = Event.current;
            EventType lCurrentEventType = lCurrentEvent.type;

            Node     lClickedNode = null;
            NodeLink lClickedLink = null;

            switch (lCurrentEventType)
            {
            // Handles keypresses
            case EventType.KeyUp:

                switch (lCurrentEvent.keyCode)
                {
                case KeyCode.Delete:

                    if (GUIUtility.keyboardControl == 0)
                    {
                        if (mSelectedNode != null)
                        {
                            RemoveNode(mSelectedNode);
                        }
                        if (mSelectedLink != null)
                        {
                            RemoveLink(mSelectedLink);
                        }

                        Editor.Repaint();
                    }

                    break;
                }

                break;

            // Handles the mouse down event
            case EventType.MouseDown:

                for (int i = 0; i < Nodes.Count; i++)
                {
                    if (Nodes[i].ContainsPoint(lCurrentEvent.mousePosition))
                    {
                        lClickedLink = null;
                        lClickedNode = Nodes[i];
                    }

                    if (lClickedNode == null)
                    {
                        for (int j = 0; j < Nodes[i].Links.Count; j++)
                        {
                            if (Nodes[i].Links[j].ContainsPoint(lCurrentEvent.mousePosition))
                            {
                                lClickedLink = Nodes[i].Links[j];
                                break;
                            }
                        }
                    }

                    if (lClickedNode != null || lClickedLink != null)
                    {
                        break;
                    }
                }

                mIsPanning = false;

                // With left mouse button, select
                if (lCurrentEvent.button == 0)
                {
                    if (mIsLinking && mActiveLink != null)
                    {
                        if (lClickedNode != null && lClickedNode != mActiveLink.StartNode)
                        {
                            mActiveLink.EndNode = lClickedNode;
                            AddLink(mActiveLink);
                        }

                        mActiveLink = null;
                        mActiveNode = null;

                        mSelectedNode = null;
                    }
                    else
                    {
                        if (lClickedNode != null)
                        {
                            GUIUtility.keyboardControl = 0;
                        }
                        if (lClickedNode != mSelectedNode && NodeSelectedEvent != null)
                        {
                            NodeSelectedEvent(lClickedNode);
                        }

                        if (lClickedLink != null)
                        {
                            GUIUtility.keyboardControl = 0;
                        }
                        if (lClickedLink != mSelectedLink && LinkSelectedEvent != null)
                        {
                            LinkSelectedEvent(lClickedLink);
                        }

                        mActiveNode   = lClickedNode;
                        mSelectedNode = lClickedNode;

                        mActiveLink   = lClickedLink;
                        mSelectedLink = lClickedLink;

                        if (lClickedNode != null)
                        {
                            mDragStart  = lCurrentEvent.mousePosition;
                            mDragOffset = Vector2.zero;
                        }
                    }

                    mIsLinking = false;

                    Editor.Repaint();
                }
                // With right mouse button, show the menu
                else if (lCurrentEvent.button == 1)
                {
                    mActiveNode = lClickedNode;
                    mActiveLink = lClickedLink;

                    if (mActiveNode != null)
                    {
                        GenericMenu lMenu = new UnityEditor.GenericMenu();
                        lMenu.AddItem(new GUIContent("Add Link"), false, OnStartAddLink, mActiveNode);
                        lMenu.AddSeparator("");
                        lMenu.AddItem(new GUIContent("Delete Node"), false, OnRemoveNode, mActiveNode);
                        lMenu.ShowAsContext();
                        lCurrentEvent.Use();
                    }
                    else if (mActiveLink != null)
                    {
                        GenericMenu lMenu = new UnityEditor.GenericMenu();
                        lMenu.AddItem(new GUIContent("Delete Link"), false, OnRemoveLink, mActiveLink);
                        lMenu.ShowAsContext();
                        lCurrentEvent.Use();
                    }
                    else
                    {
                        GenericMenu lMenu = new UnityEditor.GenericMenu();
                        lMenu.AddItem(new GUIContent("Add Node"), false, OnAddNode, typeof(Node));
                        lMenu.ShowAsContext();
                        lCurrentEvent.Use();
                    }
                }
                // With right mouse buttion, drag the canvas
                else if (lCurrentEvent.button == 2)
                {
                    mIsPanning  = true;
                    mDragStart  = lCurrentEvent.mousePosition;
                    mDragOffset = Vector2.zero;
                }

                break;

            // Handles the mouse drag event
            case EventType.MouseDrag:

                // Pan the canvas as needed
                if (mIsPanning)
                {
                    Vector2 lDragOffset = mDragOffset;
                    mDragOffset = lCurrentEvent.mousePosition - mDragStart;

                    Vector2 lOffset = (mDragOffset - lDragOffset) * mZoom;
                    mPanOffset = mPanOffset + lOffset;

                    Editor.Repaint();
                }
                // Move the active node as needed
                else if (mActiveNode != null)
                {
                    Vector2 lDragOffset = mDragOffset;
                    mDragOffset = lCurrentEvent.mousePosition - mDragStart;

                    Vector2 lOffset = (mDragOffset - lDragOffset) * mZoom;
                    mActiveNode.Position.x = mActiveNode.Position.x + lOffset.x;
                    mActiveNode.Position.y = mActiveNode.Position.y + lOffset.y;

                    Editor.Repaint();
                }

                break;

            // Handles the mouse up event
            case EventType.MouseUp:

                if (mActiveNode != null)
                {
                    if (mDragOffset.sqrMagnitude > 0f)
                    {
                        mDragOffset = Vector2.zero;

                        // Reorder the links left to right
                        for (int i = 0; i < Nodes.Count; i++)
                        {
                            bool lReorder = false;
                            for (int j = 0; j < Nodes[i].Links.Count; j++)
                            {
                                if (Nodes[i].Links[j].EndNode == mActiveNode)
                                {
                                    lReorder = true;
                                    break;
                                }
                            }

                            if (lReorder)
                            {
                                Nodes[i].Links = Nodes[i].Links.OrderBy(x => x.EndNode.Position.x).ToList <NodeLink>();
                            }
                        }

                        // Flag the canvas as dirty
                        EditorUtility.SetDirty(mActiveNode);
                        SetDirty();
                    }
                }

                // Ensure we don't pan or move a node
                mIsPanning  = false;
                mActiveNode = null;

                break;
            }
        }
예제 #54
0
        internal static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : Object, new()
        {
            GenericMenu gm = new GenericMenu();

            int selectedInstanceID = serializedProperty.objectReferenceValue != null?serializedProperty.objectReferenceValue.GetInstanceID() : 0;


            bool foundDefaultAsset = false;
            var  type    = UnityEditor.UnityType.FindTypeByName(typeName);
            int  classID = type != null ? type.persistentTypeID : 0;

            BuiltinResource[] resourceList = null;

            // Check the assets for one that matches the default name.
            if (classID > 0)
            {
                resourceList = EditorGUIUtility.GetBuiltinResourceList(classID);
                foreach (var resource in resourceList)
                {
                    if (resource.m_Name == defaultFieldName)
                    {
                        gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                        resourceList      = resourceList.Where(x => x != resource).ToArray();
                        foundDefaultAsset = true;
                        break;
                    }
                }
            }

            // If no defalut asset was found, add defualt null value.
            if (!foundDefaultAsset)
            {
                gm.AddItem(new GUIContent(defaultFieldName), selectedInstanceID == 0, AssetPopupMenuCallback, new object[] { 0, serializedProperty });
            }

            // Add items from asset database
            foreach (var property in AssetDatabase.FindAllAssets(new SearchFilter()
            {
                classNames = new[] { typeName }
            }))
            {
                gm.AddItem(new GUIContent(property.name), property.instanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { property.instanceID, serializedProperty });
            }

            // Add builtin items, except for the already added default item.
            if (classID > 0 && resourceList != null)
            {
                foreach (var resource in resourceList)
                {
                    gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                }
            }

            var  target   = serializedProperty.serializedObject.targetObject;
            bool isPreset = target is Component ? ((int)(target as Component).gameObject.hideFlags == 93) : !AssetDatabase.Contains(target);

            // the preset object is destroyed with the inspector, and nothing new can be created that needs this link. Fix for case 1208437
            if (!isPreset)
            {
                // Create item
                gm.AddSeparator("");
                gm.AddItem(EditorGUIUtility.TrTextContent("Create New..."), false, delegate
                {
                    var newAsset = Activator.CreateInstance <T>();
                    var doCreate = ScriptableObject.CreateInstance <DoCreateNewAsset>();
                    doCreate.SetProperty(serializedProperty);
                    ProjectWindowUtil.StartNameEditingIfProjectWindowExists(newAsset.GetInstanceID(), doCreate, "New " + typeName + "." + fileExtension, AssetPreview.GetMiniThumbnail(newAsset), null);
                });
            }

            gm.DropDown(buttonRect);
        }
        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);
        }
예제 #56
0
        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;
 }
            public static void Show(Rect activatorRect, PresetLibraryEditor <T> owner)
            {
                s_Owner = owner;

                GenericMenu menu = new GenericMenu();

                // View modes
                int minItemHeight = (int)s_Owner.minMaxPreviewHeight.x;
                int maxItemHeight = (int)s_Owner.minMaxPreviewHeight.y;
                List <ViewModeData> viewModeData;

                if (minItemHeight == maxItemHeight)
                {
                    viewModeData = new List <ViewModeData>
                    {
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Grid"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("List"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.List
                        },
                    };
                }
                else
                {
                    viewModeData = new List <ViewModeData>
                    {
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Small Grid"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Large Grid"), itemHeight = maxItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Small List"), itemHeight = minItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.List
                        },
                        new ViewModeData {
                            text = EditorGUIUtility.TrTextContent("Large List"), itemHeight = maxItemHeight, viewmode = PresetLibraryEditorState.ItemViewMode.List
                        }
                    };
                }

                for (int i = 0; i < viewModeData.Count; ++i)
                {
                    bool currentSelected = s_Owner.itemViewMode == viewModeData[i].viewmode && (int)s_Owner.previewHeight == viewModeData[i].itemHeight;
                    menu.AddItem(viewModeData[i].text, currentSelected, ViewModeChange, viewModeData[i]);
                }
                menu.AddSeparator("");

                // Available libraries (show user libraries first then project libraries)
                List <string> preferencesLibs;
                List <string> projectLibs;

                PresetLibraryManager.instance.GetAvailableLibraries(s_Owner.m_SaveLoadHelper, out preferencesLibs, out projectLibs);
                preferencesLibs.Sort();
                projectLibs.Sort();

                string currentLibWithExtension = s_Owner.currentLibraryWithoutExtension + "." + s_Owner.m_SaveLoadHelper.fileExtensionWithoutDot;

                string projectFolderTag = " (Project)";

                foreach (string libPath in preferencesLibs)
                {
                    string libName = Path.GetFileNameWithoutExtension(libPath);
                    menu.AddItem(new GUIContent(libName), currentLibWithExtension == libPath, LibraryModeChange, libPath);
                }
                foreach (string libPath in projectLibs)
                {
                    string libName = Path.GetFileNameWithoutExtension(libPath);
                    menu.AddItem(new GUIContent(libName + projectFolderTag), currentLibWithExtension == libPath, LibraryModeChange, libPath);
                }
                menu.AddSeparator("");
                menu.AddItem(EditorGUIUtility.TrTextContent("Create New Library..."), false, CreateLibrary, 0);
                if (HasDefaultPresets())
                {
                    menu.AddSeparator("");
                    menu.AddItem(EditorGUIUtility.TrTextContent("Add Factory Presets To Current Library"), false, AddDefaultPresetsToCurrentLibrary, 0);
                }
                menu.AddSeparator("");
                menu.AddItem(EditorGUIUtility.TrTextContent("Reveal Current Library Location"), false, RevealCurrentLibrary, 0);
                menu.DropDown(activatorRect);
            }
예제 #59
0
        private void VertexEditing(UnityEngine.Object unused, SceneView sceneView)
        {
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(300f) };
            GUILayout.BeginVertical(options);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label("Visualization: ", optionArray2);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            if (EditorGUILayout.ButtonMouseDown(this.GetModeString(this.drawMode), FocusType.Passive, EditorStyles.toolbarDropDown, new GUILayoutOption[0]))
            {
                Rect        last = GUILayoutUtility.topLevel.GetLast();
                GenericMenu menu = new GenericMenu();
                menu.AddItem(this.GetModeString(DrawMode.MaxDistance), this.drawMode == DrawMode.MaxDistance, new GenericMenu.MenuFunction(this.VisualizationMenuSetMaxDistanceMode));
                menu.AddItem(this.GetModeString(DrawMode.CollisionSphereDistance), this.drawMode == DrawMode.CollisionSphereDistance, new GenericMenu.MenuFunction(this.VisualizationMenuSetCollisionSphereMode));
                menu.AddSeparator(string.Empty);
                menu.AddItem(new GUIContent("Manipulate Backfaces"), this.state.ManipulateBackfaces, new GenericMenu.MenuFunction(this.VisualizationMenuToggleManipulateBackfaces));
                menu.DropDown(last);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label(this.m_MinVisualizedValue[(int)this.drawMode].ToString(), optionArray3);
            this.DrawColorBox(s_ColorTexture, Color.clear);
            GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
            GUILayout.Label(this.m_MaxVisualizedValue[(int)this.drawMode].ToString(), optionArray4);
            GUILayout.Label("Unconstrained:", new GUILayoutOption[0]);
            GUILayout.Space(-24f);
            GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.Width(20f) };
            GUILayout.BeginHorizontal(optionArray5);
            this.DrawColorBox(null, Color.black);
            GUILayout.EndHorizontal();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginVertical("Box", new GUILayoutOption[0]);
            if (Tools.current != Tool.None)
            {
                this.state.ToolMode = ~ToolMode.Select;
            }
            ToolMode toolMode = this.state.ToolMode;

            this.state.ToolMode = (ToolMode)GUILayout.Toolbar((int)this.state.ToolMode, s_ToolIcons, new GUILayoutOption[0]);
            if (this.state.ToolMode != toolMode)
            {
                GUIUtility.keyboardControl = 0;
                SceneView.RepaintAll();
                this.SetupSelectionMeshColors();
                this.SetupSelectedMeshColors();
            }
            switch (this.state.ToolMode)
            {
            case ToolMode.Select:
                Tools.current = Tool.None;
                this.SelectionGUI();
                break;

            case ToolMode.Paint:
                Tools.current = Tool.None;
                this.PaintGUI();
                break;
            }
            GUILayout.EndVertical();
            if (!this.IsConstrained())
            {
                EditorGUILayout.HelpBox("No constraints have been set up, so the cloth will move freely. Set up vertex constraints here to restrict it.", MessageType.Info);
            }
            GUILayout.EndVertical();
            GUILayout.Space(-4f);
        }
        private void DrawToolbarGUI()
        {
            EditorGUILayout.BeginHorizontal("Toolbar");
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);

            if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu();

                // Canvas creation
                foreach (System.Collections.Generic.KeyValuePair <Type, NodeCanvasTypeData> data in NodeCanvasManager.CanvasTypes)
                {
                    menu.AddItem(new GUIContent("New Canvas/" + data.Value.DisplayString), false, CreateCanvasCallback, data.Key);
                }
//				menu.AddItem(new GUIContent("New Standard Canvas"), false, CreateCanvasCallback, null);
                menu.AddSeparator("");

                // Scene Saving
                menu.AddItem(new GUIContent("Load Canvas", "Loads an asset canvas"), false, LoadCanvas);
                menu.AddItem(new GUIContent("Reload Canvas", "Restores the current canvas to when it has been last saved."), false, ReloadCanvas);
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas);
                menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs);
                menu.AddSeparator("");

                // Scene Saving
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    if (sceneSave.ToLower() != "lastsession")
                    {
                        menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave);
                    }
                }
                menu.AddItem(new GUIContent("Save Canvas to Scene"), false, () => showModalPanel = true);

                menu.DropDown(new Rect(5, toolbarHeight, 0, 0));
            }

            if (GUILayout.Button("Debug", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                GenericMenu menu = new GenericMenu();

                // Toggles side panel
                menu.AddItem(new GUIContent("Sidebar"), showSideWindow, () => showSideWindow = !showSideWindow);

                menu.DropDown(new Rect(55, toolbarHeight, 0, 0));
            }

            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            GUILayout.Label(new GUIContent("" + canvasCache.nodeCanvas.saveName + " (" + (canvasCache.nodeCanvas.livesInScene? "Scene Save" : "Asset Save") + ")", "Opened Canvas path: " + canvasCache.nodeCanvas.savePath), "ToolbarButton");
            GUILayout.Label("Type: " + canvasCache.typeData.DisplayString /*+ "/" + canvasCache.nodeCanvas.GetType ().Name*/, "ToolbarButton");

            GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1);
            if (GUILayout.Button("Force Re-init", EditorStyles.toolbarButton, GUILayout.Width(80)))
            {
                NodeEditor.ReInit(true);
            }
            GUI.backgroundColor = Color.white;

            EditorGUILayout.EndHorizontal();
        }