第三节 高级的控件 Checkbox单选和多选、dropdownlis下拉列表、listbox列表框、progressbar进度条、richtextlabel富文本、slider滑块、textbox输入框、scrollbar滚动条。 3.1、Checkbox单选和多选 先来显示如下的内容: 设置如下: Checked 表示当前是否选中的状态;。 Text的内容是Label对象的内容自动获取的, 为什么只需要设...
public const string id = "ExampleToolbar/Dropdown"; static string dropChoice = null; public DropdownExample() { text = "Axis"; clicked += ShowDropdown; } void ShowDropdown() { var menu = new GenericMenu(); menu.AddItem(new GUIContent("X"), dropChoice == "X", () => { text =...
UnityEditor.EditorWindowwindow=GetWindow(typeof(EditorGUIExample));window.position=newRect(0,0,150,60);window.Show();} voidOnGUI(){ showPosition=EditorGUI.Foldout(newRect(3,3,position.width-6,15),showPosition,status);if(showPosition)if(Selection.activeTransform){ Selection.activeTransform.position...
EditorGUI.DropdownButton public static boolDropdownButton(Rectposition,GUIContentcontent,FocusTypefocusType); public static boolDropdownButton(Rectposition,GUIContentcontent,FocusTypefocusType,GUIStylestyle); 参数 position屏幕上用于按钮的矩形。 content该按钮的文本、图像和工具提示。
So, what I do is my UI elements are prefabs (for example, the dropdown). Those have the script below attached to them and the eventonValueChangedof the Dropdown component has the below methodOnValueChangedassigned. Whatever instantiates the button prefab will pass through the logic of ...
4.7 Dropdown Dropdown 提供选择的选项列表. 可以为每个选项指定文本字符串和可选的图像,可以在Inspector检查器中设置,也可以从代码中动态设置. 改变时触发OnValueChanged 4.8 Input Field 输入框,有两个unityevent 4.9 Scroll Rect (Scroll View) 当占用大量空间的内容需要在一个小区域中显示时,可以使用它。滚动条提...
GetWindow(typeof(EditorGUILayoutOtherExample)); window.Show(); } #region DropdownButton private string m_itemString = ""; #endregion #region EnumMaskField public enum Example { Option_One = 1, //bits: 0000 0001 Option_Two = 2, //bits: 0000 0010 Option_Three = 4 //bits: 0000 0100...
GenericMenu lets you create custom context menus and dropdown menus. The example below opens an Editor window with a button. Clicking the button displays a context menu, which lets you change the color to apply to the GUI in the window. Copy the example's contents into a script called Gene...
You can replace yourGenericMenuwith aDropdownMenueverywhere. For example, you can use it withEditorGUI.DropdownButton(). The dropdown window will look like this: More Info DropdownItem Once the number of items pass a certain threshold (10 items by default), a search bar will show up where...
public override void OnInspectorGUI() { // Update the serializedProperty - always do this in the beginning of OnInspectorGUI. serializedObject.Update(); // Show the custom GUI controls. EditorGUILayout.IntSlider(damageProp, 0, 100, new GUIContent("Damage")); ...