Select your preferred scripting language. All code snippets will be displayed in this language.
class in UnityEditor
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
CloseDisposable helper class for managing BeginScrollView / EndScrollView.
These work just like GUILayout.ScrollViewScope but feel more application-like and should be used in the editor
Label inside a scroll view.
#pragma strict // Simple Editor Window that creates a scroll view with a Label inside class BeginEndScrollView extends EditorWindow { var scrollPos: Vector2; var t: String = "This is a string inside a Scroll view!"; @MenuItem("Examples/Write text on ScrollView") static function Init() { var window: var = GetWindow.<BeginEndScrollView>(); window.Show(); } function OnGUI() { var h: var = new EditorGUILayout.HorizontalScope(); { var scrollView: var = new EditorGUILayout.ScrollViewScope(scrollPos, GUILayout.Width(100), GUILayout.Height(100)); { scrollPos = scrollView.scrollPosition; GUILayout.Label(t); } if (GUILayout.Button("Add More Text", GUILayout.Width(100), GUILayout.Height(100))) t += " \nAnd this is more text!"; } if (GUILayout.Button("Clear")) t = ""; } }
using UnityEngine; using UnityEditor;
// Simple Editor Window that creates a scroll view with a Label inside class BeginEndScrollView : EditorWindow { Vector2 scrollPos; string t = "This is a string inside a Scroll view!";
[MenuItem("Examples/Write text on ScrollView")] static void Init() { var window = GetWindow<BeginEndScrollView>(); window.Show(); }
void OnGUI() { using (var h = new EditorGUILayout.HorizontalScope()) { using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, GUILayout.Width(100), GUILayout.Height(100))) { scrollPos = scrollView.scrollPosition; GUILayout.Label(t); } if (GUILayout.Button("Add More Text", GUILayout.Width(100), GUILayout.Height(100))) t += " \nAnd this is more text!"; } if (GUILayout.Button("Clear")) t = ""; } }
handleScrollWheel | Whether this ScrollView should handle scroll wheel events. (default: true). |
scrollPosition | The modified scrollPosition. Feed this back into the variable you pass in, as shown in the example. |
EditorGUILayout.ScrollViewScope | Create a new ScrollViewScope and begin the corresponding ScrollView. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information