Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

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

GUI.Box

static function Box(position: Rect, text: string): void;
static void Box(Rect position, string text);
static def Box(position as Rect, text as string) as void
static function Box(position: Rect, image: Texture): void;
static void Box(Rect position, Texture image);
static def Box(position as Rect, image as Texture) as void
static function Box(position: Rect, content: GUIContent): void;
static void Box(Rect position, GUIContent content);
static def Box(position as Rect, content as GUIContent) as void
static function Box(position: Rect, text: string, style: GUIStyle): void;
static void Box(Rect position, string text, GUIStyle style);
static def Box(position as Rect, text as string, style as GUIStyle) as void
static function Box(position: Rect, image: Texture, style: GUIStyle): void;
static void Box(Rect position, Texture image, GUIStyle style);
static def Box(position as Rect, image as Texture, style as GUIStyle) as void
static function Box(position: Rect, content: GUIContent, style: GUIStyle): void;
static void Box(Rect position, GUIContent content, GUIStyle style);
static def Box(position as Rect, content as GUIContent, style as GUIStyle) as void

Parameters

positionRectangle on the screen to use for the box.
textText to display on the box.
image Texture to display on the box.
contentText, image and tooltip for this box.
styleThe style to use. If left out, the box style from the current GUISkin is used.

Description

Make a graphical box.

	// Draws a box of the size of the screen.
	function OnGUI() {
		 GUI.Box(Rect(0,0,Screen.width,Screen.height),"This is a title");
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnGUI() {
        GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "This is a title");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def OnGUI() as void:
		GUI.Box(Rect(0, 0, Screen.width, Screen.height), 'This is a title')