92. CLASE GUILAYOUT (I)




Esta clase es la interfaz para la gui de Unity con distribución automática. Me explico:

Hay dos maneras que podemos usar para organizar y distribuir nuestras interfaces gráficas de usuario: fija y automática. Hasta ahora hemos trabajado con la clase GUI, que es la forma fija de distribución. Esto entraña que cada vez que se crea un nuevo elemento o control, se le ubica en un punto concreto (casi siempre a través de un Rect). En cambio, con la forma automática de distribución (que es la que permite la clase GUILayout) esto no es necesario.

Se pueden usar ambos modos en la misma función OnGUI().

El modo fijo de distribución se suele usar cuando tenemos una interfaz prediseñada con la que trabajamos. El modo automático en cambio se suele usar cuando no sabemos cuántos elementos acabaremos necesitando, o no queremos preocuparnos de colocar a mano cada control.

Hay dos diferencias a tener en cuenta cuando usamos distribución automática:

1.- Hemos de usar GUILayout en lugar de GUI.
2.- Para la distribución automática no se usa la función Rect().


FUNCIONES DE CLASE:

Label:

static function Label (image : Texture, params options : GUILayoutOption[]) : void
static function Label (text : String, params options : GUILayoutOption[]) : void
static function Label (content : GUIContent, params options : GUILayoutOption[]) : void
static function Label (image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : void
static function Label (text : String, style : GUIStyle, params options : GUILayoutOption[]) : void
static function Label (content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : void


Hace una etiqueta de distribución automático. Las etiquetas no proveen interación con el usuario, no capturan clicks de ratón y son siempre renderizadas en estilo normal. Si quieres tener un control que responda visualmente a las entradas de usuario usa un box control.

Todos los parámetros menos uno son idénticos a los de la función homónima de la clase GUI, así que a ellos me remito. Pero quiero detenerme en ese parámetro distinto, que de hecho es el que marca la diferencia entre la distribución fija (mediante Rect() y la automática. Me estoy refiriendo al parámetro params option, que es de tipo GUILayoutOption.

GUILayoutOption es una clase internamente usada por Unity para pasar diferentes opciones de distribución en las funciones de la clase GUILayout. No se usa directamente, sino a través de funciones de tipo GUILayout, como por ejemplo: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth y GUILayout.ExpandHeight.

Más adelante en esta clase estudiaremos dichas funciones.


Box:

static function Box (image : Texture, params options : GUILayoutOption[]) : void
static function Box (text : String, params options : GUILayoutOption[]) : void
static function Box (content : GUIContent, params options : GUILayoutOption[]) : void
static function Box (image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : void
static function Box (text : String, style : GUIStyle, params options : GUILayoutOption[]) : void
static function Box (content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : void

crea una caja de distribución automática. Si queremos crear una caja con algún contenido dentro, hemos de usar el parámetro de estilo de uno de los subgrupos de funciones (BeginHorizontal, BeginVertical, etc...).


Button:

static function Button (image : Texture, params options : GUILayoutOption[]) : boolean
static function Button (text : String, params options : GUILayoutOption[]) : boolean
static function Button (content : GUIContent, params options : GUILayoutOption[]) : boolean
static function Button (image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : boolean
static function Button (text : String, style : GUIStyle, params options : GUILayoutOption[]) : boolean
static function Button (content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : boolean


Crea un botón con distribución automática qevuelve true cuando el usuario lo presiona.


RepeatButton:

static function RepeatButton (image : Texture, params options : GUILayoutOption[]) : boolean
static function RepeatButton (text : String, params options : GUILayoutOption[]) : boolean
static function RepeatButton (content : GUIContent, params options : GUILayoutOption[]) : boolean
static function RepeatButton (image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : boolean
static function RepeatButton (text : String, style : GUIStyle, params options : GUILayoutOption[]) : boolean
static function RepeatButton (content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : boolean


Crea un botón que devuelve true tanto tiempo como el usuario lo mantiene pulsado.


TextField:


static function TextField (text : String, params options : GUILayoutOption[]) : String

static function TextField (text : String, maxLength : int, params options : GUILayoutOption[]) : String
static function TextField (text : String, style : GUIStyle, params options : GUILayoutOption[]) : String
static function TextField (text : String, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : String


Crea un campo de texto de una linea donde el usuario puede editar un string.


PasswordField:


static function PasswordField (password : String, maskChar : char, params options : GUILayoutOption[]) : String

static function PasswordField (password : String, maskChar : char, maxLength : int, params options : GUILayoutOption[]) : String
static function PasswordField (password : String, maskChar : char, style : GUIStyle, params options : GUILayoutOption[]) : String
static function PasswordField (password : String, maskChar : char, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : String

Crea un campo de texto donde el usuario puede entrar una contraseña. Devuelve la contraseña editada.


TextArea:

static function TextArea (text : String, params options : GUILayoutOption[]) : String
static function TextArea (text : String, maxLength : int, params options : GUILayoutOption[]) : String
static function TextArea (text : String, style : GUIStyle, params options : GUILayoutOption[]) : String
static function TextArea (text : String, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : String



Crea un campo de texto multilínea donde el user puede editar un string, y devuelve dicho string

POSTED BY UnityScripts
POSTED IN
DISCUSSION 0 Comments

Leave a Reply

Con la tecnología de Blogger.