Skip to content

Control

extends EngineObject

The Control class is the base class for all GUI controls.

You can obtain a control of type Button using the following method:

typeScript
let go = new GameObject("ui");
let uiComponent = go.AddComponent<UIComponent>(UIComponent);
let canvas = uiComponent.canvas;		
let button = canvas.FindChild<Button>("Button");

成员变量

Control.childCount : number
Get the number of child controls of the current control.
Control.name : string
The name of the current control.
Control.isShown : boolean
Check if the current control is visible.
Control.type : ControlType
The control type of the current control.
Control.rectTransform : RectTransform
The RectTransform component of a UI control.
Control.form : Form|null
The Form that the current control belongs to.
Control.layoutGroup : LayoutGroup|null
The layout group of the current control.
Control.isEnable : boolean
Check if the current control is enabled.
Control.canvas : Canvas|null
The Canvas that the current control is on.
Control.guiEventData : GUIEventData
Get the UI event data of the current control.

成员方法

Control.SetParent ( parent : Control , keepWorldPos : boolean? ) : void
Set the parent of the control.
Control.AddChild ( child : Control ) : void
Add a child control.
Control.GetChildByIndex ( index : number ) : Control
Get the child control of the current control based on the index (index starts from 0).
Control.FindChild ( name : string ) : Control
Control.Close ( ) : void
Close the current control.
Control.Clone ( parent : Control? ) : Control
Clone the current control.
Control.ClearEvent ( event : ControlEvent , callBack : IControlEventCallBack|null ) : void
Clears the specified event of the current control.
Control.Show ( ) : void
Display the control.
Control.Hide ( ) : void
Hide the control.
Control.Enable ( ) : void
Enable the control.
Control.Disable ( ) : void
Disable the control.
Control.AddEvent ( event : ControlEvent , callBack : IControlEventCallBack ) : void
Adds the specified event callback to the control.
Control.GetLayoutGroupSize ( ) : Vector2
Get the layout group size of the current control.
Control.ResetLayoutGroup ( ) : void
Resets the layout group of the current control.
Control.toString ( ) : string
Returns the type alias of the control.