DropDown() public method

public DropDown ( Rect position ) : void
position UnityEngine.Rect
return void
コード例 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var left  = position; left.xMax -= 40;
            var right = position; right.xMin = left.xMax + 2;

            EditorGUI.PropertyField(left, property);

            if (GUI.Button(right, "List") == true)
            {
                var menu = new GenericMenu();

                if (LeanLocalization.Instance != null)
                {
                    for (var j = 0; j < LeanLocalization.Instance.Languages.Count; j++)
                    {
                        var language = LeanLocalization.Instance.Languages[j];

                        menu.AddItem(new GUIContent(language), property.stringValue == language, () => { property.stringValue = language; property.serializedObject.ApplyModifiedProperties(); });
                    }
                }

                if (menu.GetItemCount() > 0)
                {
                    menu.DropDown(right);
                }
                else
                {
                    Debug.LogWarning("Your scene doesn't contain any languages, so the language name list couldn't be created.");
                }
            }
        }
コード例 #2
0
ファイル: BundleWnd.cs プロジェクト: tsuixl/Frame
    void OnGUI()
    {
        Rect curWindowRect = EditorGUILayout.BeginVertical();
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            {
                // Create drop down
                Rect createBtnRect = GUILayoutUtility.GetRect(new GUIContent("Create"), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
                if (GUI.Button(createBtnRect, "Create", EditorStyles.toolbarDropDown))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.DropDown(createBtnRect);
                }


                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
                    BuildSettingEditor.Show();
            }
            EditorGUILayout.EndHorizontal();


        }
        EditorGUILayout.EndVertical();
    }
コード例 #3
0
        public override void OpenContextual(ToolControl control)
        {
            activatorControl = control;
            var menu = new GenericMenu();

            menu.allowDuplicateNames = true;
            GameObjectContextMenu.Fill(targets, menu, activatorControl.activatorScreenPosition, null);
            menu.DropDown(activatorControl.activatorGuiPosition);
        }
コード例 #4
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();
 }
コード例 #5
0
ファイル: ImguiUtil.cs プロジェクト: Cyberbanan/Projeny
        public static void OpenContextMenu(Vector2 startPos, IEnumerable<ContextMenuItem> items)
        {
            GenericMenu contextMenu = new GenericMenu();

            foreach (var item in items)
            {
                var handler = item.Handler;
                contextMenu.AddOptionalItem(
                    item.IsEnabled, new GUIContent(item.Caption), item.IsChecked, () => handler());
            }

            contextMenu.DropDown(new Rect(startPos.x, startPos.y, 0, 0));
        }
コード例 #6
0
			public static void Show(Rect buttonRect, int viewIndex, AudioMixerGroupViewList list)
			{
				GenericMenu genericMenu = new GenericMenu();
				AudioMixerGroupViewList.ViewsContexttMenu.data userData = new AudioMixerGroupViewList.ViewsContexttMenu.data
				{
					viewIndex = viewIndex,
					list = list
				};
				genericMenu.AddItem(new GUIContent("Rename"), false, new GenericMenu.MenuFunction2(AudioMixerGroupViewList.ViewsContexttMenu.Rename), userData);
				genericMenu.AddItem(new GUIContent("Duplicate"), false, new GenericMenu.MenuFunction2(AudioMixerGroupViewList.ViewsContexttMenu.Duplicate), userData);
				genericMenu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(AudioMixerGroupViewList.ViewsContexttMenu.Delete), userData);
				genericMenu.DropDown(buttonRect);
			}
コード例 #7
0
 internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor)
 {
   GUIContent content1 = new GUIContent("Copy");
   GUIContent content2 = new GUIContent("Paste");
   GenericMenu genericMenu = new GenericMenu();
   bool flag1 = property != null && property2 != null;
   bool flag2 = flag1 && ParticleSystemClipboard.HasDoubleAnimationCurve() || !flag1 && ParticleSystemClipboard.HasSingleAnimationCurve();
   AnimationCurveContextMenu curveContextMenu = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor);
   genericMenu.AddItem(content1, false, new GenericMenu.MenuFunction(curveContextMenu.Copy));
   if (flag2)
     genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(curveContextMenu.Paste));
   else
     genericMenu.AddDisabledItem(content2);
   genericMenu.DropDown(position);
 }
コード例 #8
0
			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);
			}
コード例 #9
0
ファイル: NodeFactory.cs プロジェクト: keijiro/OscKlak
        // Create and open the "Create New Node" dropdown menu.
        public void CreateNodeMenuGUI(Patch patch)
        {
            if (GUILayout.Button(_buttonText, EditorStyles.toolbarDropDown))
            {
                var menu = new GenericMenu();

                foreach (var nodeType in _nodeTypes)
                    menu.AddItem(
                        new GUIContent(nodeType.label), false,
                        OnMenuItem, new MenuItemData(patch, nodeType.type)
                    );

                var oy = EditorStyles.toolbar.fixedHeight - 2;
                menu.DropDown(new Rect(1, oy, 1, 1));
            }
        }
コード例 #10
0
			internal static void Show(Rect activatorRect, List<ExposablePopupMenu.ItemData> buttonData, ExposablePopupMenu caller)
			{
				ExposablePopupMenu.PopUpMenu.m_Data = buttonData;
				ExposablePopupMenu.PopUpMenu.m_Caller = caller;
				GenericMenu genericMenu = new GenericMenu();
				foreach (ExposablePopupMenu.ItemData current in ExposablePopupMenu.PopUpMenu.m_Data)
				{
					if (current.m_Enabled)
					{
						genericMenu.AddItem(current.m_GUIContent, current.m_On, new GenericMenu.MenuFunction2(ExposablePopupMenu.PopUpMenu.SelectionCallback), current);
					}
					else
					{
						genericMenu.AddDisabledItem(current.m_GUIContent);
					}
				}
				genericMenu.DropDown(activatorRect);
			}
コード例 #11
0
 internal static void Show(Rect position, SerializedProperty property, SerializedProperty property2, SerializedProperty scalar, Rect curveRanges, ParticleSystemCurveEditor curveEditor)
 {
     GUIContent content = new GUIContent("Copy");
     GUIContent content2 = new GUIContent("Paste");
     GenericMenu menu = new GenericMenu();
     bool flag = (property != null) && (property2 != null);
     bool flag2 = (flag && ParticleSystemClipboard.HasDoubleAnimationCurve()) || (!flag && ParticleSystemClipboard.HasSingleAnimationCurve());
     AnimationCurveContextMenu menu2 = new AnimationCurveContextMenu(property, property2, scalar, curveRanges, curveEditor);
     menu.AddItem(content, false, new GenericMenu.MenuFunction(menu2.Copy));
     if (flag2)
     {
         menu.AddItem(content2, false, new GenericMenu.MenuFunction(menu2.Paste));
     }
     else
     {
         menu.AddDisabledItem(content2);
     }
     menu.DropDown(position);
 }
コード例 #12
0
		public static void Show(Rect buttonRect, string[] classNames, int initialSelectedInstanceID)
		{
			GenericMenu genericMenu = new GenericMenu();
			List<UnityEngine.Object> list = AssetSelectionPopupMenu.FindAssetsOfType(classNames);
			if (list.Any<UnityEngine.Object>())
			{
				list.Sort((UnityEngine.Object result1, UnityEngine.Object result2) => EditorUtility.NaturalCompare(result1.name, result2.name));
				foreach (UnityEngine.Object current in list)
				{
					GUIContent content = new GUIContent(current.name);
					bool on = current.GetInstanceID() == initialSelectedInstanceID;
					genericMenu.AddItem(content, on, new GenericMenu.MenuFunction2(AssetSelectionPopupMenu.SelectCallback), current);
				}
			}
			else
			{
				genericMenu.AddDisabledItem(new GUIContent("No Audio Mixers found in this project"));
			}
			genericMenu.DropDown(buttonRect);
		}
コード例 #13
0
 public static void Show(Rect buttonRect, string[] classNames, int initialSelectedInstanceID)
 {
   GenericMenu genericMenu = new GenericMenu();
   List<UnityEngine.Object> assetsOfType = AssetSelectionPopupMenu.FindAssetsOfType(classNames);
   if (assetsOfType.Any<UnityEngine.Object>())
   {
     assetsOfType.Sort((Comparison<UnityEngine.Object>) ((result1, result2) => EditorUtility.NaturalCompare(result1.name, result2.name)));
     using (List<UnityEngine.Object>.Enumerator enumerator = assetsOfType.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
         UnityEngine.Object current = enumerator.Current;
         GUIContent content = new GUIContent(current.name);
         bool on = current.GetInstanceID() == initialSelectedInstanceID;
         genericMenu.AddItem(content, on, new GenericMenu.MenuFunction2(AssetSelectionPopupMenu.SelectCallback), (object) current);
       }
     }
   }
   else
     genericMenu.AddDisabledItem(new GUIContent("No Audio Mixers found in this project"));
   genericMenu.DropDown(buttonRect);
 }
コード例 #14
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);

			}*/
			
		}
コード例 #15
0
ファイル: APPWindow.cs プロジェクト: kinifi/LE_IM
    void OnGUI()
    {
        GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField);
        boldNumberFieldStyle.font = EditorStyles.boldFont;

        GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle);
        boldToggleStyle.font = EditorStyles.boldFont;

        GUI.enabled = !waitTillPlistHasBeenWritten;

        //Toolbar
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false));

            if (GUILayout.Button(new GUIContent("Sort   " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                OnChangeSortModeClicked();
            }

            if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Import..."), false, OnImport);
                options.AddItem(new GUIContent("Export Selected..."), false, OnExportSelected);
                options.AddItem(new GUIContent("Export All Entries"), false, OnExportAllClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked);
                options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked);
                options.DropDown(optionsRect);
            }

            GUILayout.Space(5);

            //Searchfield
            Rect position = GUILayoutUtility.GetRect(50, 250, 10, 50,EditorStyles.toolbarTextField);
            position.width -= 16;
            position.x += 16;
            SearchString = GUI.TextField(position, SearchString, EditorStyles.toolbarTextField);

            position.x = position.x - 18;
            position.width = 20;
            if (GUI.Button(position, "", ToolbarSeachTextFieldPopup))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("All"), SearchFilter == SearchFilterType.All, OnSearchAllClicked);
                options.AddItem(new GUIContent("Key"), SearchFilter == SearchFilterType.Key, OnSearchKeyClicked);
                options.AddItem(new GUIContent("Value (Strings only)"), SearchFilter == SearchFilterType.Value , OnSearchValueClicked);
                options.DropDown(position);
            }

            position = GUILayoutUtility.GetRect(10, 10, ToolbarSeachCancelButton);
            position.x -= 5;
            if (GUI.Button(position, "", ToolbarSeachCancelButton))
            {
                SearchString = string.Empty;
            }

            GUILayout.FlexibleSpace();

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?";
                autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(75));
            }

            if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)))
            {
                RefreshKeys();
            }

            Rect r;
            if (Application.platform == RuntimePlatform.OSXEditor)
                r = GUILayoutUtility.GetRect(16, 16);
            else
                r = GUILayoutUtility.GetRect(9, 16);

            if (waitTillPlistHasBeenWritten)
            {
                Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D;

                GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t);
            }
        }
        EditorGUILayout.EndHorizontal();

        GUI.enabled = !waitTillPlistHasBeenWritten;

        if (showNewEntryBox)
        {
            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                {
                    newKey = EditorGUILayout.TextField("Key", newKey);

                    switch (selectedType)
                    {
                        default:
                        case ValueType.String:
                            newValueString = EditorGUILayout.TextField("Value", newValueString);
                            break;
                        case ValueType.Float:
                            newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat);
                            break;
                        case ValueType.Integer:
                            newValueInt = EditorGUILayout.IntField("Value", newValueInt);
                            break;
                    }

                    selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType);
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(1));
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false)))
                        {
                            showNewEntryBox = false;
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value.")))
                    {
                        if (!string.IsNullOrEmpty(newKey))
                        {
                            switch (selectedType)
                            {
                                case ValueType.Integer:
                                    PlayerPrefs.SetInt(newKey, newValueInt);
                                    ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt));
                                    break;
                                case ValueType.Float:
                                    PlayerPrefs.SetFloat(newKey, newValueFloat);
                                    ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat));
                                    break;
                                default:
                                case ValueType.String:
                                    PlayerPrefs.SetString(newKey, newValueString);
                                    ppeList.Add(new PlayerPrefsEntry(newKey, newValueString));
                                    break;
                            }
                            PlayerPrefs.Save();
                        }

                        newKey = newValueString = "";
                        newValueInt = 0;
                        newValueFloat = 0;
                        GUIUtility.keyboardControl = 0;	//move focus from textfield, else the text won't be cleared
                        showNewEntryBox = false;
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(2);
        
        GUI.backgroundColor = Color.white;
        
        EditorGUI.indentLevel++;

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        {
            EditorGUILayout.BeginVertical();
            {
                for (int i = 0; i < filteredPpeList.Count; i++)
                {
                    if (filteredPpeList[i].Value != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            filteredPpeList[i].IsSelected = GUILayout.Toggle(filteredPpeList[i].IsSelected, new GUIContent("", "Toggle selection."), filteredPpeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MaxWidth(20), GUILayout.MinWidth(20), GUILayout.ExpandWidth(false));
                            filteredPpeList[i].Key = GUILayout.TextField(filteredPpeList[i].Key, filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField, GUILayout.MaxWidth(125), GUILayout.MinWidth(40), GUILayout.ExpandWidth(true));

                            GUIStyle numberFieldStyle = filteredPpeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField;

                            switch (filteredPpeList[i].Type)
                            {
                                default:
                                case ValueType.String:
                                    filteredPpeList[i].Value = EditorGUILayout.TextField("", (string)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                    break;
                                case ValueType.Float:
                                    filteredPpeList[i].Value = EditorGUILayout.FloatField("", (float)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                    break;
                                case ValueType.Integer:
                                    filteredPpeList[i].Value = EditorGUILayout.IntField("", (int)filteredPpeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                    break;
                            }

                            GUILayout.Label(new GUIContent("?", filteredPpeList[i].Type.ToString()), GUILayout.ExpandWidth(false));

                            GUI.enabled = filteredPpeList[i].HasChanged && !waitTillPlistHasBeenWritten;
                            if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                filteredPpeList[i].SaveChanges();
                            }

                            if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                filteredPpeList[i].RevertChanges();
                            }

                            GUI.enabled = !waitTillPlistHasBeenWritten;

                            if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false)))
                            {
                                PlayerPrefs.DeleteKey(filteredPpeList[i].Key);
                                ppeList.Remove(filteredPpeList[i]);
                                PlayerPrefs.Save();

                                UpdateFilteredList();
                                break;
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndScrollView();

        EditorGUI.indentLevel--;
    }
コード例 #16
0
		private void DrawToolbar(GUIStyle buttonStyle, GUIStyle buttonDropdownStyle) {
			
			var result = GUILayout.Button("Create", buttonDropdownStyle);
			if (Event.current.type == EventType.Repaint) {
				
				this.layoutStateToolbarCreateButtonRect = GUILayoutUtility.GetLastRect();
				
			}

			if (result == true) {
				
				var menu = new GenericMenu();
				this.SetupCreateMenu(string.Empty, menu);
				
				menu.DropDown(this.layoutStateToolbarCreateButtonRect);
				
			}
			
			result = GUILayout.Button("Tools", buttonDropdownStyle);
			if (Event.current.type == EventType.Repaint) {
				
				this.layoutStateToolbarToolsButtonRect = GUILayoutUtility.GetLastRect();
				
			}

			if (result == true) {
				
				var menu = new GenericMenu();
				this.SetupToolsMenu(string.Empty, menu);
				
				menu.DropDown(this.layoutStateToolbarToolsButtonRect);
				
			}
			
			Flow.OnDrawToolbarGUI(this, buttonStyle);
			
			GUILayout.FlexibleSpace();
			
			var oldColor = GUI.color;
			GUI.color = Color.gray;
			GUILayout.Label(string.Format("Current Data: {0}", AssetDatabase.GetAssetPath(this.guiSplash.cachedData)), buttonStyle);
			GUI.color = oldColor;
			
			if (GUILayout.Button("Change", buttonStyle) == true) {
				
				this.ChangeFlowData();
				
			}
			
		}
        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);
        }
コード例 #18
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);
        }
コード例 #19
0
        public void ObjectPreview(Rect r)
        {
            if (r.height <= 0)
            {
                return;
            }

            if (m_ZoomablePreview == null)
            {
                m_ZoomablePreview = new ZoomableArea(true);

                m_ZoomablePreview.hRangeMin = 0.0f;
                m_ZoomablePreview.vRangeMin = 0.0f;

                m_ZoomablePreview.hRangeMax = 1.0f;
                m_ZoomablePreview.vRangeMax = 1.0f;

                m_ZoomablePreview.SetShownHRange(0, 1);
                m_ZoomablePreview.SetShownVRange(0, 1);

                m_ZoomablePreview.uniformScale    = true;
                m_ZoomablePreview.scaleWithWindow = true;
            }

            // Draw background
            GUI.Box(r, "", "PreBackground");

            // Top menu rect
            Rect menuRect = new Rect(r);

            menuRect.y     += 1;
            menuRect.height = 18;
            GUI.Box(menuRect, "", EditorStyles.toolbar);

            // Top menu dropdown
            Rect dropRect = new Rect(r);

            dropRect.y     += 1;
            dropRect.height = 18;
            dropRect.width  = 120;

            // Drawable area
            Rect drawableArea = new Rect(r);

            drawableArea.yMin  += dropRect.height;
            drawableArea.yMax  -= 14;
            drawableArea.width -= 11;

            int index = Array.IndexOf(Styles.ObjectPreviewTextureOptions, m_SelectedObjectPreviewTexture);

            if (index < 0 || !LightmapVisualizationUtility.IsTextureTypeEnabled(kObjectPreviewTextureTypes[index]))
            {
                index = 0;
                m_SelectedObjectPreviewTexture = Styles.ObjectPreviewTextureOptions[index];
            }

            if (EditorGUI.DropdownButton(dropRect, m_SelectedObjectPreviewTexture, FocusType.Passive, EditorStyles.toolbarPopup))
            {
                GenericMenu menu = new GenericMenu();

                for (int i = 0; i < Styles.ObjectPreviewTextureOptions.Length; i++)
                {
                    if (LightmapVisualizationUtility.IsTextureTypeEnabled(kObjectPreviewTextureTypes[i]))
                    {
                        menu.AddItem(Styles.ObjectPreviewTextureOptions[i], index == i, SelectPreviewTextureOption, Styles.ObjectPreviewTextureOptions.ElementAt(i));
                    }
                    else
                    {
                        menu.AddDisabledItem(Styles.ObjectPreviewTextureOptions.ElementAt(i));
                    }
                }
                menu.DropDown(dropRect);
            }

            GITextureType textureType = kObjectPreviewTextureTypes[Array.IndexOf(Styles.ObjectPreviewTextureOptions, m_SelectedObjectPreviewTexture)];

            if (m_CachedTexture.type != textureType || m_CachedTexture.contentHash != LightmapVisualizationUtility.GetSelectedObjectGITextureHash(textureType) || m_CachedTexture.contentHash == new Hash128())
            {
                m_CachedTexture = LightmapVisualizationUtility.GetSelectedObjectGITexture(textureType);
            }

            if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureNotAvailable || m_CachedTexture.textureAvailability == GITextureAvailability.GITextureUnknown)
            {
                if (LightmapVisualizationUtility.IsBakedTextureType(textureType))
                {
                    if (textureType == GITextureType.BakedShadowMask)
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBakedShadowmask);
                    }
                    else
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBaked);
                    }
                }
                else
                {
                    GUI.Label(drawableArea, Styles.TextureNotAvailableRealtime);
                }

                return;
            }

            if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureLoading && m_CachedTexture.texture == null)
            {
                GUI.Label(drawableArea, Styles.TextureLoading);

                return;
            }

            LightmapType lightmapType = LightmapVisualizationUtility.GetLightmapType(textureType);

            // Framing and drawing
            var evt = Event.current;

            switch (evt.type)
            {
            // 'F' will zoom to uv bounds
            case EventType.ValidateCommand:
            case EventType.ExecuteCommand:

                if (Event.current.commandName == EventCommandNames.FrameSelected)
                {
                    Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                    if ((textureType == GITextureType.BakedAlbedo || textureType == GITextureType.BakedEmissive) && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.ProgressiveCPU)
                    {
                        lightmapTilingOffset = new Vector4(1f, 1f, 0f, 0f);
                    }

                    Vector2 min = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                    Vector2 max = min + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);

                    min = Vector2.Max(min, Vector2.zero);
                    max = Vector2.Min(max, Vector2.one);

                    float swap = 1f - min.y;
                    min.y = 1f - max.y;
                    max.y = swap;

                    // Make sure that the focus rectangle is a even square
                    Rect rect = new Rect(min.x, min.y, max.x - min.x, max.y - min.y);
                    rect.x    -= Mathf.Clamp(rect.height - rect.width, 0, float.MaxValue) / 2;
                    rect.y    -= Mathf.Clamp(rect.width - rect.height, 0, float.MaxValue) / 2;
                    rect.width = rect.height = Mathf.Max(rect.width, rect.height);

                    m_ZoomablePreview.shownArea = rect;
                    Event.current.Use();
                }
                break;

            // Scale and draw texture and uv's
            case EventType.Repaint:

                Texture2D texture = m_CachedTexture.texture;
                if (texture && Event.current.type == EventType.Repaint)
                {
                    Rect textureRect = new Rect(0, 0, texture.width, texture.height);
                    textureRect = ResizeRectToFit(textureRect, drawableArea);
                    //textureRect.x = -textureRect.width / 2;
                    //textureRect.y = -textureRect.height / 2;
                    textureRect = CenterToRect(textureRect, drawableArea);
                    textureRect = ScaleRectByZoomableArea(textureRect, m_ZoomablePreview);

                    // Draw texture and UV
                    Rect uvRect = new Rect(textureRect);
                    uvRect.x += 3;
                    uvRect.y += drawableArea.y + 20;

                    Rect clipRect = new Rect(drawableArea);
                    clipRect.y += dropRect.height + 3;

                    // fix 635838 - We need to offset the rects for rendering.
                    {
                        float offset = clipRect.y - 14;
                        uvRect.y   -= offset;
                        clipRect.y -= offset;
                    }

                    // Texture shouldn't be filtered since it will make previewing really blurry
                    FilterMode prevMode = texture.filterMode;
                    texture.filterMode = FilterMode.Point;

                    LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, clipRect, uvRect, textureType);
                    texture.filterMode = prevMode;
                }
                break;
            }

            // Reset zoom if selection is changed
            if (m_PreviousSelection != Selection.activeInstanceID)
            {
                m_PreviousSelection = Selection.activeInstanceID;
                m_ZoomablePreview.SetShownHRange(0, 1);
                m_ZoomablePreview.SetShownVRange(0, 1);
            }

            // Handle zoomable area
            Rect zoomRect = new Rect(r);

            zoomRect.yMin         += dropRect.height;
            m_ZoomablePreview.rect = zoomRect;

            m_ZoomablePreview.BeginViewGUI();
            m_ZoomablePreview.EndViewGUI();

            GUILayoutUtility.GetRect(r.width, r.height);
        }
コード例 #20
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("");
                }
                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("");
            }
            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("");
                genericMenu.AddItem(new GUIContent("Remove this effect"), false, delegate
                {
                    controller.ClearSendConnectionsTo(effect);
                    controller.RemoveEffect(effect, group);
                    AudioMixerUtility.RepaintAudioMixerAndInspectors();
                });
            }
            genericMenu.DropDown(buttonRect);
        }
コード例 #21
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,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        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,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        new PresetLibraryEditor <T> .SettingsMenu.ViewModeData
                        {
                            text       = new GUIContent("Large Grid"),
                            itemHeight = num2,
                            viewmode   = PresetLibraryEditorState.ItemViewMode.Grid
                        },
                        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);
            }
コード例 #22
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);
        }
コード例 #23
0
 public void OnGUI(AudioMixerGroupController group)
 {
     if (!(group == null))
     {
         AudioMixerController             controller         = group.controller;
         List <AudioMixerGroupController> allAudioGroupsSlow = controller.GetAllAudioGroupsSlow();
         Dictionary <AudioMixerEffectController, AudioMixerGroupController> dictionary = new Dictionary <AudioMixerEffectController, AudioMixerGroupController>();
         foreach (AudioMixerGroupController current in allAudioGroupsSlow)
         {
             AudioMixerEffectController[] effects = current.effects;
             for (int i = 0; i < effects.Length; i++)
             {
                 AudioMixerEffectController key = effects[i];
                 dictionary[key] = current;
             }
         }
         Rect totalRect = EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
         if (EditorApplication.isPlaying)
         {
             GUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayout.FlexibleSpace();
             EditorGUI.BeginChangeCheck();
             GUILayout.Toggle(AudioSettings.editingInPlaymode, AudioMixerEffectView.Texts.editInPlaymode, EditorStyles.miniButton, new GUILayoutOption[]
             {
                 GUILayout.Width(120f)
             });
             if (EditorGUI.EndChangeCheck())
             {
                 AudioSettings.editingInPlaymode = !AudioSettings.editingInPlaymode;
             }
             GUILayout.FlexibleSpace();
             GUILayout.EndHorizontal();
         }
         using (new EditorGUI.DisabledScope(!AudioMixerController.EditingTargetSnapshot()))
         {
             if (group != this.m_PrevGroup)
             {
                 this.m_PrevGroup = group;
                 controller.m_HighlightEffectIndex = -1;
                 AudioMixerUtility.RepaintAudioMixerAndInspectors();
             }
             AudioMixerEffectView.DoInitialModule(group, controller, allAudioGroupsSlow);
             for (int j = 0; j < group.effects.Length; j++)
             {
                 this.DoEffectGUI(j, group, allAudioGroupsSlow, dictionary, ref controller.m_HighlightEffectIndex);
             }
             this.m_EffectDragging.HandleDragging(totalRect, group, controller);
             GUILayout.Space(10f);
             EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayout.FlexibleSpace();
             if (EditorGUILayout.ButtonMouseDown(AudioMixerEffectView.Texts.addEffect, FocusType.Passive, GUISkin.current.button, new GUILayoutOption[0]))
             {
                 GenericMenu genericMenu            = new GenericMenu();
                 Rect        last                   = GUILayoutUtility.topLevel.GetLast();
                 AudioMixerGroupController[] groups = new AudioMixerGroupController[]
                 {
                     group
                 };
                 AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groups, group.effects.Length, string.Empty, genericMenu);
                 genericMenu.DropDown(last);
             }
             EditorGUILayout.EndHorizontal();
         }
         EditorGUILayout.EndVertical();
     }
 }
コード例 #24
0
        private void ShowLODGUI()
        {
            m_ShowSmoothLODOptions.target      = m_EnableSmoothLOD.hasMultipleDifferentValues || m_EnableSmoothLOD.boolValue;
            m_ShowCrossFadeWidthOptions.target = m_AnimateCrossFading.hasMultipleDifferentValues || !m_AnimateCrossFading.boolValue;

            GUILayout.Label(Styles.LODHeader, EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(m_EnableSmoothLOD, Styles.SmoothLOD);

            EditorGUI.indentLevel++;
            if (EditorGUILayout.BeginFadeGroup(m_ShowSmoothLODOptions.faded))
            {
                EditorGUILayout.PropertyField(m_AnimateCrossFading, Styles.AnimateCrossFading);
                if (EditorGUILayout.BeginFadeGroup(m_ShowCrossFadeWidthOptions.faded))
                {
                    EditorGUILayout.Slider(m_BillboardTransitionCrossFadeWidth, 0.0f, 1.0f, Styles.CrossFadeWidth);
                    EditorGUILayout.Slider(m_FadeOutWidth, 0.0f, 1.0f, Styles.FadeOutWidth);
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            if (HasSameLODConfig())
            {
                EditorGUILayout.Space();

                var area = GUILayoutUtility.GetRect(0, LODGroupGUI.kSliderBarHeight, GUILayout.ExpandWidth(true));
                var lods = GetLODInfoArray(area);
                DrawLODLevelSlider(area, lods);

                EditorGUILayout.Space();
                EditorGUILayout.Space();

                if (m_SelectedLODRange != -1 && lods.Count > 0)
                {
                    EditorGUILayout.LabelField(lods[m_SelectedLODRange].LODName + " Options", EditorStyles.boldLabel);
                    bool isBillboard = (m_SelectedLODRange == lods.Count - 1) && importers[0].hasBillboard;

                    EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("castShadows"), Styles.CastShadows);
                    EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("receiveShadows"), Styles.ReceiveShadows);

                    var useLightProbes = m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("useLightProbes");
                    EditorGUILayout.PropertyField(useLightProbes, Styles.UseLightProbes);
                    if (!useLightProbes.hasMultipleDifferentValues && useLightProbes.boolValue && isBillboard)
                    {
                        EditorGUILayout.HelpBox("Enabling Light Probe for billboards breaks batched rendering and may cause performance problem.", MessageType.Warning);
                    }

                    // TODO: reflection probe support when PBS is implemented
                    //EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("useReflectionProbes"), Styles.UseReflectionProbes);

                    EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("enableBump"), Styles.EnableBump);
                    EditorGUILayout.PropertyField(m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("enableHue"), Styles.EnableHue);

                    int bestWindQuality = importers.Min(im => im.bestWindQuality);
                    if (bestWindQuality > 0)
                    {
                        if (isBillboard)
                        {
                            bestWindQuality = bestWindQuality >= 1 ? 1 : 0; // billboard has only one level of wind quality
                        }
                        EditorGUILayout.Popup(
                            m_LODSettings.GetArrayElementAtIndex(m_SelectedLODRange).FindPropertyRelative("windQuality"),
                            SpeedTreeImporter.windQualityNames.Take(bestWindQuality + 1).Select(s => new GUIContent(s)).ToArray(),
                            Styles.WindQuality);
                    }
                }
            }
            else
            {
                if (CanUnifyLODConfig())
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    Rect buttonRect = GUILayoutUtility.GetRect(Styles.ResetLOD, EditorStyles.miniButton);
                    if (GUI.Button(buttonRect, Styles.ResetLOD, EditorStyles.miniButton))
                    {
                        var dropDownMenu = new GenericMenu();
                        foreach (var importer in targets.Cast <SpeedTreeImporter>())
                        {
                            var menuText = String.Format("{0}: {1}",
                                                         Path.GetFileNameWithoutExtension(importer.assetPath),
                                                         String.Join(" | ", importer.LODHeights.Select(height => String.Format("{0:0}%", height * 100)).ToArray()));
                            dropDownMenu.AddItem(new GUIContent(menuText), false, OnResetLODMenuClick, importer);
                        }
                        dropDownMenu.DropDown(buttonRect);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                var area = GUILayoutUtility.GetRect(0, LODGroupGUI.kSliderBarHeight, GUILayout.ExpandWidth(true));
                if (Event.current.type == EventType.Repaint)
                {
                    LODGroupGUI.DrawMixedValueLODSlider(area);
                }
            }

            EditorGUILayout.Space();
        }
コード例 #25
0
            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);
            }
コード例 #26
0
 private void ShowLODGUI()
 {
     this.m_ShowSmoothLODOptions.target      = this.m_EnableSmoothLOD.hasMultipleDifferentValues || this.m_EnableSmoothLOD.boolValue;
     this.m_ShowCrossFadeWidthOptions.target = this.m_AnimateCrossFading.hasMultipleDifferentValues || !this.m_AnimateCrossFading.boolValue;
     GUILayout.Label(SpeedTreeImporterInspector.Styles.LODHeader, EditorStyles.boldLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_EnableSmoothLOD, SpeedTreeImporterInspector.Styles.SmoothLOD, new GUILayoutOption[0]);
     ++EditorGUI.indentLevel;
     if (EditorGUILayout.BeginFadeGroup(this.m_ShowSmoothLODOptions.faded))
     {
         EditorGUILayout.PropertyField(this.m_AnimateCrossFading, SpeedTreeImporterInspector.Styles.AnimateCrossFading, new GUILayoutOption[0]);
         if (EditorGUILayout.BeginFadeGroup(this.m_ShowCrossFadeWidthOptions.faded))
         {
             EditorGUILayout.Slider(this.m_BillboardTransitionCrossFadeWidth, 0.0f, 1f, SpeedTreeImporterInspector.Styles.CrossFadeWidth, new GUILayoutOption[0]);
             EditorGUILayout.Slider(this.m_FadeOutWidth, 0.0f, 1f, SpeedTreeImporterInspector.Styles.FadeOutWidth, new GUILayoutOption[0]);
         }
         EditorGUILayout.EndFadeGroup();
     }
     EditorGUILayout.EndFadeGroup();
     --EditorGUI.indentLevel;
     EditorGUILayout.Space();
     if (this.HasSameLODConfig())
     {
         EditorGUILayout.Space();
         Rect rect = GUILayoutUtility.GetRect(0.0f, 30f, new GUILayoutOption[1] {
             GUILayout.ExpandWidth(true)
         });
         List <LODGroupGUI.LODInfo> lodInfoArray = this.GetLODInfoArray(rect);
         this.DrawLODLevelSlider(rect, lodInfoArray);
         EditorGUILayout.Space();
         EditorGUILayout.Space();
         if (this.m_SelectedLODRange != -1 && lodInfoArray.Count > 0)
         {
             EditorGUILayout.LabelField(lodInfoArray[this.m_SelectedLODRange].LODName + " Options", EditorStyles.boldLabel, new GUILayoutOption[0]);
             bool flag = this.m_SelectedLODRange == lodInfoArray.Count - 1 && this.importers[0].hasBillboard;
             EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("castShadows"), SpeedTreeImporterInspector.Styles.CastShadows, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("receiveShadows"), SpeedTreeImporterInspector.Styles.ReceiveShadows, new GUILayoutOption[0]);
             SerializedProperty propertyRelative = this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("useLightProbes");
             EditorGUILayout.PropertyField(propertyRelative, SpeedTreeImporterInspector.Styles.UseLightProbes, new GUILayoutOption[0]);
             if (!propertyRelative.hasMultipleDifferentValues && propertyRelative.boolValue && flag)
             {
                 EditorGUILayout.HelpBox("Enabling Light Probe for billboards breaks batched rendering and may cause performance problem.", MessageType.Warning);
             }
             EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("enableBump"), SpeedTreeImporterInspector.Styles.EnableBump, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("enableHue"), SpeedTreeImporterInspector.Styles.EnableHue, new GUILayoutOption[0]);
             int num = ((IEnumerable <SpeedTreeImporter>) this.importers).Min <SpeedTreeImporter>((Func <SpeedTreeImporter, int>)(im => im.bestWindQuality));
             if (num > 0)
             {
                 if (flag)
                 {
                     num = num < 1 ? 0 : 1;
                 }
                 EditorGUILayout.Popup(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("windQuality"), ((IEnumerable <string>)SpeedTreeImporter.windQualityNames).Take <string>(num + 1).Select <string, GUIContent>((Func <string, GUIContent>)(s => new GUIContent(s))).ToArray <GUIContent>(), SpeedTreeImporterInspector.Styles.WindQuality, new GUILayoutOption[0]);
             }
         }
     }
     else
     {
         if (this.CanUnifyLODConfig())
         {
             EditorGUILayout.BeginHorizontal();
             GUILayout.FlexibleSpace();
             Rect rect = GUILayoutUtility.GetRect(SpeedTreeImporterInspector.Styles.ResetLOD, EditorStyles.miniButton);
             if (GUI.Button(rect, SpeedTreeImporterInspector.Styles.ResetLOD, EditorStyles.miniButton))
             {
                 GenericMenu genericMenu = new GenericMenu();
                 foreach (SpeedTreeImporter speedTreeImporter in this.targets.Cast <SpeedTreeImporter>())
                 {
                     string text = string.Format("{0}: {1}", (object)Path.GetFileNameWithoutExtension(speedTreeImporter.assetPath), (object)string.Join(" | ", ((IEnumerable <float>)speedTreeImporter.LODHeights).Select <float, string>((Func <float, string>)(height => string.Format("{0:0}%", (object)(height * 100f)))).ToArray <string>()));
                     genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.OnResetLODMenuClick), (object)speedTreeImporter);
                 }
                 genericMenu.DropDown(rect);
             }
             EditorGUILayout.EndHorizontal();
         }
         Rect rect1 = GUILayoutUtility.GetRect(0.0f, 30f, new GUILayoutOption[1] {
             GUILayout.ExpandWidth(true)
         });
         if (Event.current.type == EventType.Repaint)
         {
             LODGroupGUI.DrawMixedValueLODSlider(rect1);
         }
     }
     EditorGUILayout.Space();
 }
コード例 #27
0
        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);
        }
コード例 #28
0
            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);
            }
コード例 #29
0
 public static void GUIMMCurveStateList(Rect rect, SerializedMinMaxCurve[] minMaxCurves)
 {
   if (!EditorGUI.ButtonMouseDown(rect, GUIContent.none, FocusType.Passive, ParticleSystemStyles.Get().minMaxCurveStateDropDown) || minMaxCurves.Length == 0)
     return;
   GUIContent[] guiContentArray = new GUIContent[4]{ new GUIContent("Constant"), new GUIContent("Curve"), new GUIContent("Random Between Two Constants"), new GUIContent("Random Between Two Curves") };
   MinMaxCurveState[] minMaxCurveStateArray = new MinMaxCurveState[4]{ MinMaxCurveState.k_Scalar, MinMaxCurveState.k_Curve, MinMaxCurveState.k_TwoScalars, MinMaxCurveState.k_TwoCurves };
   bool[] flagArray = new bool[4]{ (minMaxCurves[0].m_AllowConstant ? 1 : 0) != 0, (minMaxCurves[0].m_AllowCurves ? 1 : 0) != 0, (minMaxCurves[0].m_AllowRandom ? 1 : 0) != 0, (!minMaxCurves[0].m_AllowRandom ? 0 : (minMaxCurves[0].m_AllowCurves ? 1 : 0)) != 0 };
   GenericMenu genericMenu = new GenericMenu();
   for (int index = 0; index < guiContentArray.Length; ++index)
   {
     if (flagArray[index])
       genericMenu.AddItem(guiContentArray[index], minMaxCurves[0].state == minMaxCurveStateArray[index], new GenericMenu.MenuFunction2(ModuleUI.SelectMinMaxCurveStateCallback), (object) new ModuleUI.CurveStateCallbackData(minMaxCurveStateArray[index], minMaxCurves));
   }
   genericMenu.DropDown(rect);
   Event.current.Use();
 }
コード例 #30
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);
        }
コード例 #31
0
 public void OnGUI(AudioMixerGroupController group)
 {
   if ((UnityEngine.Object) group == (UnityEngine.Object) null)
     return;
   AudioMixerController controller = group.controller;
   List<AudioMixerGroupController> allAudioGroupsSlow = controller.GetAllAudioGroupsSlow();
   Dictionary<AudioMixerEffectController, AudioMixerGroupController> effectMap = new Dictionary<AudioMixerEffectController, AudioMixerGroupController>();
   using (List<AudioMixerGroupController>.Enumerator enumerator = allAudioGroupsSlow.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       AudioMixerGroupController current = enumerator.Current;
       foreach (AudioMixerEffectController effect in current.effects)
         effectMap[effect] = current;
     }
   }
   Rect totalRect = EditorGUILayout.BeginVertical();
   if (EditorApplication.isPlaying)
   {
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     EditorGUI.BeginChangeCheck();
     GUILayout.Toggle((AudioSettings.editingInPlaymode ? 1 : 0) != 0, AudioMixerEffectView.Texts.editInPlaymode, EditorStyles.miniButton, new GUILayoutOption[1]
     {
       GUILayout.Width(120f)
     });
     if (EditorGUI.EndChangeCheck())
       AudioSettings.editingInPlaymode = !AudioSettings.editingInPlaymode;
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
   }
   EditorGUI.BeginDisabledGroup(!AudioMixerController.EditingTargetSnapshot());
   if ((UnityEngine.Object) group != (UnityEngine.Object) this.m_PrevGroup)
   {
     this.m_PrevGroup = group;
     controller.m_HighlightEffectIndex = -1;
     AudioMixerUtility.RepaintAudioMixerAndInspectors();
   }
   double num = (double) AudioMixerEffectView.DoInitialModule(group, controller, allAudioGroupsSlow);
   for (int effectIndex = 0; effectIndex < group.effects.Length; ++effectIndex)
     this.DoEffectGUI(effectIndex, group, allAudioGroupsSlow, effectMap, ref controller.m_HighlightEffectIndex);
   this.m_EffectDragging.HandleDragging(totalRect, group, controller);
   GUILayout.Space(10f);
   EditorGUILayout.BeginHorizontal();
   GUILayout.FlexibleSpace();
   if (EditorGUILayout.ButtonMouseDown(AudioMixerEffectView.Texts.addEffect, FocusType.Passive, GUISkin.current.button))
   {
     GenericMenu pm = new GenericMenu();
     Rect last = GUILayoutUtility.topLevel.GetLast();
     AudioMixerGroupController[] groups = new AudioMixerGroupController[1]{ group };
     AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groups, group.effects.Length, string.Empty, pm);
     pm.DropDown(last);
   }
   EditorGUILayout.EndHorizontal();
   EditorGUI.EndDisabledGroup();
   EditorGUILayout.EndVertical();
 }
コード例 #32
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;
            UnityType   unityType   = UnityType.FindTypeByName(typeName);
            int         num2        = (unityType == null) ? 0 : unityType.persistentTypeID;

            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_124_0 = genericMenu;
                        GUIContent  arg_124_1 = new GUIContent(resource.m_Name);
                        bool        arg_124_2 = resource.m_InstanceID == num;
                        if (AssetPopupBackend.< > f__mg$cache0 == null)
                        {
                            AssetPopupBackend.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                        }
                        arg_124_0.AddItem(arg_124_1, arg_124_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_1A6_0 = genericMenu;
                GUIContent  arg_1A6_1 = new GUIContent(defaultFieldName);
                bool        arg_1A6_2 = num == 0;
                if (AssetPopupBackend.< > f__mg$cache1 == null)
                {
                    AssetPopupBackend.< > f__mg$cache1 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                }
                arg_1A6_0.AddItem(arg_1A6_1, arg_1A6_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_23D_0 = genericMenu;
                GUIContent  arg_23D_1 = new GUIContent(hierarchyProperty.name);
                bool        arg_23D_2 = hierarchyProperty.instanceID == num;
                if (AssetPopupBackend.< > f__mg$cache2 == null)
                {
                    AssetPopupBackend.< > f__mg$cache2 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                }
                arg_23D_0.AddItem(arg_23D_1, arg_23D_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_2C7_0       = genericMenu;
                    GUIContent      arg_2C7_1       = new GUIContent(builtinResource.m_Name);
                    bool            arg_2C7_2       = builtinResource.m_InstanceID == num;
                    if (AssetPopupBackend.< > f__mg$cache3 == null)
                    {
                        AssetPopupBackend.< > f__mg$cache3 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                    }
                    arg_2C7_0.AddItem(arg_2C7_1, arg_2C7_2, AssetPopupBackend.< > f__mg$cache3, new object[]
                    {
                        builtinResource.m_InstanceID,
                        serializedProperty
                    });
                }
            }
            genericMenu.AddSeparator("");
            genericMenu.AddItem(EditorGUIUtility.TrTextContent("Create New...", null, null), false, delegate
            {
                T t = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(t, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = t;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });
            genericMenu.DropDown(buttonRect);
        }
コード例 #33
0
        internal void OnGUI()
        {
            Event e = Event.current;

            LoadIcons();

            if (!m_HasUpdatedGuiStyles)
            {
                m_LineHeight   = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight);
                m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom;
                UpdateListView();
            }

            GUILayout.BeginHorizontal(Constants.Toolbar);

            // Clear button and clearing options
            bool clearClicked = false;

            if (EditorGUILayout.DropDownToggle(ref clearClicked, Constants.Clear, EditorStyles.toolbarDropDownToggle))
            {
                var clearOnPlay      = HasFlag(ConsoleFlags.ClearOnPlay);
                var clearOnBuild     = HasFlag(ConsoleFlags.ClearOnBuild);
                var clearOnRecompile = HasFlag(ConsoleFlags.ClearOnRecompile);

                GenericMenu menu = new GenericMenu();
                menu.AddItem(Constants.ClearOnPlay, clearOnPlay, () => { SetFlag(ConsoleFlags.ClearOnPlay, !clearOnPlay); });
                menu.AddItem(Constants.ClearOnBuild, clearOnBuild, () => { SetFlag(ConsoleFlags.ClearOnBuild, !clearOnBuild); });
                menu.AddItem(Constants.ClearOnRecompile, clearOnRecompile, () => { SetFlag(ConsoleFlags.ClearOnRecompile, !clearOnRecompile); });
                var rect = GUILayoutUtility.GetLastRect();
                rect.y += EditorGUIUtility.singleLineHeight;
                menu.DropDown(rect);
            }
            if (clearClicked)
            {
                LogEntries.Clear();
                GUIUtility.keyboardControl = 0;
            }

            int  currCount = LogEntries.GetCount();
            bool showSearchNoResultMessage = currCount == 0 && !String.IsNullOrEmpty(m_SearchText);

            if (m_ListView.totalRows != currCount)
            {
                // scroll bar was at the bottom?
                if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
                {
                    m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight;
                }
            }

            bool wasCollapsed = HasFlag(ConsoleFlags.Collapse);

            SetFlag(ConsoleFlags.Collapse, GUILayout.Toggle(wasCollapsed, Constants.Collapse, Constants.MiniButton));

            bool collapsedChanged = (wasCollapsed != HasFlag(ConsoleFlags.Collapse));

            if (collapsedChanged)
            {
                // unselect if collapsed flag changed
                m_ListView.row = -1;

                // scroll to bottom
                m_ListView.scrollPos.y = LogEntries.GetCount() * RowHeight;
            }

            if (HasSpaceForExtraButtons())
            {
                SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPause, Constants.MiniButton));
                PlayerConnectionGUILayout.ConnectionTargetSelectionDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown, (int)(position.width - k_HasSpaceForExtraButtonsCutoff) + 80);
            }

            GUILayout.FlexibleSpace();

            // Search bar
            if (HasSpaceForExtraButtons())
            {
                SearchField(e);
            }

            // Flags
            int errorCount = 0, warningCount = 0, logCount = 0;

            LogEntries.GetCountsByType(ref errorCount, ref warningCount, ref logCount);
            EditorGUI.BeginChangeCheck();
            bool setLogFlag     = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton);
            bool setWarningFlag = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton);
            bool setErrorFlag   = GUILayout.Toggle(HasFlag(ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButtonRight);

            // Active entry index may no longer be valid
            if (EditorGUI.EndChangeCheck())
            {
                SetActiveEntry(null);
                m_LastActiveEntryIndex = -1;
            }

            SetFlag(ConsoleFlags.LogLevelLog, setLogFlag);
            SetFlag(ConsoleFlags.LogLevelWarning, setWarningFlag);
            SetFlag(ConsoleFlags.LogLevelError, setErrorFlag);

            GUILayout.EndHorizontal();

            if (showSearchNoResultMessage)
            {
                Rect r = new Rect(0, EditorGUI.kSingleLineHeight, ms_ConsoleWindow.position.width, ms_ConsoleWindow.position.height - EditorGUI.kSingleLineHeight);
                GUI.Box(r, m_ConsoleSearchNoResultMsg, Constants.ConsoleSearchNoResult);
            }
            else
            {
                // Console entries
                SplitterGUILayout.BeginVerticalSplit(spl);

                GUIContent tempContent      = new GUIContent();
                int        id               = GUIUtility.GetControlID(0);
                int        rowDoubleClicked = -1;

                /////@TODO: Make Frame selected work with ListViewState
                using (new GettingLogEntriesScope(m_ListView))
                {
                    int   selectedRow      = -1;
                    bool  openSelectedItem = false;
                    bool  collapsed        = HasFlag(ConsoleFlags.Collapse);
                    float scrollPosY       = m_ListView.scrollPos.y;

                    foreach (ListViewElement el in ListViewGUI.ListView(m_ListView,
                                                                        ListViewOptions.wantsRowMultiSelection, Constants.Box))
                    {
                        // Destroy latest restore entry if needed
                        if (e.type == EventType.ScrollWheel || e.type == EventType.Used)
                        {
                            DestroyLatestRestoreEntry();
                        }

                        // Make sure that scrollPos.y is always up to date after restoring last entry
                        if (m_RestoreLatestSelection)
                        {
                            m_ListView.scrollPos.y = scrollPosY;
                        }

                        if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition))
                        {
                            selectedRow = m_ListView.row;
                            DestroyLatestRestoreEntry();
                            LogEntry entry = new LogEntry();
                            LogEntries.GetEntryInternal(m_ListView.row, entry);
                            m_LastActiveEntryIndex = entry.globalLineIndex;
                            if (e.clickCount == 2)
                            {
                                openSelectedItem = true;
                            }
                        }
                        else if (e.type == EventType.Repaint)
                        {
                            int    mode = 0;
                            string text = null;
                            LogEntries.GetLinesAndModeFromEntryInternal(el.row, Constants.LogStyleLineCount, ref mode,
                                                                        ref text);
                            bool entryIsSelected = m_ListView.selectedItems != null &&
                                                   el.row < m_ListView.selectedItems.Length &&
                                                   m_ListView.selectedItems[el.row];

                            // offset value in x for icon and text
                            var offset = Constants.LogStyleLineCount == 1 ? 4 : 8;

                            // Draw the background
                            GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground;
                            s.Draw(el.position, false, false, entryIsSelected, false);

                            // Draw the icon
                            GUIStyle iconStyle = GetStyleForErrorMode(mode, true, Constants.LogStyleLineCount == 1);
                            Rect     iconRect  = el.position;
                            iconRect.x += offset;
                            iconRect.y += 2;

                            iconStyle.Draw(iconRect, false, false, entryIsSelected, false);

                            // Draw the text
                            tempContent.text = text;
                            GUIStyle errorModeStyle =
                                GetStyleForErrorMode(mode, false, Constants.LogStyleLineCount == 1);
                            var textRect = el.position;
                            textRect.x += offset;

                            if (string.IsNullOrEmpty(m_SearchText))
                            {
                                errorModeStyle.Draw(textRect, tempContent, id, m_ListView.row == el.row);
                            }
                            else if (text != null)
                            {
                                //the whole text contains the searchtext, we have to know where it is
                                int startIndex = text.IndexOf(m_SearchText, StringComparison.OrdinalIgnoreCase);
                                if (startIndex == -1
                                    ) // the searchtext is not in the visible text, we don't show the selection
                                {
                                    errorModeStyle.Draw(textRect, tempContent, id, m_ListView.row == el.row);
                                }
                                else // the searchtext is visible, we show the selection
                                {
                                    int endIndex = startIndex + m_SearchText.Length;

                                    const bool isActive = false;
                                    const bool
                                        hasKeyboardFocus =
                                        true;     // This ensure we draw the selection text over the label.
                                    const bool drawAsComposition = false;
                                    Color      selectionColor    = GUI.skin.settings.selectionColor;

                                    errorModeStyle.DrawWithTextSelection(textRect, tempContent, isActive,
                                                                         hasKeyboardFocus, startIndex, endIndex, drawAsComposition, selectionColor);
                                }
                            }

                            if (collapsed)
                            {
                                Rect badgeRect = el.position;
                                tempContent.text = LogEntries.GetEntryCount(el.row)
                                                   .ToString(CultureInfo.InvariantCulture);
                                Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent);

                                if (Constants.CountBadge.fixedHeight > 0)
                                {
                                    badgeSize.y = Constants.CountBadge.fixedHeight;
                                }
                                badgeRect.xMin  = badgeRect.xMax - badgeSize.x;
                                badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f;
                                badgeRect.x    -= 5f;
                                GUI.Label(badgeRect, tempContent, Constants.CountBadge);
                            }
                        }
                    }

                    if (selectedRow != -1)
                    {
                        if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
                        {
                            m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1;
                        }
                    }

                    // Make sure the selected entry is up to date
                    if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0)
                    {
                        if (m_ActiveText.Length != 0)
                        {
                            SetActiveEntry(null);
                            DestroyLatestRestoreEntry();
                        }
                    }
                    else
                    {
                        LogEntry entry = new LogEntry();
                        LogEntries.GetEntryInternal(m_ListView.row, entry);
                        SetActiveEntry(entry);
                        m_LastActiveEntryIndex = entry.globalLineIndex;


                        // see if selected entry changed. if so - clear additional info
                        LogEntries.GetEntryInternal(m_ListView.row, entry);
                        if (m_ListView.selectionChanged || !m_ActiveText.Equals(entry.message))
                        {
                            SetActiveEntry(entry);
                            m_LastActiveEntryIndex = entry.globalLineIndex;
                        }


                        // If copy, get the messages from selected rows
                        if (e.type == EventType.ExecuteCommand && e.commandName == EventCommandNames.Copy &&
                            m_ListView.selectedItems != null)
                        {
                            m_CopyString.Clear();
                            for (int rowIndex = 0; rowIndex < m_ListView.selectedItems.Length; rowIndex++)
                            {
                                if (m_ListView.selectedItems[rowIndex])
                                {
                                    LogEntries.GetEntryInternal(rowIndex, entry);
                                    m_CopyString.AppendLine(entry.message);
                                }
                            }
                        }
                    }

                    // Open entry using return key
                    if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) &&
                        (e.keyCode == KeyCode.Return) && (m_ListView.row != 0))
                    {
                        selectedRow      = m_ListView.row;
                        openSelectedItem = true;
                    }

                    if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1)
                    {
                        ms_LVHeight = ListViewGUI.ilvState.rectHeight;
                    }

                    if (openSelectedItem)
                    {
                        rowDoubleClicked = selectedRow;
                        e.Use();
                    }
                }

                // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been
                // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060.
                if (rowDoubleClicked != -1)
                {
                    LogEntries.RowGotDoubleClicked(rowDoubleClicked);
                }


                // Display active text (We want word wrapped text with a vertical scrollbar)
                m_TextScroll = GUILayout.BeginScrollView(m_TextScroll, Constants.Box);

                string stackWithHyperlinks = StacktraceWithHyperlinks(m_ActiveText, m_CallstackTextStart);
                float  height = Constants.MessageStyle.CalcHeight(GUIContent.Temp(stackWithHyperlinks), position.width);
                EditorGUILayout.SelectableLabel(stackWithHyperlinks, Constants.MessageStyle,
                                                GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinHeight(height + 10));

                GUILayout.EndScrollView();

                SplitterGUILayout.EndVerticalSplit();
            }

            // Copy & Paste selected item
            if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == EventCommandNames.Copy && m_CopyString != null)
            {
                if (e.type == EventType.ExecuteCommand)
                {
                    EditorGUIUtility.systemCopyBuffer = m_CopyString.ToString();
                }
                e.Use();
            }

            if (!ms_ConsoleWindow)
            {
                ms_ConsoleWindow = this;
            }
        }
コード例 #34
0
        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();
        }
コード例 #35
0
 protected void DisplayMuscleButtons()
 {
   GUILayout.BeginHorizontal(string.Empty, AvatarMuscleEditor.styles.toolbar, new GUILayoutOption[1]
   {
     GUILayout.ExpandWidth(true)
   });
   Rect rect = GUILayoutUtility.GetRect(AvatarMuscleEditor.styles.muscle, AvatarMuscleEditor.styles.toolbarDropDown);
   if (GUI.Button(rect, AvatarMuscleEditor.styles.muscle, AvatarMuscleEditor.styles.toolbarDropDown))
   {
     GenericMenu genericMenu = new GenericMenu();
     genericMenu.AddItem(AvatarMuscleEditor.styles.resetMuscle, false, new GenericMenu.MenuFunction(this.ResetMuscleToDefault));
     genericMenu.DropDown(rect);
   }
   GUILayout.FlexibleSpace();
   GUILayout.EndHorizontal();
 }
コード例 #36
0
        public void OnGUI(AudioMixerGroupController group)
        {
            if (group == null)
            {
                return;
            }

            var controller = group.controller;
            var allGroups  = controller.GetAllAudioGroupsSlow();
            var effectMap  = new Dictionary <AudioMixerEffectController, AudioMixerGroupController>();

            foreach (var g in allGroups)
            {
                foreach (var e in g.effects)
                {
                    effectMap[e] = g;
                }
            }

            Rect totalRect = EditorGUILayout.BeginVertical();

            if (EditorApplication.isPlaying)
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUI.BeginChangeCheck();
                GUILayout.Toggle(AudioSettings.editingInPlaymode, Texts.editInPlaymode, EditorStyles.miniButton, GUILayout.Width(120));
                if (EditorGUI.EndChangeCheck())
                {
                    AudioSettings.editingInPlaymode = !AudioSettings.editingInPlaymode;
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            using (new EditorGUI.DisabledScope(!AudioMixerController.EditingTargetSnapshot()))
            {
                if (group != m_PrevGroup)
                {
                    m_PrevGroup = group;
                    controller.m_HighlightEffectIndex = -1;
                    AudioMixerUtility.RepaintAudioMixerAndInspectors();
                }

                // Do Effect modules
                DoInitialModule(group, controller, allGroups);
                for (int effectIndex = 0; effectIndex < group.effects.Length; effectIndex++)
                {
                    DoEffectGUI(effectIndex, group, allGroups, effectMap, ref controller.m_HighlightEffectIndex);
                }

                m_EffectDragging.HandleDragging(totalRect, group, controller);

                GUILayout.Space(10f);

                EditorGUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();
                if (EditorGUILayout.DropdownButton(Texts.addEffect, FocusType.Passive, GUISkin.current.button))
                {
                    GenericMenu pm         = new GenericMenu();
                    Rect        buttonRect = GUILayoutUtility.topLevel.GetLast();
                    AudioMixerGroupController[] groupArray = new AudioMixerGroupController[] { group };
                    AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groupArray, group.effects.Length, string.Empty, pm);
                    pm.DropDown(buttonRect);
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
        }
コード例 #37
0
        private static void OnBottomToolbarGUI(int windowID)
        {
            GUILayout.BeginHorizontal();

            // For debugging frame rate
            //			GUILayout.Label(((int)(1 / csgModel.CurrentFrameDelta)).ToString(), SabreGUILayout.GetLabelStyle());

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

                string[] names = Enum.GetNames(typeof(PrimitiveBrushType));

                for (int i = 0; i < names.Length; i++)
                {
                    if(names[i] != "Custom")
                    {
                        menu.AddItem (new GUIContent (names[i]), false, OnSelectedCreateOption, Enum.Parse(typeof(PrimitiveBrushType), names[i]));
                    }
                }

                menu.DropDown(createRect);
            }

            if (Event.current.type == EventType.Repaint)
            {
                createRect = GUILayoutUtility.GetLastRect();
                createRect.width = 100;
            }

            if (SabreGUILayout.Button("Rebuild"))
            {
                csgModel.Build();
            }

            // DISABLED as no longer necessary - CurrentSettings.Optimizations = (Optimizations)EditorGUILayout.EnumMaskField(CurrentSettings.Optimizations, GUILayout.Width(100));

            bool lastBrushesHidden = CurrentSettings.BrushesHidden;
            if(lastBrushesHidden)
            {
                GUI.color = Color.red;
            }
            CurrentSettings.BrushesHidden = SabreGUILayout.Toggle(CurrentSettings.BrushesHidden, "Brushes Hidden");
            if (CurrentSettings.BrushesHidden != lastBrushesHidden)
            {
                // Has changed
                csgModel.UpdateBrushVisibility();
                SceneView.RepaintAll();
            }

            GUI.color = Color.white;
            bool lastMeshHidden = CurrentSettings.MeshHidden;
            if(lastMeshHidden)
            {
                GUI.color = Color.red;
            }
            CurrentSettings.MeshHidden = SabreGUILayout.Toggle(CurrentSettings.MeshHidden, "Mesh Hidden");
            if (CurrentSettings.MeshHidden != lastMeshHidden)
            {
                // Has changed
                csgModel.UpdateBrushVisibility();
                SceneView.RepaintAll();
            }

            GUI.color = Color.white;

            if(GUILayout.Button("Grid " + CurrentSettings.GridMode.ToString(), EditorStyles.toolbarDropDown, GUILayout.Width(90)))
            {
                GenericMenu menu = new GenericMenu ();

                string[] names = Enum.GetNames(typeof(GridMode));

                for (int i = 0; i < names.Length; i++)
                {
                    GridMode value = (GridMode)Enum.Parse(typeof(GridMode),names[i]);
                    bool selected = false;
                    if(CurrentSettings.GridMode == value)
                    {
                        selected = true;
                    }
                    menu.AddItem (new GUIContent (names[i]), selected, OnSelectedGridOption, value);
                }

                menu.DropDown(gridRect);
            }

            if (Event.current.type == EventType.Repaint)
            {
                gridRect = GUILayoutUtility.GetLastRect();
                gridRect.width = 100;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Line Two
            GUILayout.BeginHorizontal();

            // Display brush count
            GUILayout.Label(csgModel.BrushCount.ToStringWithSuffix(" brush", " brushes"), SabreGUILayout.GetLabelStyle());
            //			CurrentSettings.GridMode = (GridMode)EditorGUILayout.EnumPopup(CurrentSettings.GridMode, EditorStyles.toolbarPopup, GUILayout.Width(80));

            if (Selection.activeGameObject != null)
            {
                Brush brush = Selection.activeGameObject.GetComponent<Brush>();
                if (brush != null)
                {
                    CSGMode brushMode = (CSGMode)EditorGUILayout.EnumPopup(brush.Mode, EditorStyles.toolbarPopup, GUILayout.Width(80));
                    if(brushMode != brush.Mode)
                    {
                        Undo.RecordObject(brush, "Change Brush Mode To " + brushMode);

                        brush.Mode = brushMode;
                    }

                    bool isDetailBrush = SabreGUILayout.Toggle(brush.IsDetailBrush, "Detail", GUILayout.Width(53));
                    bool hasCollision = SabreGUILayout.Toggle(brush.HasCollision, "Collision", GUILayout.Width(53));
                    bool isVisible = SabreGUILayout.Toggle(brush.IsVisible, "Visible", GUILayout.Width(53));

                    if(brush.IsDetailBrush != isDetailBrush)
                    {
                        Undo.RecordObject(brush, "Change Brush Detail Mode");
                        brush.IsDetailBrush = isDetailBrush;
                    }
                    if(brush.HasCollision != hasCollision)
                    {
                        Undo.RecordObject(brush, "Change Brush Collision Mode");
                        brush.HasCollision = hasCollision;
                    }
                    if(brush.IsVisible != isVisible)
                    {
                        Undo.RecordObject(brush, "Change Brush Visible Mode");
                        brush.IsVisible = isVisible;
                    }
                }
            }

            GUILayout.Space(10);

            // Position snapping UI
            CurrentSettings.PositionSnappingEnabled = SabreGUILayout.Toggle(CurrentSettings.PositionSnappingEnabled, "Pos Snapping");
            CurrentSettings.PositionSnapDistance = EditorGUILayout.FloatField(CurrentSettings.PositionSnapDistance, GUILayout.Width(50));

            if (SabreGUILayout.Button("-", EditorStyles.miniButtonLeft))
            {
                CurrentSettings.ChangePosSnapDistance(.5f);
            }
            if (SabreGUILayout.Button("+", EditorStyles.miniButtonRight))
            {
                CurrentSettings.ChangePosSnapDistance(2f);
            }

            // Rotation snapping UI
            CurrentSettings.AngleSnappingEnabled = SabreGUILayout.Toggle(CurrentSettings.AngleSnappingEnabled, "Ang Snapping");
            CurrentSettings.AngleSnapDistance = EditorGUILayout.FloatField(CurrentSettings.AngleSnapDistance, GUILayout.Width(50));

            if (SabreGUILayout.Button("-", EditorStyles.miniButtonLeft))
            {
                CurrentSettings.ChangeAngSnapDistance(.5f);
            }
            if (SabreGUILayout.Button("+", EditorStyles.miniButtonRight))
            {
                CurrentSettings.ChangeAngSnapDistance(2f);
            }

            // Disabled test build options
            //			CurrentSettings.RestoreOriginalPolygons = SabreGUILayout.Toggle(CurrentSettings.RestoreOriginalPolygons, "Restore Original Polygons", GUILayout.Width(153));
            //			CurrentSettings.RemoveHiddenGeometry = SabreGUILayout.Toggle(CurrentSettings.RemoveHiddenGeometry, "Remove Hidden Geometry", GUILayout.Width(153));

            GUILayout.FlexibleSpace();

            if (CurrentSettings.CurrentMode != MainMode.Free)
            {
                if( Tools.current == UnityEditor.Tool.View && Tools.viewTool == ViewTool.Pan)
                {
                    GUI.color = Color.yellow;
                }
            }

            if (SabreGUILayout.Button("Disable"))
            {
                Selection.activeGameObject = null;
                csgModel.EditMode = false;
            }

            GUILayout.EndHorizontal();
        }
コード例 #38
0
 private void AutoCompute()
 {
   if (this.m_BlendType.intValue == 0)
   {
     EditorGUILayout.PropertyField(this.m_UseAutomaticThresholds, EditorGUIUtility.TempContent("Automate Thresholds"), new GUILayoutOption[0]);
     this.m_ShowCompute.target = !this.m_UseAutomaticThresholds.boolValue;
   }
   else if (this.m_BlendType.intValue == 4)
     this.m_ShowCompute.target = false;
   else
     this.m_ShowCompute.target = true;
   this.m_ShowAdjust.target = this.AllMotions();
   if (EditorGUILayout.BeginFadeGroup(this.m_ShowCompute.faded))
   {
     Rect position = EditorGUI.PrefixLabel(EditorGUILayout.GetControlRect(), 0, this.ParameterCount != 1 ? EditorGUIUtility.TempContent("Compute Positions") : EditorGUIUtility.TempContent("Compute Thresholds"));
     if (EditorGUI.ButtonMouseDown(position, EditorGUIUtility.TempContent("Select"), FocusType.Passive, EditorStyles.popup))
     {
       GenericMenu menu = new GenericMenu();
       if (this.ParameterCount == 1)
       {
         this.AddComputeMenuItems(menu, string.Empty, BlendTreeInspector.ChildPropertyToCompute.Threshold);
       }
       else
       {
         menu.AddItem(new GUIContent("Velocity XZ"), false, new GenericMenu.MenuFunction(this.ComputePositionsFromVelocity));
         menu.AddItem(new GUIContent("Speed And Angular Speed"), false, new GenericMenu.MenuFunction(this.ComputePositionsFromSpeedAndAngularSpeed));
         this.AddComputeMenuItems(menu, "X Position From/", BlendTreeInspector.ChildPropertyToCompute.PositionX);
         this.AddComputeMenuItems(menu, "Y Position From/", BlendTreeInspector.ChildPropertyToCompute.PositionY);
       }
       menu.DropDown(position);
     }
   }
   EditorGUILayout.EndFadeGroup();
   if (EditorGUILayout.BeginFadeGroup(this.m_ShowAdjust.faded))
   {
     Rect position = EditorGUI.PrefixLabel(EditorGUILayout.GetControlRect(), 0, EditorGUIUtility.TempContent("Adjust Time Scale"));
     if (EditorGUI.ButtonMouseDown(position, EditorGUIUtility.TempContent("Select"), FocusType.Passive, EditorStyles.popup))
     {
       GenericMenu genericMenu = new GenericMenu();
       genericMenu.AddItem(new GUIContent("Homogeneous Speed"), false, new GenericMenu.MenuFunction(this.ComputeTimeScaleFromSpeed));
       genericMenu.AddItem(new GUIContent("Reset Time Scale"), false, new GenericMenu.MenuFunction(this.ResetTimeScale));
       genericMenu.DropDown(position);
     }
   }
   EditorGUILayout.EndFadeGroup();
 }
コード例 #39
0
		private void DrawToolbar(GUIStyle buttonStyle, GUIStyle buttonDropdownStyle) {
			
			var result = GUILayout.Button("Create", buttonDropdownStyle);
			if (Event.current.type == EventType.Repaint) {
				
				this.layoutStateToolbarCreateButtonRect = GUILayoutUtility.GetLastRect();
				
			}

			if (result == true) {
				
				var menu = new GenericMenu();
				this.SetupCreateMenu(string.Empty, menu);
				
				menu.DropDown(this.layoutStateToolbarCreateButtonRect);
				
			}
			
			result = GUILayout.Button("Tools", buttonDropdownStyle);
			if (Event.current.type == EventType.Repaint) {
				
				this.layoutStateToolbarToolsButtonRect = GUILayoutUtility.GetLastRect();
				
			}

			if (result == true) {
				
				var menu = new GenericMenu();
				this.SetupToolsMenu(string.Empty, menu);
				
				menu.DropDown(this.layoutStateToolbarToolsButtonRect);
				
			}
			
			Flow.OnDrawToolbarGUI(this, buttonStyle);
			
			GUILayout.FlexibleSpace();
			
			var oldColor = GUI.color;
			var c = Color.cyan;
			c.a = 0.3f;
			GUI.color = c;
			GUILayout.Label(string.Format("Version: {1}. Current Data: {0}", AssetDatabase.GetAssetPath(FlowSystem.GetData()), VersionInfo.BUNDLE_VERSION), buttonStyle);
			GUI.color = oldColor;
			
			if (GUILayout.Button("Change", buttonStyle) == true) {
				
				this.ChangeFlowData();
				
			}
			
		}
コード例 #40
0
ファイル: BTEditorWindow.cs プロジェクト: mbbarange/hivemind
        public void ShowContextMenu(Vector2 point, Node node)
        {
            if (Application.isPlaying) {
                return;
            }

            var menu = new GenericMenu();

            if (node == null || node.CanConnectChild) {

                // Add new node
                string addMsg = (node == null ? "Add" : "Add Child") + "/";

                // List all available node subclasses
                int length = BehaviorTree.NodeTypes.Length;
                for ( int i = 0; i < length; i++ ) {
                    menu.AddItem (
                        new GUIContent(addMsg + BehaviorTree.NodeTypes[i]),
                        false,
                        Add,
                        new MenuAction(node, point, BehaviorTree.NodeTypes[i])
                        );
                }

            } else {
                menu.AddDisabledItem(new GUIContent("Add"));
            }

            if (node == null) {
                menu.AddSeparator ("");
                menu.AddItem (new GUIContent("Save"), false, Save, null);
            }

            menu.AddSeparator ("");

            // Node actions
            if (node != null) {

                // Connect/Disconnect Parent
                if (!(node is Root)) {
                    if (node.parent != null)
                        menu.AddItem(new GUIContent("Disconnect from Parent"), false, Unparent, new MenuAction(node));
                    else
                        menu.AddItem(new GUIContent("Connect to Parent"), false, ConnectParent, new MenuAction(node));
                }

                menu.AddSeparator ("");

                // Connect Child
                if (node.CanConnectChild)
                    menu.AddItem(new GUIContent("Connect to Child"), false, ConnectChild, new MenuAction(node));
                else
                    menu.AddDisabledItem(new GUIContent("Connect to Child"));

                menu.AddSeparator ("");

                // Deleting
                if (node is Root)
                    menu.AddDisabledItem(new GUIContent("Delete"));
                else
                    menu.AddItem(new GUIContent("Delete"), false, Delete, new MenuAction(node));

            }

            menu.DropDown(new Rect(point.x, point.y, 0, 0));
        }
コード例 #41
0
ファイル: ClothInspector.cs プロジェクト: randomize/VimConfig
        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);
        }
コード例 #42
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);
        }
コード例 #43
0
		private void DrawToolbar(GUIStyle buttonStyle) {
			
			var result = GUILayout.Button("Create", buttonStyle);
			var rect = GUILayoutUtility.GetLastRect();
			
			if (result == true) {
				
				var menu = new GenericMenu();
				this.SetupCreateMenu(string.Empty, menu);
				
				menu.DropDown(new Rect(rect.x, rect.y + TOOLBAR_HEIGHT, rect.width, rect.height));
				
			}
			
			result = GUILayout.Button("Tools", buttonStyle);
			rect = GUILayoutUtility.GetLastRect();
			
			if (result == true) {
				
				var menu = new GenericMenu();
				this.SetupToolsMenu(string.Empty, menu);
				
				menu.DropDown(new Rect(rect.x, rect.y + TOOLBAR_HEIGHT, rect.width, rect.height));
				
			}
			
			Flow.OnDrawToolbarGUI(this, buttonStyle);
			
			GUILayout.FlexibleSpace();
			
			var oldColor = GUI.color;
			GUI.color = Color.gray;
			GUILayout.Label(string.Format("Current Data: {0}", AssetDatabase.GetAssetPath(this.guiSplash.cachedData)), buttonStyle);
			GUI.color = oldColor;
			
			if (GUILayout.Button("Change", buttonStyle) == true) {
				
				this.ChangeFlowData();
				
			}
			
		}
コード例 #44
0
 private static void ShowEffectContextMenu(AudioMixerGroupController group, AudioMixerEffectController effect, int effectIndex, AudioMixerController controller, Rect buttonRect)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   AudioMixerEffectView.\u003CShowEffectContextMenu\u003Ec__AnonStorey63 menuCAnonStorey63 = new AudioMixerEffectView.\u003CShowEffectContextMenu\u003Ec__AnonStorey63();
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey63.effect = effect;
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey63.controller = controller;
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey63.group = group;
   // ISSUE: reference to a compiler-generated field
   menuCAnonStorey63.effectIndex = effectIndex;
   GenericMenu pm = new GenericMenu();
   // ISSUE: reference to a compiler-generated field
   if (!menuCAnonStorey63.effect.IsReceive())
   {
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     if (!menuCAnonStorey63.effect.IsAttenuation() && !menuCAnonStorey63.effect.IsSend() && !menuCAnonStorey63.effect.IsDuckVolume())
     {
       // ISSUE: reference to a compiler-generated field
       // ISSUE: reference to a compiler-generated method
       pm.AddItem(new GUIContent("Allow Wet Mixing (causes higher memory usage)"), menuCAnonStorey63.effect.enableWetMix, new GenericMenu.MenuFunction(menuCAnonStorey63.\u003C\u003Em__AA));
       // ISSUE: reference to a compiler-generated field
       // ISSUE: reference to a compiler-generated method
       pm.AddItem(new GUIContent("Bypass"), menuCAnonStorey63.effect.bypass, new GenericMenu.MenuFunction(menuCAnonStorey63.\u003C\u003Em__AB));
       pm.AddSeparator(string.Empty);
     }
     // ISSUE: reference to a compiler-generated method
     pm.AddItem(new GUIContent("Copy effect settings to all snapshots"), false, new GenericMenu.MenuFunction(menuCAnonStorey63.\u003C\u003Em__AC));
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     if (!menuCAnonStorey63.effect.IsAttenuation() && !menuCAnonStorey63.effect.IsSend() && (!menuCAnonStorey63.effect.IsDuckVolume() && menuCAnonStorey63.effect.enableWetMix))
     {
       // ISSUE: reference to a compiler-generated method
       pm.AddItem(new GUIContent("Copy effect settings to all snapshots, including wet level"), false, new GenericMenu.MenuFunction(menuCAnonStorey63.\u003C\u003Em__AD));
     }
     pm.AddSeparator(string.Empty);
   }
   // ISSUE: reference to a compiler-generated field
   AudioMixerGroupController[] groups = new AudioMixerGroupController[1]{ menuCAnonStorey63.group };
   // ISSUE: reference to a compiler-generated field
   // ISSUE: reference to a compiler-generated field
   AudioMixerChannelStripView.AddEffectItemsToMenu(menuCAnonStorey63.controller, groups, menuCAnonStorey63.effectIndex, "Add effect before/", pm);
   // ISSUE: reference to a compiler-generated field
   // ISSUE: reference to a compiler-generated field
   AudioMixerChannelStripView.AddEffectItemsToMenu(menuCAnonStorey63.controller, groups, menuCAnonStorey63.effectIndex + 1, "Add effect after/", pm);
   // ISSUE: reference to a compiler-generated field
   if (!menuCAnonStorey63.effect.IsAttenuation())
   {
     pm.AddSeparator(string.Empty);
     // ISSUE: reference to a compiler-generated method
     pm.AddItem(new GUIContent("Remove this effect"), false, new GenericMenu.MenuFunction(menuCAnonStorey63.\u003C\u003Em__AE));
   }
   pm.DropDown(buttonRect);
 }
コード例 #45
0
        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);
        }
コード例 #46
0
 private static void ShowBusPopupMenu(int effectIndex, AudioMixerGroupController group, List<AudioMixerGroupController> allGroups, Dictionary<AudioMixerEffectController, AudioMixerGroupController> effectMap, AudioMixerEffectController effect, Rect buttonRect)
 {
   GenericMenu pm = new GenericMenu();
   pm.AddItem(new GUIContent("None"), false, new GenericMenu.MenuFunction2(AudioMixerChannelStripView.ConnectSendPopupCallback), (object) new AudioMixerChannelStripView.ConnectSendContext(effect, (AudioMixerEffectController) null));
   pm.AddSeparator(string.Empty);
   AudioMixerChannelStripView.AddMenuItemsForReturns(pm, string.Empty, effectIndex, group, allGroups, effectMap, effect, true);
   if (pm.GetItemCount() == 2)
     pm.AddDisabledItem(new GUIContent("No valid Receive targets found"));
   pm.DropDown(buttonRect);
 }
コード例 #47
0
ファイル: LMExtendedWindow.cs プロジェクト: damard/Unity
    private bool BakeButton(params GUILayoutOption[] options)
    {
        GUIContent content = new GUIContent (ObjectNames.NicifyVariableName (bakeMode.ToString ()));

        Rect dropdownRect = GUILayoutUtility.GetRect (content, (GUIStyle)"DropDownButton", options);
        Rect buttonRect = dropdownRect;
        buttonRect.xMin = buttonRect.xMax - 20;
        if (Event.current.type != EventType.MouseDown || !buttonRect.Contains (Event.current.mousePosition))
            return GUI.Button (dropdownRect, content, (GUIStyle)"DropDownButton");
        GenericMenu genericMenu = new GenericMenu ();
        string[] names = Enum.GetNames (typeof(BakeMode));
        int num1 = Array.IndexOf<string> (names, Enum.GetName (typeof(BakeMode), this.bakeMode));
        int num2 = 0;
        foreach (string text in Enumerable.Select<string, string> (names, x => ObjectNames.NicifyVariableName(x))) {
            genericMenu.AddItem (new GUIContent (text), num2 == num1, new GenericMenu.MenuFunction2 (this.BakeDropDownCallback), num2++);
        }
        genericMenu.DropDown (dropdownRect);
        Event.current.Use ();
        return false;
    }
コード例 #48
0
 private void ShowLODGUI()
 {
     this.m_ShowSmoothLODOptions.target = (this.m_EnableSmoothLOD.hasMultipleDifferentValues || this.m_EnableSmoothLOD.boolValue);
     GUILayout.Label(SpeedTreeImporterInspector.Styles.LODHeader, EditorStyles.boldLabel, new GUILayoutOption[0]);
     if (!Application.HasAdvancedLicense())
     {
         EditorGUILayout.HelpBox("LOD only available in Unity Pro", MessageType.Warning);
         return;
     }
     EditorGUILayout.PropertyField(this.m_EnableSmoothLOD, SpeedTreeImporterInspector.Styles.SmoothLOD, new GUILayoutOption[0]);
     EditorGUI.indentLevel++;
     if (EditorGUILayout.BeginFadeGroup(this.m_ShowSmoothLODOptions.faded))
     {
         EditorGUILayout.Slider(this.m_BillboardTransitionCrossFadeWidth, 0f, 1f, SpeedTreeImporterInspector.Styles.CrossFadeWidth, new GUILayoutOption[0]);
         EditorGUILayout.Slider(this.m_FadeOutWidth, 0f, 1f, SpeedTreeImporterInspector.Styles.FadeOutWidth, new GUILayoutOption[0]);
     }
     EditorGUILayout.EndFadeGroup();
     EditorGUI.indentLevel--;
     EditorGUILayout.Space();
     if (this.HasSameLODConfig())
     {
         EditorGUILayout.Space();
         Rect rect = GUILayoutUtility.GetRect(0f, 30f, new GUILayoutOption[]
         {
             GUILayout.ExpandWidth(true)
         });
         List <LODGroupGUI.LODInfo> lODInfoArray = this.GetLODInfoArray(rect);
         this.DrawLODLevelSlider(rect, lODInfoArray);
         EditorGUILayout.Space();
         EditorGUILayout.Space();
         if (this.m_SelectedLODRange != -1 && lODInfoArray.Count > 0)
         {
             EditorGUILayout.LabelField(lODInfoArray[this.m_SelectedLODRange].LODName + " Options", EditorStyles.boldLabel, new GUILayoutOption[0]);
             bool flag = this.m_SelectedLODRange == lODInfoArray.Count - 1 && this.importers[0].hasBillboard;
             if (!flag)
             {
                 EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("castShadows"), SpeedTreeImporterInspector.Styles.CastShadows, new GUILayoutOption[0]);
                 EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("receiveShadows"), SpeedTreeImporterInspector.Styles.ReceiveShadows, new GUILayoutOption[0]);
             }
             SerializedProperty serializedProperty = this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("useLightProbes");
             EditorGUILayout.PropertyField(serializedProperty, SpeedTreeImporterInspector.Styles.UseLightProbes, new GUILayoutOption[0]);
             if (!serializedProperty.hasMultipleDifferentValues && serializedProperty.boolValue && flag)
             {
                 EditorGUILayout.HelpBox("Enabling Light Probe for billboards breaks batched rendering and may cause performance problem.", MessageType.Warning);
             }
             EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("enableBump"), SpeedTreeImporterInspector.Styles.EnableBump, new GUILayoutOption[0]);
             EditorGUILayout.PropertyField(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("enableHue"), SpeedTreeImporterInspector.Styles.EnableHue, new GUILayoutOption[0]);
             int num = this.importers.Min((SpeedTreeImporter im) => im.bestWindQuality);
             if (num > 0)
             {
                 if (flag)
                 {
                     num = ((num < 1) ? 0 : 1);
                 }
                 EditorGUILayout.Popup(this.m_LODSettings.GetArrayElementAtIndex(this.m_SelectedLODRange).FindPropertyRelative("windQuality"), (
                                           from s in SpeedTreeImporter.windQualityNames.Take(num + 1)
                                           select new GUIContent(s)).ToArray <GUIContent>(), SpeedTreeImporterInspector.Styles.WindQuality, new GUILayoutOption[0]);
             }
         }
     }
     else
     {
         if (this.CanUnifyLODConfig())
         {
             EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayout.FlexibleSpace();
             Rect rect2 = GUILayoutUtility.GetRect(SpeedTreeImporterInspector.Styles.ResetLOD, EditorStyles.miniButton);
             if (GUI.Button(rect2, SpeedTreeImporterInspector.Styles.ResetLOD, EditorStyles.miniButton))
             {
                 GenericMenu genericMenu = new GenericMenu();
                 foreach (SpeedTreeImporter current in base.targets.Cast <SpeedTreeImporter>())
                 {
                     string text = string.Format("{0}: {1}", Path.GetFileNameWithoutExtension(current.assetPath), string.Join(" | ", (
                                                                                                                                  from height in current.LODHeights
                                                                                                                                  select string.Format("{0:0}%", height * 100f)).ToArray <string>()));
                     genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.OnResetLODMenuClick), current);
                 }
                 genericMenu.DropDown(rect2);
             }
             EditorGUILayout.EndHorizontal();
         }
         Rect rect3 = GUILayoutUtility.GetRect(0f, 30f, new GUILayoutOption[]
         {
             GUILayout.ExpandWidth(true)
         });
         if (Event.current.type == EventType.Repaint)
         {
             LODGroupGUI.DrawMixedValueLODSlider(rect3);
         }
     }
     EditorGUILayout.Space();
 }