Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

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

GUILayout.BeginArea

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

public static method BeginArea(screenRect: Rect): void;
public static void BeginArea(Rect screenRect);
public static method BeginArea(screenRect: Rect, text: string): void;
public static void BeginArea(Rect screenRect, string text);
public static method BeginArea(screenRect: Rect, image: Texture): void;
public static void BeginArea(Rect screenRect, Texture image);
public static method BeginArea(screenRect: Rect, content: GUIContent): void;
public static void BeginArea(Rect screenRect, GUIContent content);
public static method BeginArea(screenRect: Rect, style: GUIStyle): void;
public static void BeginArea(Rect screenRect, GUIStyle style);
public static method BeginArea(screenRect: Rect, text: string, style: GUIStyle): void;
public static void BeginArea(Rect screenRect, string text, GUIStyle style);
public static method BeginArea(screenRect: Rect, image: Texture, style: GUIStyle): void;
public static void BeginArea(Rect screenRect, Texture image, GUIStyle style);
public static method BeginArea(screenRect: Rect, content: GUIContent, style: GUIStyle): void;
public static void BeginArea(Rect screenRect, GUIContent content, GUIStyle style);

Parameters

textOptional text to display in the area.
imageOptional texture to display in the area.
contentOptional text, image and tooltip top display for this area.
styleThe style to use. If left out, the empty GUIStyle (GUIStyle.none) is used, giving a transparent background.

Description

Begin a GUILayout block of GUI controls in a fixed screen area.

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.

See Also: EndArea


Explained Area of the example.

    function OnGUI () {
        // Starts an area to draw elements
        GUILayout.BeginArea (Rect (10,10,100,100));
        GUILayout.Button ("Click me");
        GUILayout.Button ("Or me");
        GUILayout.EndArea ();
    }
no example available in C#

This function is very useful when mixing GUILayout code. It must be matched with a call to EndArea. BeginArea / EndArea cannot be nested.

对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答