Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ScrollViewScope

class in UnityEditor

Switch to Manual

Description

Disposable 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 = "";
	}
}

Variables

handleScrollWheelWhether this ScrollView should handle scroll wheel events. (default: true).
scrollPositionThe modified scrollPosition. Feed this back into the variable you pass in, as shown in the example.

Constructors

EditorGUILayout.ScrollViewScopeCreate a new ScrollViewScope and begin the corresponding ScrollView.