public virtual void DoGUI() { var list = GetSortedList((T)this); var count = list.Count(); using (new GUILayout.HorizontalScope()) { GUILayout.Label($"{label}: "); currentIdx = GUILayout.Toolbar(currentIdx, list.Select(ins => ins.name).ToArray()); } var current = list.ElementAt(Mathf.Min(currentIdx, count - 1)); var isTop = list.First() == current; var tmp = GUI.enabled; GUI.enabled = isTop; using (var h = new GUILayout.HorizontalScope()) { GUILayout.Space(16f); using (var v = new GUILayout.VerticalScope()) { current.DoGUIInternal(); } } GUI.enabled = tmp; }
protected override void NodeGUI() { using (var hscope = new GUILayout.HorizontalScope()) { clip = RTEditorGUI.ObjectField <AnimationClip>("Animation Clip", clip, true); } }
protected override void OnGUIInternal() { using (var h = new GUILayout.HorizontalScope()) { using (var v = new GUILayout.VerticalScope(GUILayout.MinWidth(300f))) { _miscFolds.OnGUI(); _dynamicFoldEnable = GUILayout.Toggle(_dynamicFoldEnable, "DynamicFold"); _dynamicFolds.OnGUI(); _int = GUIUtil.IntButton(_int, "IntButton"); GUIUtil.Indent(() => { GUILayout.Label("Indent"); }); using (var cs = new GUIUtil.ColorScope(Color.green)) { GUILayout.Label("ColorScope"); } } _fieldFolds.OnGUI(); _sliderFolds.OnGUI(); } }
private void RegisteredListenersList() { using (GUILayout.HorizontalScope h = new GUILayout.HorizontalScope("ToolbarButton")) { GUILayout.Label("Registered Listeners"); } if (!Application.isPlaying) { using (GUILayout.VerticalScope v = new GUILayout.VerticalScope(GameEventStyles.Box, GUILayout.Height(21))) GUILayout.Label("All GameEventListeners registered to this event. Populated at runtime."); } else { using (GUILayout.ScrollViewScope s = new GUILayout.ScrollViewScope(_listenersScrollPosition, GameEventStyles.Box)) { _listenersScrollPosition = s.scrollPosition; if (_listeners.Count == 0) { GUILayout.Label("No GameEventListeners are registered to this event."); } for (int i = 0; i < _listeners.Count; i++) { GUIStyle style = i % 2 == 0 ? GameEventStyles.ListBackgroundEven : GameEventStyles.ListBackgroundOdd; if (GUILayout.Button(_listeners[i].gameObject.name, style)) { Selection.activeObject = _listeners[i]; } } } } }
public void Start() { _miscFold.Add("Fold0", () => { GUILayout.Label("Fold0"); }); _miscFold.Add("Fold1", () => { GUILayout.Label("Fold1 FirstAdd"); }); _miscFold.Add("Fold1", () => { GUILayout.Label("Fold1 SecondAdd"); }); _miscFold.Add(-1, "FoldCustomOrder", () => { GUILayout.Label("FoldCustomOrder"); }); _miscFold.Add("IDebugMenu", typeof(IDebugMenuSample)); _dynamicFold.Add("DynamicFold", () => _dynamicFoldEnable, () => { GUILayout.Label("DynamicFold"); }); _fieldFold.Add("Field", () => { _enum = GUIUtil.Field(_enum, "enum"); _string = GUIUtil.Field(_string, "string"); _bool = GUIUtil.Field(_bool, "bool"); _int = GUIUtil.Field(_int, "int"); _float = GUIUtil.Field(_float, "float"); _vector2 = GUIUtil.Field(_vector2, "vector2"); _vector3 = GUIUtil.Field(_vector3, "vector3"); _vector4 = GUIUtil.Field(_vector4, "vector4"); _rect = GUIUtil.Field(_rect, "rect"); }); _fieldFold.Add("FieldWithUnparsedStr", () => { _int = GUIUtil.Field(_int, ref _intStr, "int"); _float = GUIUtil.Field(_float, ref _floatStr, "float"); _vector2 = GUIUtil.Field(_vector2, ref _vector2Str, "vector2"); _vector3 = GUIUtil.Field(_vector3, ref _vector3Str, "vector3"); _vector4 = GUIUtil.Field(_vector4, ref _vector4Str, "vector4"); _rect = GUIUtil.Field(_rect, ref _rectStr, "rect"); }, true); _sliderFold.Add("Slider", () => { _int = GUIUtil.Slider(_int, 0, 100, "Slider(int)"); _float = GUIUtil.Slider(_float, "Slider(float)"); using (var h = new GUILayout.HorizontalScope()) { GUILayout.Label("hoge"); GUILayout.HorizontalSlider(0f, 0f, 1f, GUILayout.MinWidth(200f)); GUILayout.TextField("hoge", GUILayout.MaxWidth(100f)); } _vector2 = GUIUtil.Slider(_vector2, Vector2.zero, Vector2.one, "Slider(Vector2)"); _vector3 = GUIUtil.Slider(_vector3, Vector3.zero, Vector3.one, "Slider(Vector3)"); _vector4 = GUIUtil.Slider(_vector4, Vector4.zero, Vector4.one, "Slider(Vector4)"); _rect = GUIUtil.Slider(_rect, Rect.zero, new Rect(1f, 1f, 1f, 1f), "Slider(Rect)"); }); _sliderFold.Add("SliderWithUnparsedStr", () => { _int = GUIUtil.Slider(_int, 0, 100, ref _intStr, "Slider(int)"); _float = GUIUtil.Slider(_float, ref _floatStr, "Slider(float)"); _vector2 = GUIUtil.Slider(_vector2, Vector2.zero, Vector2.one, ref _vector2Str, "Slider(Vector2)"); _vector3 = GUIUtil.Slider(_vector3, Vector3.zero, Vector3.one, ref _vector3Str, "Slider(Vector3)"); _vector4 = GUIUtil.Slider(_vector4, Vector4.zero, Vector4.one, ref _vector4Str, "Slider(Vector4)"); _rect = GUIUtil.Slider(_rect, Rect.zero, new Rect(1f, 1f, 1f, 1f), ref _rectStr, "Slider(Rect)"); }, true); }
void LabelWithEditPrefix(PrefsGUISync sync, string label, Object target, List <PrefsParam> prefsList) { using (var h = new GUILayout.HorizontalScope()) { SyncToggleList(sync, prefsList); GUILayout.Label(label); const char separator = '.'; var prefix = prefsList.Select(p => p.key.Split(separator)).Where(sepKeys => sepKeys.Length > 1).FirstOrDefault()?.First(); GUILayout.Label("KeyPrefix:"); var prefixNew = GUILayout.TextField(prefix, GUILayout.MinWidth(100f)); if (prefix != prefixNew) { Undo.RecordObject(target, "Change PrefsGUI Prefix"); EditorUtility.SetDirty(target); var prefixWithSeparator = string.IsNullOrEmpty(prefixNew) ? "" : prefixNew + separator; prefsList.ForEach(p => { p.key = prefixWithSeparator + p.key.Split(separator).Last(); }); } GUILayout.FlexibleSpace(); } }
public override void OnInspectorGUI() { #if KAITOOL_EDITOR serializedObject.Update(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); var guiStyle0 = new GUIStyle(); guiStyle0.fixedWidth = 20f; using (var verticalScope = new GUILayout.HorizontalScope(guiStyle0)) { EditorGUILayout.BeginVertical(); if (GUILayout.Button("P")) { m_transform.localPosition = Vector3.zero; } if (GUILayout.Button("R")) { m_transform.localRotation = Quaternion.identity; } if (GUILayout.Button("S")) { m_transform.localScale = Vector3.one; } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginVertical(); m_editor.OnInspectorGUI(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); #else m_editor.OnInspectorGUI(); #endif serializedObject.ApplyModifiedProperties(); }
public void DrawWindow() { windowTitle = eventName = EditorGUILayout.TextField(eventName); eventDescription = EditorGUILayout.TextArea(eventDescription, GUILayout.Height(100)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add Choice")) { ChoiceWindow temp = CreateInstance <ChoiceWindow>(); temp.Init(new Rect(6, 160, 252, 280)); choices.Add(temp); ChoiceAdded = true; } if (GUILayout.Button("Remove All")) { choices.Clear(); AllRemoved = true; } GUILayout.EndHorizontal(); using (GUILayout.HorizontalScope scope = new GUILayout.HorizontalScope()) { for (int i = 0; i < choices.Count; i++) { if (i > 0) { choices[i].windowRect.x = choices[i - 1].windowRect.x + choices[i - 1].windowRect.width + 5; } choices[i].DrawWindow(); } } }
public override void OnDrawScrollArea() { float width = (position.width - 80) * 0.5f; foreach (var item in fixerDatas) { using (var vertical = new GUILayout.VerticalScope("box")) { using (var horizon = new GUILayout.HorizontalScope()) { item.fix = EditorGUILayout.ToggleLeft(GUIContent.none, item.fix, GUILayout.Width(20)); // GUILayout.Label($"Missing GameObject in {(isViewState ? "State" : "Page")} : [{(isViewState ? item.originalNotFoundItem.viewState.name : item.originalNotFoundItem.viewPage.name)}], Under ViewElement : [{item.originalNotFoundItem.viewPageItem.viewElement.name}]"); GUILayout.Label($"{item.originalNotFoundItem.stateOrPageName} ({(item.originalNotFoundItem.isViewState ? "State" : "Page")})"); GUILayout.Label(Drawer.arrowIcon); GUILayout.Label($"{item.originalNotFoundItem.viewElement.name} (ViewElement)"); } item.tempPath = EditorGUILayout.TextField("Transform Path", item.tempPath); if (item.originalNotFoundItem.viewElement.transform.Find(item.tempPath) == null) { GUILayout.Label(new GUIContent($"[{item.tempPath}] is not a vaild Path in target ViewElement", Drawer.miniErrorIcon), GUILayout.Height(EditorGUIUtility.singleLineHeight)); } else { GUILayout.Label(new GUIContent($"Good! GameObject can be found with the input Path"), GUILayout.Height(EditorGUIUtility.singleLineHeight)); } item.delete = EditorGUILayout.ToggleLeft("This item is nolonger in use, help me delete it.(You also need to check the checkbox on the lefttop)", item.delete); } } }
public virtual void DebugMenu() { enabled = GUILayout.Toggle(enabled, "LatencyChckerLine"); if (enabled) { GUIUtil.Indent(() => { _width = GUIUtil.Slider(_width, 0f, 20f, "width"); using (var h = new GUILayout.HorizontalScope()) { _timeEnable = GUILayout.Toggle(_timeEnable, "Time"); _timeStride = GUIUtil.Slider(_timeStride, 0.1f, 10f, "Stride"); } using (var h = new GUILayout.HorizontalScope()) { _networkTimeEnable = GUILayout.Toggle(_networkTimeEnable, "NetworkTime"); _networkTimeStride = GUIUtil.Slider(_networkTimeStride, 0.1f, 10f, "Stride"); } DebugMenuInternal(); _datas.ForEach(data => { using (var h = new GUILayout.HorizontalScope()) { data.enable = GUILayout.Toggle(data.enable, data.name); data.mode = GUIUtil.Field(data.mode); } }); }); } }
/// <summary> /// ヘッダー描画 /// </summary> private void DrawHeader() { //using (var v = new GUILayout.VerticalScope()) { // ボタン一覧 using (var h = new GUILayout.HorizontalScope()) { float buttonSize = 30f; // 戻る using (var d = new DisabledScope(hasPageHistory == false)) { if (GUILayout.Button("←", GUILayout.Width(buttonSize), GUILayout.Height(buttonSize))) { OpenPage(PageBack); } } // スペース GUILayout.FlexibleSpace(); // 閉じる if (GUILayout.Button("×", GUILayout.Width(buttonSize), GUILayout.Height(buttonSize))) { this.Close(); } } } }
public void OnGUI(Action <T> elementGUI, Func <T> createNewElement = null, string label = null) { GUILayout.Label(label ?? key); GUIUtil.Indent(() => { var list = Get() ?? new List <T>(); list.ForEach(elem => { using (var h = new GUILayout.HorizontalScope()) { elementGUI(elem); } }); using (var h = new GUILayout.HorizontalScope()) { if (GUILayout.Button("Add")) { var elem = (createNewElement != null) ? createNewElement() : Activator.CreateInstance <T>(); list.Add(elem); } if (GUILayout.Button("Remove")) { list.RemoveAt(list.Count - 1); } Set(list); OnGUIDefaultButton(); } }); }
public bool OnGUI() { var ret = false; var drawFuncs = _funcDatas.Where(fd => fd._checkEnable == null || fd._checkEnable()).Select(fd => fd._draw).ToList(); if (drawFuncs.Any()) { var foldStr = _foldOpen ? "▼" : "▶"; using (var h = new GUILayout.HorizontalScope()) { _foldOpen ^= GUILayout.Button(foldStr + _name, Style.FoldoutPanelStyle); _titleAction?.Invoke(); } if (_foldOpen) { using (var v = new GUILayout.VerticalScope("window")) { ret = drawFuncs.Aggregate(false, (changed, drawFunc) => changed || drawFunc()); } } } return(ret); }
private void OnGUI() { using (var horizon = new GUILayout.HorizontalScope()) { if (GUILayout.Button(new GUIContent("Open with Unity Doc Generator", "Open Unity Doc Generator for more detail settings"))) { DocGeneratorWindow.OpenWindow(); DocGeneratorWindow.currentSelectPath = packagePath; } string p1 = System.IO.Path.Combine(packagePath, DocGeneratorWindow.settingFile); string p2 = System.IO.Path.Combine(packagePath, DocGeneratorWindow.DocFxProject); bool isSettingExsit = System.IO.File.Exists(p1); bool isDocFxDocumentExsit = System.IO.Directory.Exists(p2); bool buildDirectAvailable = !(isSettingExsit && isDocFxDocumentExsit); using (var disable = new EditorGUI.DisabledGroupScope(buildDirectAvailable)) { if (GUILayout.Button(new GUIContent("Generate Doc with last setting", "Require the package has generate document using UnityDocGenerator before"))) { DocGeneratorWindow.OpenWindow(); DocGeneratorWindow.currentSelectPath = System.IO.Path.GetFullPath(packageInfo.assetPath); DocGeneratorWindow.Instance.Docfx(); } } } }
private void OnGUI() { using (var hor = new GUILayout.HorizontalScope()) { if (GUILayout.Button("PopUpPanel -string[]")) { UIFacade.Instence.Open(PanelNames.PopUpPanel, new string[] { "你好", "这是一个提示面板!" }); } if (GUILayout.Button("PopUpPanel -enum network")) { var handle = UIFacade.Instence.Open(PanelNames.PopUpPanel, NetWorkInfos.OnNetError); handle.RegistCallBack((panel, data) => { Debug.Log("call back :" + data); }); } if (GUILayout.Button("PopUpPanel -enum file")) { UIFacade.Instence.Open(PanelNames.PopUpPanel, FileInfos.FileAlreadyExists); } if (GUILayout.Button("PopUpPanel -dic")) { var table = new Hashtable(); table["title"] = "标题 - HashTable"; table["info"] = "信息 - HashTable"; table["donthide"] = false; UIFacade.Instence.Open(PanelNames.PopUpPanel, table); } } }
///<summary> ///Use this for draw window. ///</summary> void OnGUI() { m_format = (ImageFormat)EditorGUILayout.EnumPopup("Format", m_format); m_customResolution = EditorGUILayout.ToggleLeft("Custom Resolution", m_customResolution); using (var hz = new GUILayout.HorizontalScope()) { EditorGUI.indentLevel++; m_imageWidth = EditorGUILayout.IntField(m_imageWidth); GUILayout.Label("x", GUILayout.ExpandWidth(false)); m_imageHeight = EditorGUILayout.IntField(m_imageHeight); EditorGUI.indentLevel--; } if (GUILayout.Button("Take")) { string path = ChooseSavePath(); if (!string.IsNullOrEmpty(path)) { var tex = CreateTexture(); ScreenShot.TakeCameraImage(Camera.main, tex); var bytes = EncodeImage(tex); SafeDestroy(tex); System.IO.File.WriteAllBytes(path, bytes); } } }
void RenderObjectWindow(int id) { using (var horizontalScope = new GUILayout.HorizontalScope("box")) { x = GUILayout.TextField(x); y = GUILayout.TextField(y); z = GUILayout.TextField(z); } Vector3 pos = new Vector3(); bool success = true; if (float.TryParse(x, out pos.x) && float.TryParse(y, out pos.y) && float.TryParse(z, out pos.z)) { _testObject.transform.position = pos; } else { success = false; } GUILayout.Label(success ? "everything ok!" : "Parsing failed! check input!"); GUILayout.Space(10); GUILayout.Label(SessionManagerStatic.Instance ? "SessionManagerStatic instantiated." : "SessionManagerStatic not instantiated!"); if (SessionManagerStatic.Instance) { GUILayout.Label( $"{SessionManagerStatic.Instance.AssetCollection.Models.Assets.Count} assets loaded in AssetCollection"); _assetToSpawnId = GUILayout.TextField(_assetToSpawnId); if (GUILayout.Button("Spawn Asset")) { if (_testObject) { GameObject.Destroy(_testObject); } _testObject = GameObject.Instantiate(_assetToSpawnId == "" ? SessionManagerStatic.Instance.AssetCollection.Models.DefaultValue : SessionManagerStatic.Instance.AssetCollection.Models.Find(_assetToSpawnId)); } // IEnumerable<ModelAsset> model = // SessionManagerStatic.Instance.AssetCollection.Models.Assets.Where(asset => // asset.AssetID == "workplaces/tables/bld_tinker_tier01"); // // SessionManagerStatic.Instance.AssetCollection.Models.Find("workplaces/tables/bld_tinker_tier01"); } GUI.DragWindow(); }
static object SliderFuncRect(object v, object min, object max, ref string unparsedStr, string label = "", string[] elemLabels = null) { const int elementNum = 4; var eLabels = elemLabels ?? defaultElemLabelsRect; using (var h0 = new GUILayout.HorizontalScope()) { if (!string.IsNullOrEmpty(label)) { GUILayout.Label(label); } using (var vertical = new GUILayout.VerticalScope()) { var strs = SplitUnparsedStr(unparsedStr, elementNum); var rect = (Rect)v; var rectMin = (Rect)min; var rectMax = (Rect)max; rect.x = Slider(rect.x, rectMin.x, rectMax.x, ref strs[0], eLabels[0]); rect.y = Slider(rect.y, rectMin.y, rectMax.y, ref strs[1], eLabels[1]); rect.width = Slider(rect.width, rectMin.width, rectMax.width, ref strs[2], eLabels[2]); rect.height = Slider(rect.height, rectMin.height, rectMax.height, ref strs[3], eLabels[3]); v = rect; unparsedStr = JoinUnparsedStr(strs); } } return(v); }
static object SliderFuncVector <T, ElemType>(object v, object min, object max, ref string unparsedStr, string label = "", string[] elemLabels = null) { var vec = new AbstractVector(v); var minVec = new AbstractVector(min); var maxVec = new AbstractVector(max); var elementNum = vec.GetElementNum(); var eLabels = elemLabels ?? defaultElemLabelsVector; using (var h0 = new GUILayout.HorizontalScope()) { if (!string.IsNullOrEmpty(label)) { GUILayout.Label(label); } using (var vertical = new GUILayout.VerticalScope()) { var strs = SplitUnparsedStr(unparsedStr, elementNum); for (var i = 0; i < elementNum; ++i) { using (var h1 = new GUILayout.HorizontalScope()) { var elem = Slider((ElemType)vec[i], (ElemType)minVec[i], (ElemType)maxVec[i], ref strs[i], eLabels[i]); vec[i] = elem; } } unparsedStr = JoinUnparsedStr(strs); } } return(v); }
private void OnGUI() { fpsAccumulator++; if (Time.realtimeSinceStartup > fpsNextPeriod) { currentFps = (int)(fpsAccumulator / fpsMeasurePeriod); fpsAccumulator = 0; fpsNextPeriod += fpsMeasurePeriod; } using (var scope = new GUILayout.HorizontalScope()) { GUILayout.Box(string.Format("FPS:[{0}] ", currentFps)); if (Networker.IsConnected) { GUILayout.Box(string.Format("Delay:[{0}]ms ", Networker.PingTime)); } GUILayout.Box(string.Format("UsedHeapSize:[{0}]", LongToMb(Profiler.usedHeapSizeLong))); GUILayout.Box(string.Format("Reserved:[{0}]", LongToMb(Profiler.GetTotalReservedMemoryLong()))); GUILayout.Box(string.Format("Used:[{0}]", LongToMb(Profiler.GetTotalAllocatedMemoryLong()))); GUILayout.Box(string.Format("Unused:[{0}]", LongToMb(Profiler.GetTotalUnusedReservedMemoryLong()))); GUILayout.Box(string.Format("MonoHeapSize:[{0}]", LongToMb(Profiler.GetMonoHeapSizeLong()))); GUILayout.Box(string.Format("MonoUsed:[{0}]", LongToMb(Profiler.GetMonoUsedSizeLong()))); } if (showConsole) { windowRect = GUILayout.Window(123456, windowRect, ConsoleWindow, "Console"); } }
public static void DrawPresetButton(MonoBehaviour owner, ClothParams clothParam) { using (var horizontalScope = new GUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel); GUI.backgroundColor = Color.green; if (EditorGUILayout.DropdownButton(new GUIContent("Preset"), FocusType.Keyboard, GUILayout.Width(70), GUILayout.Height(16))) { CreatePresetPopupMenu(owner, clothParam); GUI.backgroundColor = Color.white; GUIUtility.ExitGUI(); } GUI.backgroundColor = Color.white; if (GUILayout.Button("Save", GUILayout.Width(40), GUILayout.Height(16))) { SavePreset(owner, clothParam); GUIUtility.ExitGUI(); } if (GUILayout.Button("Load", GUILayout.Width(40), GUILayout.Height(16))) { LoadPreset(owner, clothParam); GUIUtility.ExitGUI(); } } }
override public void OnInspectorGUI() { var creepData = (CreepData)target; DrawDefaultInspector(); //EditorGUILayout.TextField("Creep Name",creepData.Name); //EditorGUILayout.ObjectField("Prefab", creepData.Prefab, typeof(GameObject), false); //EditorGUILayout.Space(); //EditorGUILayout.LabelField("PARAMETERS"); EditorGUILayout.Space(); using (var horizontalScope = new GUILayout.HorizontalScope()) { creepData.changeMesh = GUILayout.Toggle(creepData.changeMesh, "Custom Mesh"); creepData.changeMaterial = GUILayout.Toggle(creepData.changeMaterial, "Custom Material"); creepData.changeTexture = GUILayout.Toggle(creepData.changeTexture, "Custom Texture"); } if (creepData.changeMesh) { creepData.Mesh = EditorGUILayout.ObjectField("Mesh", creepData.Mesh, typeof(Mesh), false) as Mesh; } if (creepData.changeMaterial) { creepData.Material = EditorGUILayout.ObjectField("Material", creepData.Material, typeof(Material), false) as Material; } if (creepData.changeTexture) { creepData.Texture = EditorGUILayout.ObjectField("Texture", creepData.Texture, typeof(Texture2D), false) as Texture2D; } }
private void DoDiscordWindow(int windowId) { GUISkinUtils.RenderWithSkin(SetGUIStyle(), () => { using (GUILayout.VerticalScope v = new GUILayout.VerticalScope("Box")) { using (GUILayout.HorizontalScope h = new GUILayout.HorizontalScope()) { GUILayout.Label(avatar); GUILayout.Label("<b>" + Request.username + "</b> wants to join your server."); } using (GUILayout.HorizontalScope b = new GUILayout.HorizontalScope()) { if (GUILayout.Button("Accept")) { CloseWindow(1); } if (GUILayout.Button("Deny")) { CloseWindow(0); } } } }); }
static object SliderFuncVector <T>(object v, object min, object max, ref string unparsedStr, string label = "", string[] elemLabels = null) { var elementNum = AbstractVector.GetElementNum <T>(); var eLabels = elemLabels ?? defaultElemLabelsVector; using (var h0 = new GUILayout.HorizontalScope()) { if (!string.IsNullOrEmpty(label)) { GUILayout.Label(label); } using (var vertical = new GUILayout.VerticalScope()) { var strs = SplitUnparsedStr(unparsedStr, elementNum); for (var i = 0; i < elementNum; ++i) { using (var h1 = new GUILayout.HorizontalScope()) { var elem = Slider(AbstractVector.GetAtIdx <T>(v, i), AbstractVector.GetAtIdx <T>(min, i), AbstractVector.GetAtIdx <T>(max, i), ref strs[i], eLabels[i]); v = AbstractVector.SetAtIdx <T>(v, i, elem); } } unparsedStr = JoinUnparsedStr(strs); } } return(v); }
/// <summary> /// 任意の型を描画する. /// </summary> /// <typeparam name="T">描画する型.</typeparam> /// <param name="label">ラベル.</param> /// <param name="value">現在値.</param> /// <returns>GUIからの入力値.</returns> protected T Draw <T>(string label, ref T value) { using (var horizon = new GUILayout.HorizontalScope()) { GUILayout.Label(label); return(this.TextField(ref value)); } }
/// <summary> /// <see cref="bool"/>型を描画する. /// </summary> /// <param name="label">ラベル.</param> /// <param name="value">現在値.</param> /// <returns>GUIからの入力値.</returns> protected bool Draw(string label, ref bool value) { using (var horizon = new GUILayout.HorizontalScope()) { GUILayout.Label(label); return(value = GUILayout.Toggle(value, "")); } }
public override void OnInspectorGUI() { serializedObject.Update(); var target = this.target as ValueData; showOrders = EditorGUILayout.Foldout(showOrders, "Orders"); if (showOrders) { using (var cHorizontalScope = new GUILayout.HorizontalScope()) { GUILayout.Space(EditorGUI.indentLevel * 15 + 4); using (var cVerticalScope = new GUILayout.VerticalScope()) { EditorGUILayout.LabelField("Value modifiers are executed in these orders"); foreach (var orderData in target.orders) { if (!this.cache.TryGetValue(orderData, out var cache)) { cache = new CacheData(target.GetByFullName(orderData.valueName).modifiers); this.cache.Add(orderData, cache); cache.drawer.displayAdd = false; cache.drawer.displayRemove = false; cache.drawer.headerHeight = 1; cache.drawer.onReorderCallbackWithDetails = (ReorderableList list, int oldIndex, int newIndex) => { // Restore old state var moved = list.list[newIndex]; list.list.RemoveAt(newIndex); list.list.Insert(oldIndex, moved); EditorUtility.SetDirty(target); Undo.RegisterCompleteObjectUndo(target, "Modified list"); // Restore new state list.list.RemoveAt(oldIndex); list.list.Insert(newIndex, moved); target.Validate(); }; } cache.showPosition = EditorGUILayout.BeginFoldoutHeaderGroup(cache.showPosition, orderData.valueName); if (cache.showPosition) { cache.drawer.DoLayoutList(); } EditorGUILayout.EndFoldoutHeaderGroup(); } } } } EditorGUILayout.EndFoldoutHeaderGroup(); serializedObject.ApplyModifiedProperties(); }
static public void OnFolder(ref bool foldOpen, string name = null) { var foldStr = foldOpen ? "▼" : "▶"; using (var h = new GUILayout.HorizontalScope()) { foldOpen ^= GUILayout.Button(foldStr + name, Style.FoldoutPanelStyle); } }
static public void OnGUI(ref bool toggle, string displayName = null) { var op = new[] { GUILayout.MinWidth(70f) }; using (var h = new GUILayout.HorizontalScope()) { toggle = GUILayout.Toggle(toggle, displayName == null ? "bool" : displayName); } }
private void DrawInfoPanel() { GUIStyle textBackground = new GUIStyle(GUI.skin.GetStyle("WindowBackground")); Handles.BeginGUI(); { Rect labelRect = new Rect(10, _editorUIRect.y - 30, _screenWidth - 25, _buttonHeight + 4); GUIStyle toolbarStyle = new GUIStyle(EditorStyles.toolbar); toolbarStyle.fixedHeight = _buttonHeight + 8; toolbarStyle.fixedWidth = labelRect.width; GUILayout.BeginArea(labelRect, toolbarStyle); { GUIStyle boldLabelStyle = new GUIStyle(EditorStyles.boldLabel); boldLabelStyle.alignment = TextAnchor.UpperLeft; using (var hl = new GUILayout.HorizontalScope()) { GUILayout.Label(_toolsLabel, boldLabelStyle); int selectedMode = GUILayout.Toolbar((int)_interactionMode, _interactionModeLabels, GUILayout.Height(_buttonHeight)); if (selectedMode != (int)_interactionMode) { SwitchToMode((ToolInteractionMode)selectedMode); } } } GUILayout.EndArea(); GUILayout.BeginArea(_editorUIRect, textBackground); { using (var horizontalLayout = new GUILayout.HorizontalScope()) { switch (_interactionMode) { case ToolInteractionMode.VIEW: { DrawViewModeInfo(); break; } case ToolInteractionMode.PAINT: { DrawPaintModeInfo(); break; } case ToolInteractionMode.EDIT: { DrawEditModeInfo(); break; } } } } GUILayout.EndArea(); } Handles.EndGUI(); }