Question by
Pratap-Dafedar · Aug 01, 2020 at 04:28 PM ·
editor-scriptingeditorwindowscrollvieweditor windoweditorscript
UIElements - Horizontal scrolling is not working in ScrollView even with ScrollViewMode.Horizontal.
I would like to create an editor window, which is similar to the unity profiler, where I want to enable horizontal scrolling to see through the data horizontally.
I am wondering whether my mac book's trackpad horizontal scrolling is supported by unity UI elements or not! On the other side, this is very basic functionality. Please help here!
The sample code snippet below.
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class HorizontalScrollWindow : EditorWindow
{
[MenuItem("Test/Open")]
public static void ShowWindow()
{
var window = GetWindow<HorizontalScrollWindow>();
window.titleContent = new GUIContent("HorizontalScrollWindow");
}
public void OnEnable()
{
rootVisualElement.Add(new CustomScrollView());
rootVisualElement.style.flexDirection = FlexDirection.Row;
}
class CustomScrollView : ScrollView
{
public CustomScrollView() : base(ScrollViewMode.Horizontal)
{
style.flexGrow = new StyleFloat(1f);
for (int i = 0; i < 400; i++)
{
base.contentContainer.Add(new Button()
{
text = "hello: " + i
});
}
}
}
}
cc: @uDamian @JonathanMah
horizotal-scrolling-not-working.png
(65.9 kB)
Comment