public static void DoReorderableList <TSetting>(TSetting setting, IList list, Type listType, ref UnityEditorInternal.ReorderableList mReorderableList, ref Vector2 mReorderableScrollPosition, ref Vector2 mSettingsScrollPosition, UnityEditorInternal.ReorderableList.ElementCallbackDelegate drawElementCallback = null, Action enableAction = null, Action disableAction = null) where TSetting : ScriptableObject { if (mReorderableList == null) { mReorderableList = new UnityEditorInternal.ReorderableList(list, listType, true, false, false, false); mReorderableList.headerHeight = 0; mReorderableList.showDefaultBackground = false; mReorderableList.drawElementCallback = drawElementCallback; } QuickEditorGUIStaticAPI.Space(); using (new QuickEditorGUILayout.HorizontalBlock()) { QuickEditorGUIStaticAPI.Space(); if (GUILayout.Button(EditorGUIUtility.FindTexture("Toolbar Plus"), GUIStyle.none, GUILayout.Width(16))) { list.Add(Activator.CreateInstance(listType)); mReorderableList.index = list.Count - 1; mReorderableList.GrabKeyboardFocus(); mSettingsScrollPosition.y = float.MaxValue; } QuickEditorGUIStaticAPI.Space(); if (GUILayout.Button(EditorGUIUtility.FindTexture("Toolbar Minus"), GUIStyle.none, GUILayout.Width(16))) { if (mReorderableList.index >= 0 && mReorderableList.index <= list.Count - 1) { Undo.RecordObject(setting, "Removed Import Preset"); list.RemoveAt(mReorderableList.index); mReorderableList.index = Mathf.Max(0, mReorderableList.index - 1); mReorderableList.GrabKeyboardFocus(); } } QuickEditorGUIStaticAPI.FlexibleSpace(); if (enableAction != null) { QuickEditorGUIStaticAPI.Button("Enable.All", EditorStyles.miniButtonRight, () => { enableAction(); }); } if (disableAction != null) { QuickEditorGUIStaticAPI.Button("Disable.All", EditorStyles.miniButtonLeft, () => { disableAction(); }); } } //QEditorGUIStaticAPI.Space(); QuickEditorGUIStaticAPI.DrawRect(EditorGUILayout.GetControlRect(false, 2), QuickEditorColors.WhiteCoffee); using (var scroll = new EditorGUILayout.ScrollViewScope(mReorderableScrollPosition)) { mReorderableScrollPosition = scroll.scrollPosition; mReorderableList.DoLayoutList(); } }
private void OnGUI() { using (var check = new EditorGUI.ChangeCheckScope()) { renderer = EditorGUILayout.ObjectField( "SkinnedMeshRenderer", renderer, typeof(SkinnedMeshRenderer), true ) as SkinnedMeshRenderer; if (check.changed) { if (renderer != null) { shapeKeyNames = GetBlendShapeListFromRenderer(renderer); selectedShapeKeys = new bool[shapeKeyNames.Count()]; } } } if (shapeKeyNames != null) { isOpenedBlendShape = EditorGUILayout.Foldout(isOpenedBlendShape, "Shape Keys"); if (isOpenedBlendShape) { using (new EditorGUI.IndentLevelScope()) using (var scroll = new EditorGUILayout.ScrollViewScope(shapeKeyScrollPos, GUI.skin.box)) { shapeKeyScrollPos = scroll.scrollPosition; for (int i = 0; i < shapeKeyNames.Count(); i++) { selectedShapeKeys[i] = EditorGUILayout.ToggleLeft(shapeKeyNames[i], selectedShapeKeys[i]); } } } } using (new EditorGUI.DisabledScope(renderer == null || (selectedShapeKeys != null && selectedShapeKeys.All(x => !x)))) { if (GUILayout.Button("Delete ShapeKeys")) { // 選択されている要素のインデックスの配列 var selectedBlendShapeIndexs = selectedShapeKeys .Select((isSelect, index) => new { Index = index, Value = isSelect }) .Where(x => x.Value) .Select(x => x.Index) .ToArray(); DeleteShapeKey(renderer, selectedBlendShapeIndexs); shapeKeyNames = GetBlendShapeListFromRenderer(renderer); selectedShapeKeys = new bool[shapeKeyNames.Count()]; } } }
private void OnGUI() { using (new EditorGUILayout.HorizontalScope()) { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.LabelField("", GUILayout.Width(50)); EditorGUILayout.LabelField("Model"); EditorGUILayout.LabelField("Animation"); EditorGUILayout.LabelField("PortraitSheet"); EditorGUILayout.LabelField("BaseFormModelName"); EditorGUILayout.LabelField("WalkSpeedDistance"); } } var names = _rom.GetCommonStrings().Pokemon; var formDbEntries = _rom.GetPokemonFormDatabase().Entries; var graphicsDbEntries = _rom.GetPokemonGraphicsDatabase().Entries; using (var scrollView = new EditorGUILayout.ScrollViewScope(_scrollPos)) { _scrollPos = scrollView.scrollPosition; for (int i = 0; i < formDbEntries.Count; i++) { var formDbEntry = formDbEntries[i]; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(40)); EditorGUILayout.LabelField(((CreatureIndex)i + 1).ToString(), EditorStyles.boldLabel, GUILayout.Width(150)); EditorGUILayout.LabelField($"({names[(CreatureIndex) i+1]})", EditorStyles.boldLabel); } foreach (var graphicsDatabaseEntryId in formDbEntry.PokemonGraphicsDatabaseEntryIds) { if (graphicsDatabaseEntryId == 0 || graphicsDatabaseEntryId + 1 >= graphicsDbEntries.Count) { continue; } using (new EditorGUI.IndentLevelScope()) { using (new EditorGUILayout.HorizontalScope()) { var entry = graphicsDbEntries[graphicsDatabaseEntryId - 1]; EditorGUILayout.LabelField((graphicsDatabaseEntryId - 1).ToString(), GUILayout.Width(50)); EditorGUILayout.LabelField(entry.ModelName); EditorGUILayout.LabelField(entry.AnimationName); EditorGUILayout.LabelField(entry.PortraitSheetName); EditorGUILayout.LabelField(entry.BaseFormModelName); EditorGUILayout.LabelField(entry.WalkSpeedDistance.ToString()); } } } } } }
public void OnGUI() { if (AddSchemaDirButton == null) { AddSchemaDirButton = new GUIContent(EditorGUIUtility.IconContent("Toolbar Plus")) { tooltip = "Add schema directory" }; RemoveSchemaDirButton = new GUIContent(EditorGUIUtility.IconContent("Toolbar Minus")) { tooltip = "Remove schema directory" }; } using (new EditorGUILayout.VerticalScope()) using (var scroll = new EditorGUILayout.ScrollViewScope(scrollPosition)) using (var check = new EditorGUI.ChangeCheckScope()) { using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { var canSave = configErrors.Count > 0; using (new EditorGUI.DisabledScope(canSave)) { if (GUILayout.Button(SaveConfigurationButtonText, EditorStyles.toolbarButton)) { toolsConfig.Save(); } } if (GUILayout.Button(ResetConfigurationButtonText, EditorStyles.toolbarButton)) { if (EditorUtility.DisplayDialog("Confirmation", "Are you sure you want to reset to defaults?", "Yes", "No")) { toolsConfig.ResetToDefault(); } } } DrawCodeGenerationOptions(); DrawCustomSnapshotDir(); if (check.changed) { configErrors = toolsConfig.Validate(); } scrollPosition = scroll.scrollPosition; } foreach (var error in configErrors) { EditorGUILayout.HelpBox(error, MessageType.Error); } }
private void OnGUI() { DrawObjectField(); using (var scroll = new EditorGUILayout.ScrollViewScope(scrollPos)) { scrollPos = scroll.scrollPosition; SwitchDrawOption(); } }
public void OnGUI() { levelNumber = EditorGUILayout.IntField("LevelNumber", levelNumber); if (GUILayout.Button("Load")) { levelData = Load(levelNumber); } if (levelData != null) { var size = EditorGUILayout.Vector2IntField("Size", levelData.stage.size); if (size != levelData.stage.size) { levelData.stage.ChangeSize(size); } using (var scrollScope = new EditorGUILayout.ScrollViewScope(scrollPos)) { for (int y = 0; y < size.y; ++y) { using (new EditorGUILayout.HorizontalScope()) { for (int x = 0; x < size.x; ++x) { using (new EditorGUILayout.VerticalScope(GUI.skin.box, GUILayout.Width(50f))) { var panel = levelData.stage[x, y]; using (new GUIBackgroundColorScope(ContentColor(panel))) { panel.type = (Enums.EPanelType)EditorGUILayout.EnumPopup((Enums.EPanelType)panel.type); panel.color = (Enums.EPanelColor)EditorGUILayout.EnumPopup((Enums.EPanelColor)panel.color); } if (panel.type == Enums.EPanelType.WALL) { panel.adjacentWallPattern = levelData.stage.GetAdjacentWallPattern(x, y); } panel.color = AdjustmentColor(panel); levelData.stage[x, y] = panel; } } } } scrollPos = scrollScope.scrollPosition; } } if (GUILayout.Button("Initialize")) { levelData.stage.Initialize(); } if (GUILayout.Button("Save")) { levelData.number = levelNumber; Save(levelNumber, levelData); } }
void OnGUI() { OnDragAndDropUI(); if (_targets == null || _targets.Count == 0) { EditorGUILayout.LabelField("Source assets is empty. Drag and Drop here."); return; } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Source assets", GUILayout.Width(80)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Clear", GUILayout.Width(80))) { _targets.Clear(); } } using (var scroll = new EditorGUILayout.ScrollViewScope(_scrollPos)) { _scrollPos = scroll.scrollPosition; foreach (var item in _targets) { EditorGUILayout.ObjectField(item, typeof(Object), false); } } using (var check = new EditorGUI.ChangeCheckScope()) { _folder = (DefaultAsset)EditorGUILayout.ObjectField("To", _folder, typeof(DefaultAsset), false); if (check.changed && _folder != null) { string assetPath = AssetDatabase.GetAssetPath(_folder); EditorUserSettings.SetConfigValue(Key_LastFolderPath, assetPath); } } using (new EditorGUI.DisabledScope(_folder == null || _targets.Count == 0)) { if (GUILayout.Button("Move")) { foreach (var target in _targets) { if (target == null) { continue; } string oldPath = AssetDatabase.GetAssetPath(target); string fileName = Path.GetFileName(oldPath); string newPath = Path.Combine(AssetDatabase.GetAssetPath(_folder), fileName); Debug.Log($"[Move] from {oldPath}. to {newPath}"); AssetDatabase.MoveAsset(oldPath, newPath); } } } EditorGUILayout.Space(); }
public override void OnGUI(string searchContext) { if (AddSchemaDirButton == null) { AddSchemaDirButton = new GUIContent(EditorGUIUtility.IconContent("Toolbar Plus")) { tooltip = "Add schema directory" }; RemoveSchemaDirButton = new GUIContent(EditorGUIUtility.IconContent("Toolbar Minus")) { tooltip = "Remove schema directory" }; } using (new EditorGUILayout.VerticalScope()) using (var scroll = new EditorGUILayout.ScrollViewScope(scrollPosition)) using (var check = new EditorGUI.ChangeCheckScope()) { DrawGeneralSection(); DrawCodeGenerationOptions(); DrawCustomSnapshotDir(); if (check.changed) { configErrors = toolsConfig.Validate(); if (configErrors.Count == 0) { hasUnsavedData = true; } } GUILayout.Space(10f); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(ResetConfigurationButtonText, EditorStyles.miniButtonMid, GUILayout.Width(150)) && EditorUtility.DisplayDialog("Confirmation", "Are you sure you want to reset to defaults?", "Yes", "No")) { GUI.FocusControl(null); toolsConfig.ResetToDefault(); } GUILayout.FlexibleSpace(); } scrollPosition = scroll.scrollPosition; } foreach (var error in configErrors) { EditorGUILayout.HelpBox(error, MessageType.Error); } }
private void DrawWindow() { using (var scrollScope = new EditorGUILayout.ScrollViewScope(_windowScrollPosition)) { GUILayout.Space(4.0f); _itemsReorderableList.DoLayoutList(); _windowScrollPosition = scrollScope.scrollPosition; } }
private void OnGUI() { using (var scrollScope = new EditorGUILayout.ScrollViewScope(_scrollPosition)) { _scrollPosition = scrollScope.scrollPosition; EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); _serializedObject = _serializedObject ?? new SerializedObject(ClickerSettings.Instance); _serializedObject.UpdateIfRequiredOrScript(); SerializedProperty iterator = _serializedObject.GetIterator(); EditorGUILayout.LabelField("Options", EditorStyles.boldLabel); for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { if (Array.IndexOf(_propertyBlacklist, iterator.propertyPath) == -1) { EditorGUILayout.PropertyField(iterator, true); } } _serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { ClickerSettings.Instance.Save(); } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Debug Values", EditorStyles.boldLabel); _debugOpen = EditorGUILayout.Foldout(_debugOpen, "Debug"); if (_debugOpen) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.PropertyField(_serializedObject.FindProperty("ClickerComponentGUIDContainers"), true); EditorGUILayout.PropertyField(_serializedObject.FindProperty("ClickerComponentAssetGUIDs"), true); _runtimeListOpen = EditorGUILayout.Foldout(_runtimeListOpen, "Runtime DB"); if (_runtimeListOpen) { EditorGUI.indentLevel++; foreach (KeyValuePair <Guid, ClickerComponent> kvp in ClickerComponent.RuntimeLookup) { EditorGUILayout.LabelField("Key", kvp.Key.ToString()); EditorGUILayout.ObjectField("Value", kvp.Value, typeof(ClickerComponent), false); } EditorGUI.indentLevel--; } } } } }
private void DrawSelectionPopup() { GUILayout.Space(6); using (var scope = new EditorGUILayout.ScrollViewScope(_scrollPos, EditorStyles.helpBox)) { _selectedIndex = GUILayout.SelectionGrid(_selectedIndex, _searchResults, 1); _scrollPos = scope.scrollPosition; } }
public override void OnGUI(Rect rect) { if (elements == null) { return; } using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.Height(15f))) { if (GUILayout.Button(toolbarPlusIcon, EditorStyles.toolbarButton, GUILayout.Width(50f))) { elements.Add(elementType.GetDefaultValue()); OnUpdateElements(); } GUILayout.FlexibleSpace(); } using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition)) { var removeIndexs = new List <int>(); for (var i = 0; i < elements.Count; i++) { using (new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginChangeCheck(); elements[i] = EditorRecordFieldUtility.DrawRecordField(elements[i], elementType); if (EditorGUI.EndChangeCheck()) { OnUpdateElements(); } if (GUILayout.Button(toolbarMinusIcon, GUILayout.Width(20f))) { removeIndexs.Add(i); } } } if (removeIndexs.Any()) { foreach (var removeIndex in removeIndexs) { elements.RemoveAt(removeIndex); } OnUpdateElements(); } scrollPosition = scrollViewScope.scrollPosition; } }
private void DoList() { using (var scrollView = new EditorGUILayout.ScrollViewScope(m_ScrollPosition)) { m_ScrollPosition = scrollView.scrollPosition; EditorGUI.BeginChangeCheck(); string valueName = null; object value = null; foreach (var kvp in m_EditorPrefsLookup) { valueName = kvp.Key; value = kvp.Value; if (IsFiltering && !valueName.ToLower().Contains(m_Filter.ToLower())) { continue; } // Strings are encoded as utf8 bytes var bytes = value as byte[]; if (bytes != null) { string valueAsString = Encoding.UTF8.GetString(bytes); EditorGUI.BeginChangeCheck(); string newString = EditorGUILayout.DelayedTextField(StripValueNameHash(valueName), valueAsString); if (EditorGUI.EndChangeCheck()) { value = Encoding.UTF8.GetBytes(newString); break; } } else if (value is int) { int valueAsInt = (int)value; EditorGUI.BeginChangeCheck(); int newInt = EditorGUILayout.DelayedIntField(StripValueNameHash(valueName), valueAsInt); if (EditorGUI.EndChangeCheck()) { value = newInt; break; } } else { EditorGUILayout.LabelField(StripValueNameHash(valueName), string.Format("Unhandled Type {0}", value.GetType())); } } if (EditorGUI.EndChangeCheck()) { SetKeyValue(valueName, value); } } }
protected override void OnGUI() { var selects = Selection.objects; using (var svs = new EditorGUILayout.ScrollViewScope(m_scoll)) { m_scoll = svs.scrollPosition; foreach (var obj in selects) { var clip = obj as AnimationClip; if (clip == null) { continue; } EditorGUILayout.ObjectField(clip, typeof(AnimationClip), false); } } using (new EditorGUILayout.HorizontalScope()) { m_excludeScale = EditorGUILayout.ToggleLeft("Exclude Scale", m_excludeScale); if (GUILayout.Button("Optimize")) { m_ing = true; } } if (m_ing) { if (m_index >= selects.Length) { m_ing = false; m_index = 0; EditorUtility.ClearProgressBar(); return; } var info = string.Format("Process {0}/{1}", m_index, selects.Length); EditorUtility.DisplayProgressBar("Optimize Clip", info, (m_index + 1f) / selects.Length); var obj = selects[m_index]; m_index++; var clip = obj as AnimationClip; if (clip == null) { return; } animClip = clip; animclipPath = AssetDatabase.GetAssetPath(clip); Log("优化前---->"); FixFloatAtClip(clip, m_excludeScale); Log("优化后---->"); } }
private void OnGUI() { if (GUILayout.Button("Search Missing Script")) { FindMissingScript(); } if (_missingScripts.Count <= 0) { return; } using (var scroll = new EditorGUILayout.ScrollViewScope(_scrollPosition)) { _scrollPosition = scroll.scrollPosition; using (new EditorGUILayout.VerticalScope()) { foreach (var script in _missingScripts) { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.ObjectField(script.GameObject, typeof(GameObject), true); } foreach (var missionObject in script.MissionObjects) { if (GUILayout.Button(missionObject.Path, EditorStyles.linkLabel)) { Selection.objects = new Object[] { missionObject.TargetObject } } } ; } } } if (GUILayout.Button("Remove All Missing Scripts")) { foreach (var script in _missingScripts) { foreach (var missionObject in script.MissionObjects) { #if UNITY_2019_2_OR_NEWER GameObjectUtility.RemoveMonoBehavioursWithMissingScript(missionObject.TargetObject); #else GameObject.DestroyImmediate(missionObject.TargetObject); #endif } EditorUtility.SetDirty(script.GameObject); } _missingScripts.Clear(); AssetDatabase.SaveAssets(); } }
void LeftSidebar() { using (new EditorGUILayout.VerticalScope(GUILayout.Width(300))) { if (GUILayout.Button("Back to start")) { BackToStart(); } if (GUILayout.Button("New Response")) { NewResponse(); } if (GUILayout.Button("Unlink response")) { UnlinkResponse(); } if (GUILayout.Button("Copy selected")) { CopySelected(); } if (GUILayout.Button("Paste into selected")) { PasteIntoSelected(); } if (GUILayout.Button("Move selected up")) { MoveSelectedUp(); } if (GUILayout.Button("Move selected down")) { MoveSelectedDown(); } // Debug information, for now if (curEntry != null) { GUILayout.Label("Entry: " + curEntry.ToString()); } if (curReply != null) { GUILayout.Label("Reply: " + curReply.ToString()); } using (var scroll = new EditorGUILayout.ScrollViewScope(leftScroll)) { leftScroll = scroll.scrollPosition; // Show the inspector for the currently selected link if (curEditingLink != null) { GFFEditor.DrawStruct(curEditingLink); } } } }
private void RenderSpriteAtlas(TileMap tileMap) { zoom = EditorGUILayout.Slider("Zoom", zoom, 0.5f, 4f); using (EditorGUILayout.ScrollViewScope scrollView = new EditorGUILayout.ScrollViewScope(scrollPosition)) { scrollPosition = scrollView.scrollPosition; Sprite[] sprites = tileMap.TextureAtlas.GetSprites(); EditorGUILayout.BeginHorizontal(); // Draw all the available sprites foreach (Sprite sprite in sprites) { // Convert sprite rect to texture coordinates Rect spriteRect = new Rect( sprite.rect.x / sprite.texture.width, sprite.rect.y / sprite.texture.height, sprite.rect.width / sprite.texture.width, sprite.rect.height / sprite.texture.height ); Rect rect = GUILayoutUtility.GetRect( sprite.rect.width * zoom + (float)outlineSize * 2f, sprite.rect.height * zoom + (float)outlineSize * 2f ); // If the user clicks on the sprite, set it as the current selection if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition)) { tileMap.SpriteSelection = sprite; Event.current.Use(); } // If the sprite is selected, draw an outline if (sprite == tileMap.SpriteSelection) { EditorGUI.DrawRect(rect, outlineColor); EditorGUI.DrawRect(new Rect( rect.position + new Vector2((float)outlineSize - 1f, (float)outlineSize - 1f), rect.size - new Vector2((float)outlineSize * 2f - 2f, (float)outlineSize * 2f - 2f) ), Color.white); } // Draw the sprite GUI.DrawTextureWithTexCoords(new Rect( rect.position + new Vector2((float)outlineSize, (float)outlineSize), rect.size - new Vector2((float)outlineSize * 2f, (float)outlineSize * 2f) ), tileMap.TextureAtlas, spriteRect); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } }
void OnGUI() { using (var h = new EditorGUILayout.HorizontalScope()) { using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos)) { scrollPos = scrollView.scrollPosition; RenderAddRegistryForm(); RenderListOfRegistries(); } } }
private void OnGUI() { using var scroll = new EditorGUILayout.ScrollViewScope(_scrollPosition); MetricsGUI(); ColorsGUI(); IconsGUI(); _scrollPosition = scroll.scrollPosition; }
public static Vector2 DrawScrollableSelectableLabel(Vector2 scrollPosition, float width, string text, GUIStyle style) { using (EditorGUILayout.ScrollViewScope scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition)) { scrollPosition = scrollViewScope.scrollPosition; float textHeight = style.CalcHeight(new GUIContent(text), width); EditorGUILayout.SelectableLabel(text, style, GUILayout.MinHeight(textHeight)); return(scrollPosition); } }
public void OnGUI() { if (m_typeSelected == null) { using (EditorGUI.ChangeCheckScope scope = new EditorGUI.ChangeCheckScope()) { m_typeFilter = EditorGUILayout.TextField("Component filter", m_typeFilter); if (scope.changed) { ParseAssemblies(m_typeFilter); } } foreach (System.Type type in m_typesCandidates) { if (GUILayout.Button(type.Name)) { m_typeSelected = type; EditorPrefs.SetString(EDITORPREFS_TYPESELECTED, m_typeSelected.AssemblyQualifiedName); } } } else { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Component", m_typeSelected.Name); if (GUILayout.Button("Clear")) { m_typeSelected = null; } } m_finalFilter = EditorGUILayout.TextField("Filter", m_finalFilter); if (GUILayout.Button("Find All")) { FindAssets(m_typeSelected, m_finalFilter); } using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(m_scrollPos)) { using (new EditorGUI.DisabledGroupScope(true)) { foreach (GameObject gameObject in m_selection) { EditorGUILayout.ObjectField(gameObject, typeof(GameObject), false); } m_scrollPos = scope.scrollPosition; } } } }
private void OnGUI() { /* var topRect =*/ GUIClipGetTopRect(); var pivotPoint = Vector2.zero; //var rect = new Rect(0, 0, topRect.width, topRect.height); var zoom = 2.0f; // 1.0f~ 値が大きいほど、小さく表示される var invZoom = 1.0f / zoom; { using (var scrollScope = new EditorGUILayout.ScrollViewScope(_scrPos)) { _scrPos = scrollScope.scrollPosition; /*var area =*/ GUILayoutUtility.GetRect(new GUIContent(string.Empty), GUIStyle.none, GUILayout.Width(3000), GUILayout.Height(3000)); { GUIUtility.ScaleAroundPivot(Vector2.one * invZoom, pivotPoint); var visibleRect = GUIClipGetVisibleRect(); visibleRect.position *= zoom; visibleRect.size *= zoom; GUIClipSetTransform(Matrix4x4.identity, Matrix4x4.identity, visibleRect); //内部のGUI 適当! int x, y; x = 3000 - 25; for (y = 0; y <= 6000; y += 100) { GUI.Button(new Rect(x, y, 50, 50), y.ToString()); } x = 6000 - 25; for (y = 0; y <= 6000; y += 100) { GUI.Button(new Rect(x, y, 50, 50), y.ToString()); } y = 3000 - 25; for (x = -25; x <= 6000; x += 100) { GUI.Button(new Rect(x, y, 50, 50), x.ToString()); } y = 6000 - 25; for (x = 0; x <= 6000; x += 100) { GUI.Button(new Rect(x, y, 50, 50), x.ToString()); } GUI.matrix = Matrix4x4.identity; } } } }
private void OnGUI() { using (new EditorGUILayout.VerticalScope()) { var firstIndex = ProfilerDriver.firstFrameIndex; var lastIndex = ProfilerDriver.lastFrameIndex; _captureIndex = EditorGUILayout.IntSlider("CaptureFrame", _captureIndex, firstIndex, lastIndex); _collectionThreshold = EditorGUILayout.FloatField("SelfTime Threshold", _collectionThreshold); using (new EditorGUILayout.ToggleGroupScope("ExportColumns", _isCaptureProfiler)) { foreach (var item in Enum.GetValues(typeof(ExportProfilerColumn))) { var columnName = Enum.GetName(typeof(ExportProfilerColumn), item); bool isToggle = false; var columnValue = (ExportProfilerColumn)item; if ((_exportCollectColumn & columnValue) == columnValue) { isToggle = true; } var toggleResult = EditorGUILayout.Toggle(columnName, isToggle); if (toggleResult != isToggle) { _exportCollectColumn ^= columnValue; } } } if (GUILayout.Button("Capture")) { CaptureProfilerData(); _isCaptureProfiler = true; } using (var scrollView = new EditorGUILayout.ScrollViewScope(_logScrollPosition)) { _logScrollPosition = scrollView.scrollPosition; if (_logText != string.Empty) { EditorGUILayout.TextArea(_logText); } else { EditorGUILayout.TextArea("not capture log."); } } } }
public void OnGUI() { using (new EditorGUILayout.VerticalScope("box")) { ItemType newItemType = (ItemType)EditorGUILayout.Popup((int)curItemType, Enum.GetNames(typeof(ItemType))); if (newItemType != curItemType) { curItemType = newItemType; GetItems(); } tab = GUILayout.Toolbar(tab, new string[] { "Base", "Module", "Override", "All" }); search = GUILayout.TextField(search); string[] resrefs = new string[] { }; switch (tab) { case 0: resrefs = bifItems; break; case 1: resrefs = modItems; break; case 2: resrefs = overItems; break; case 3: resrefs = bifItems.Concat(modItems).Concat(overItems).ToArray(); break; } if (search != "") { resrefs = resrefs.Where(p => p.Contains(search)).ToArray(); } using (var scope = new EditorGUILayout.ScrollViewScope(modScroll, "box")) { modScroll = scope.scrollPosition; int i = 0; foreach (string item in resrefs) { if (GUILayout.Button(item)) { NewInstance(item); } } } } }
private void OnGUI() { if (m_Node == null) { CollapseEditor(); return; } using (var scope = new EditorGUILayout.ScrollViewScope(m_ScrollPostion)) using (new EditorGUILayout.VerticalScope(GUILayout.MaxWidth(maxContentWidth))) { EditorGUIUtility.labelWidth = 80f; DrawCommonControls(); switch (m_Node.type) { case ExpressionType.Search: DrawNameEditor(); DrawSearchEditor(); break; case ExpressionType.Value: DrawNameEditor(); DrawValueEditor(); break; case ExpressionType.Provider: DrawProviderEditor(); break; case ExpressionType.Union: case ExpressionType.Intersect: case ExpressionType.Except: case ExpressionType.Results: DrawResultsEditor(); break; case ExpressionType.Select: DrawSelectEditor(); break; case ExpressionType.Expression: DrawNestedExpressionEditor(); break; default: throw new NotSupportedException($"No inspector for {m_Node.type} {m_Node.id}"); } ResizeEditor(); m_ScrollPostion = scope.scrollPosition; } }
private void DrawDefines() { using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos)) { scrollPos = scrollView.scrollPosition; DrawPlatformDefines(); EditorGUILayout.Space(); DrawCodeCompilationDefines(); } }
private void OnGUI() { using (var scroll = new EditorGUILayout.ScrollViewScope(pos)) { pos = scroll.scrollPosition; foreach (var obj in allObjects) { EditorGUILayout.ObjectField(obj, obj.GetType(), false); } } }
public void DisplayObjects() { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Found " + FilteredObjects.Count()); if (GUILayout.Button("Refresh", GUILayout.Width(64))) { RefreshObjects(); } } DisplaySearchField(); if (FoundObjects == null) { return; } using (var scrollScope = new EditorGUILayout.ScrollViewScope(ListScrollViewOffset)) { ListScrollViewOffset = scrollScope.scrollPosition; foreach (var foundObject in FilteredObjects.ToList()) { if (foundObject == null) { FilteredObjects.Remove(foundObject); } else { using (new EditorGUILayout.HorizontalScope()) { GUI.DrawTexture(GUILayoutUtility.GetRect(16, 16, GUILayout.Width(16)), GetPreviewTexture(foundObject)); if (GUILayout.Button(foundObject.name, GetGuIStyle(foundObject))) { ChangeSelectedObject(foundObject); } // TODO: Find a way to make this work //if(foundObject is GameObject) { // if (GUILayout.Button(new GUIContent(Resources.Load<Texture>("UnityObject"), "Open in prefab editor"), EditorStyles.label, GUILayout.MaxWidth(18), GUILayout.MaxHeight(16))) { // //var prefab = PrefabUtility.LoadPrefabContents(PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(foundObject)); // //AssetDatabase.OpenAsset(prefab); // } //} if (GUILayout.Button(new GUIContent(Resources.Load <Texture>("ShowInProjectIcon"), "Open in project view"), EditorStyles.label, GUILayout.MaxWidth(18))) { ProjectWindowUtil.ShowCreatedAsset(foundObject); EditorGUIUtility.PingObject(foundObject); } } } } } }
public override void OnInspectorGUI() { serializedObject.Update(); DrawDefaultInspector(); int oldRows = rows.intValue; int oldColumns = columns.intValue; // Edit size EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rows: "); rows.intValue = EditorGUILayout.IntField(rows.intValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Columns: "); columns.intValue = EditorGUILayout.IntField(columns.intValue); if (rows.intValue <= 0) { rows.intValue = 1; } if (columns.intValue <= 0) { columns.intValue = 1; } EditorGUILayout.EndHorizontal(); if (rows.intValue != oldRows || columns.intValue != oldColumns) { tilemap.arraySize = rows.intValue * columns.intValue; } using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, GUILayout.Width(columns.intValue * 20 + 16), GUILayout.Height(rows.intValue * 20 + 16))) { scrollPos = scrollView.scrollPosition; for (int i = 0; i < rows.intValue; i++) { EditorGUILayout.BeginHorizontal(); for (int j = 0; j < columns.intValue; j++) { int index = i * (columns.intValue) + j; SerializedProperty type = tilemap.GetArrayElementAtIndex(index); type.intValue = EditorGUILayout.IntField(type.intValue, GUILayout.Width(16), GUILayout.Height(16)); } EditorGUILayout.EndHorizontal(); } } serializedObject.ApplyModifiedProperties(); }
private void OnGUIDeferred(Event e) { using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(_scrollVector)) { _scrollVector = scrollViewScope.scrollPosition; foreach (var task in Ledger.Manifest.DeferredTasks) { task.Draw(e); } } }