- Home /
Custom EditorWindow Scrollbars not working with GUILayout areas
Hi,
Maybe this was raised before but couldn't find the answer. It seams that GUILayout.BeginScrollView does not detect GUILayout.BeginArea.
Why the vertical scrollbar is not appearing for the below code ??
When I remove BeginArea & EndArea lines the scrollbar appears.
using UnityEngine;
using UnityEditor;
public class SimpleEditorCode : EditorWindow {
private Vector2 scrollPos;
[MenuItem("Window/Simple Editor")]
public static void Init() {
SimpleEditorCode mainWindow = GetWindow<SimpleEditorCode>();
mainWindow.Show();
}
public void OnGUI() {
scrollPos = GUILayout.BeginScrollView(scrollPos);
GUILayout.BeginArea(new Rect(50, 50, 500, 70));
GUILayout.Button("Test", GUILayout.Width(450));
GUILayout.EndArea();
GUILayout.EndScrollView();
}
}
Any help or link to solution please. Many thanks.
Answer by Olinus · Sep 03, 2017 at 07:41 PM
I find Unity great for coding but when it comes to Custom UI coding it is a complete nightmare. GUI, GUILayout, EditorGUILayout, GUILayoutUtility...
The only workaround solution that is working can be found here.
Working code for my example:
public void OnGUI() {
// Create a gigantic working area. Why I cannot simply use the Screen rect ???
Rect workArea = GUILayoutUtility.GetRect(10, 10000, 10, 10000);
// Create scrollable area using GUI not GUILayout.BeginScrollView(). Why ???
scrollPos = GUI.BeginScrollView(workArea, scrollPos, new Rect(0, 0 ,500, 70));
// The areas are ready and scrollable - place controls now
GUILayout.BeginArea(new Rect(50, 50, 500, 70));
GUILayout.Button("Test", GUILayout.Width(450));
GUILayout.EndArea();
GUI.EndScrollView();
}
I have raised this as a bug in Unity. Maybe this will help.
Your answer
Follow this Question
Related Questions
Editor GUI ScrollView Actual Scrollbar Not Showing Up?? 1 Answer
How to hide scrollbar on side of the view 0 Answers
GUIlayout scrollbar, Not working well... 1 Answer
How do you use EditorGUILayout.TextArea with EditorGUILayout.ScrollViewScope? 1 Answer
Scrollbar is not appearing in my list, I am using Unity 4.6 1 Answer