Version: 2023.2
LanguageEnglish
  • C#

AreaScope

class in UnityEngine

/

Implemented in:UnityEngine.IMGUIModule

Suggest a change

Success!

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.

Close

Submission failed

For 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.

Close

Cancel

Description

Disposable helper class for managing BeginArea / EndArea.

BeginArea is called at construction, and EndArea is called when the instance is disposed. By default, any GUI controls made using GUILayout are placed in the top-left corner of the screen. If you want to place a series of automatically laid out controls in an arbitrary area, use GUILayout.BeginArea to define a new area for the automatic layouting system to use.

Additional resources: BeginArea, EndArea


Explained Area of the example.

using UnityEngine;

public class ExampleClass : MonoBehaviour { void OnGUI() { using (var areaScope = new GUILayout.AreaScope(new Rect(10, 10, 100, 100))) { GUILayout.Button("Click me"); GUILayout.Button("Or me"); } } }

Constructors

GUILayout.AreaScopeCreate a new AreaScope and begin the corresponding Area.