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.

GUILayout.ExpandWidth

static function ExpandWidth(expand: bool): GUILayoutOption;
static GUILayoutOption ExpandWidth(bool expand);
static def ExpandWidth(expand as bool) as GUILayoutOption

Description

Option passed to a control to allow or disallow horizontal expansion.

	function OnGUI () {
		GUILayout.BeginVertical();
		GUILayout.Button("Short Button", GUILayout.ExpandWidth(false));
		GUILayout.Button("Very very long Button");
		GUILayout.EndVertical();
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnGUI() {
        GUILayout.BeginVertical();
        GUILayout.Button("Short Button", GUILayout.ExpandWidth(false));
        GUILayout.Button("Very very long Button");
        GUILayout.EndVertical();
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def OnGUI() as void:
		GUILayout.BeginVertical()
		GUILayout.Button('Short Button', GUILayout.ExpandWidth(false))
		GUILayout.Button('Very very long Button')
		GUILayout.EndVertical()