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

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 FlexibleSpace(): void;
public static void FlexibleSpace();

Description

Insert a flexible space element.

Flexible spaces use up any leftover space in a layout.

Note: This will override the GUILayout.ExpandWidth and GUILayout.ExpandHeight


Flexible Space in a GUILayout Area.

    var sliderValue : float = 1.0;

function OnGUI() { // Wrap everything in the designated GUI Area GUILayout.BeginArea (Rect (0,0,200,60)); // Begin the singular Horizontal Group GUILayout.BeginHorizontal(); // Place a Button normally GUILayout.RepeatButton ("A button with\ntwo lines"); // Place a space between the button and the vertical area // so it fits the whole area GUILayout.FlexibleSpace(); // Arrange two more Controls vertically beside the Button GUILayout.BeginVertical(); GUILayout.Box("Value:" + Mathf.Round(sliderValue)); sliderValue = GUILayout.HorizontalSlider (sliderValue, 0.0, 10);

// End the Groups and Area GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
no example available in C#
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答