88. CLASE GUI (V)










TextArea:

static function TextArea (position : Rect, text : String) : String
static function TextArea (position : Rect, text : String, maxLength : int) : String
static function TextArea (position : Rect, text : String, style : GUIStyle) : String
static function TextArea (position : Rect, text : String, maxLength : int, style : GUIStyle) : String

Crea un área de texto de varias líneas donde el usuario puede editar un string. Devuelve el string editado.


SetNextControlName:

static function SetNextControlName (name : String) : void


Función que establece el nombre del siguiente control. Esto hace que el siguiente control sea registrado con un nombre dado.


GetNameOfFocusedControl:

static function GetNameOfFocusedControl () : String


Obtiene el nombre del control que tiene el foco. El nombre de los controles es asignado usando SetNextControlName. Cuando un control tiene el foco, esta función devuelve su nombre. GetNameOfFocusedControl funciona especialmente bien cuando tratamos con ventanas para loguearse.


FocusControl:

static function FocusControl (name : String) : void


Mueve el foco del teclado a un control nombrado.


Toggle:

static function Toggle (position : Rect, value : boolean, text : String) : boolean
static function Toggle (position : Rect, value : boolean, image : Texture) : boolean
static function Toggle (position : Rect, value : boolean, content : GUIContent) : boolean
static function Toggle (position : Rect, value : boolean, text : String, style : GUIStyle) : boolean
static function Toggle (position : Rect, value : boolean, image : Texture, style : GUIStyle) : boolean
static function Toggle (position : Rect, value : boolean, content : GUIContent, style : GUIStyle) : boolean

Crea un botón de tipo interruptor (on/off). Devuelve el nuevo valor del botón(true/false).


Toolbar:

static function Toolbar (position : Rect, selected : int, texts : string[]) : int
static function Toolbar (position : Rect, selected : int, images : Texture[]) : int
static function Toolbar (position : Rect, selected : int, content : GUIContent[]) : int
static function Toolbar (position : Rect, selected : int, texts : string[], style : GUIStyle) : int
static function Toolbar (position : Rect, selected : int, images : Texture[], style : GUIStyle) : int
static function Toolbar (position : Rect, selected : int, contents : GUIContent[], style : GUIStyle) : int


Función que crea una barra de herramientas. Devuelve -un int- el índice de la toolbar seleccionado.

Tiene estos parámetros:


position: Rectángulo en la pantalla a usar para la barra de herramientas.
selected: El índice del botón seleccionado.
texts: Un array de strings a enseñar en los botones de la barra.
images: Un array de textras para los botones de la barra de herramientas.
contents: Un array de texto, imágenes y tooltips para los botones del toolbar.
style: El estilo a usar. Si no se indica, se usará el estilo para botones que
tenga la GUISkin que se esté usando.





Veámoslo con un ejemplo:


var toolbarIndice : int = 0;
var toolbarStrings : String[] = ["Toolbar1", "Toolbar2", "Toolbar3"];

function OnGUI () {
toolbarIndice = GUI.Toolbar (Rect (25, 25, 250, 30), toolbarIndice, toolbarStrings);
Debug.Log("El índice pulsado es " + toolbarIndice);
}


Observaremos que nos aparece en pantalla al pulsar play una barra con tres botones, estando por defecto activado el primero, que corresponde con el índice cero que le hemos pasado como parámetro. Le hemos añadido la función Debug.Log para acreditar que al presionar los distintos botones se le asigna a la variable el índice de cada botón.

POSTED BY UnityScripts
POSTED IN
DISCUSSION 0 Comments

Leave a Reply

Con la tecnología de Blogger.