Skip to main content

GComponent

Namespace:FairyGUI
Source:Assets/Scripts/UI/GComponent.cs (line 14)

public class GComponent : GObject

Component

Inheritance:EventDispatcher → GObject → GComponent

Inherited members​

GObject

data, dragBounds, initHeight, initWidth, maxHeight, maxWidth, minHeight, minWidth, name, packageItem, sourceHeight, sourceWidth, underConstruct, AddRelation, Center, GetGear, GlobalToLocal, HandleAlphaChanged, HandlePositionChanged, HandleScaleChanged, HandleVisibleChanged, LocalToGlobal, LocalToRoot, MakeFullScreen, RemoveFromParent, RemoveRelation, RequestFocus, RootToLocal, SetHome, SetPivot, SetPosition, SetScale, SetSize, SetSizeDirectly, SetXY, Setup_BeforeAdd, StartDrag, StopDrag, TransformPoint, TransformRect, TweenFade, TweenMove, TweenMoveX, TweenMoveY, TweenResize, TweenRotate, TweenScale, TweenScaleX, TweenScaleY, UpdateGear, WorldToLocal, actualHeight, actualWidth, alpha, asButton, asComboBox, asCom, asGraph, asGroup, asImage, asLabel, asList, asLoader3D, asLoader, asMovieClip, asProgress, asRichTextField, asSlider, asTextField, asTextInput, asTree, blendMode, cursor, displayObject, dragStartPos, draggable, draggingObject, dragging, enabled, filter, focusable, focused, gameObjectName, gearLook, gearSize, gearXY, grayed, group, height, icon, id, inContainer, isDisposed, onAddedToStage, onClickLink, onClick, onDragEnd, onDragMove, onDragStart, onFocusIn, onFocusOut, onGearStop, onKeyDown, onPositionChanged, onRemovedFromStage, onRightClick, onRollOut, onRollOver, onSizeChanged, onStage, onTouchBegin, onTouchEnd, onTouchMove, parent, pivotAsAnchor, pivotX, pivotY, pivot, pixelSnapping, position, relations, resourceURL, root, rotationX, rotationY, rotation, scaleX, scaleY, scale, size, skew, sortingOrder, tabStop, text, tooltips, touchable, treeNode, visible, width, xMin, xy, x, yMin, y, z

EventDispatcher

AddCapture, AddEventListener, BroadcastEvent, BubbleEvent, DispatchEvent, RemoveCapture, RemoveEventListener, RemoveEventListeners, hasEventListeners, isDispatching

Constructors​

GComponent()​

public GComponent();

Source:UI/GComponent.cs (line 48)

Fields​

__onConstruct​

public Action __onConstruct;

Compilation conditions:FAIRYGUI_PUERTS

Source:UI/GComponent.cs (line 1722)

__onDispose​

public Action __onDispose;

Compilation conditions:FAIRYGUI_PUERTS

Source:UI/GComponent.cs (line 1723)

_apexIndex​

protected int _apexIndex;

Source:UI/GComponent.cs (line 38)

_boundsChanged​

protected bool _boundsChanged;

Source:UI/GComponent.cs (line 36)

_childrenRenderOrder​

protected ChildrenRenderOrder _childrenRenderOrder;

Source:UI/GComponent.cs (line 37)

_margin​

protected Margin _margin;

Source:UI/GComponent.cs (line 34)

_trackBounds​

protected bool _trackBounds;

Source:UI/GComponent.cs (line 35)

Methods​

AddChild(GObject)​

public GObject AddChild(GObject child);

Add a child to the component. It will be at the frontmost position.

returns

GObject

ParameterTypeDescription
childGObjectA child object

Source:UI/GComponent.cs (line 214)

AddChildAt(GObject, int)​

virtual public GObject AddChildAt(GObject child, int index);

Adds a child to the component at a certain index.

returns

GObject

ParameterTypeDescription
childGObjectA child object
indexintIndex

Source:UI/GComponent.cs (line 226)

AddController(Controller)​

public void AddController(Controller controller);

Adds a controller to the container.

ParameterTypeDescription
controllerControllerController object

Source:UI/GComponent.cs (line 689)

CallLua(string)​

public bool CallLua(string funcName);

Compilation conditions:FAIRYGUI_TOLUA

ParameterTypeDescription
funcNamestring

Source:UI/GComponent.cs (line 1695)

ChangeChildrenOrder(IList<GObject>)​

public void ChangeChildrenOrder(IList<GObject> objs);
ParameterTypeDescription
objsIList<GObject>

Source:UI/GComponent.cs (line 670)

ConstructExtension(ByteBuffer)​

virtual protected void ConstructExtension(ByteBuffer buffer);
ParameterTypeDescription
bufferByteBuffer

Source:UI/GComponent.cs (line 1615)

ConstructFromResource()​

override public void ConstructFromResource();

Source:UI/GComponent.cs (line 1363)

ConstructFromXML(XML)​

virtual public void ConstructFromXML(XML xml);

Method for extensions to override

ParameterTypeDescription
xmlXML

Source:UI/GComponent.cs (line 1623)

CreateDisplayObject()​

override protected void CreateDisplayObject();

Source:UI/GComponent.cs (line 57)

Dispose()​

override public void Dispose();

Source:UI/GComponent.cs (line 67)

EnsureBoundsCorrect()​

public void EnsureBoundsCorrect();

Make sure the bounds of the component is correct. Bounds of the component is not updated on every changed. For example, you add a new child to the list, children in the list will be rearranged in next frame. If you want to access the correct child position immediatelly, call this function first.

Source:UI/GComponent.cs (line 1149)

GetChild(string)​

public GObject GetChild(string name);

Returns a child object with a certain name.

returns

A child object. Null if not found.

ParameterTypeDescription
namestringName

Source:UI/GComponent.cs (line 399)

GetChildAt(int)​

public GObject GetChildAt(int index);

Returns a child object at a certain index. If index out of bounds, exception raised.

returns

A child object.

ParameterTypeDescription
indexintIndex

Source:UI/GComponent.cs (line 386)

GetChildByPath(string)​

public GObject GetChildByPath(string path);
ParameterTypeDescription
pathstring

Source:UI/GComponent.cs (line 411)

GetChildInGroup(GGroup, string)​

public GObject GetChildInGroup(GGroup group, string name);

Returns a child object belong to a group with a certain name.

returns

A child object. Null if not found.

ParameterTypeDescription
groupGGroupA group object
namestringName

Source:UI/GComponent.cs (line 462)

GetChildIndex(GObject)​

public int GetChildIndex(GObject child);

Returns the index of a child within the container, or "-1" if it is not found.

returns

Index of the child. -1 If not found.

ParameterTypeDescription
childGObjectA child object

Source:UI/GComponent.cs (line 501)

GetChildren()​

public GObject[] GetChildren();

Returns a copy of all children with an array.

returns

An array contains all children

Source:UI/GComponent.cs (line 491)

GetController(string)​

public Controller GetController(string name);

Returns a controller object with a certain name.

returns

Controller object. Null if not found.

ParameterTypeDescription
namestringName

Source:UI/GComponent.cs (line 711)

GetControllerAt(int)​

public Controller GetControllerAt(int index);

Returns a controller object at a certain index.

returns

Controller object.

ParameterTypeDescription
indexintIndex

Source:UI/GComponent.cs (line 701)

GetFirstChildInView()​

virtual public int GetFirstChildInView();

Source:UI/GComponent.cs (line 1045)

GetSnappingPosition(float, float)​

public void GetSnappingPosition(ref float xValue, ref float yValue);
ParameterTypeDescription
xValuefloat
yValuefloat

Source:UI/GComponent.cs (line 1247)

GetSnappingPositionWithDir(float, float, float, float)​

virtual public void GetSnappingPositionWithDir(ref float xValue, ref float yValue, float xDir, float yDir);
ParameterTypeDescription
xValuefloat
yValuefloat
xDirfloat
yDirfloat

Source:UI/GComponent.cs (line 1262)

GetTransition(string)​

public Transition GetTransition(string name);

Returns a transition object at a certain name.

returns

Transition Object

ParameterTypeDescription
namestringName

Source:UI/GComponent.cs (line 769)

GetTransitionAt(int)​

public Transition GetTransitionAt(int index);

Returns a transition object at a certain index.

returns

transition object.

ParameterTypeDescription
indexintIndex

Source:UI/GComponent.cs (line 759)

GetVisibleChild(string)​

public GObject GetVisibleChild(string name);

Returns a visible child object with a certain name.

returns

A child object. Null if not found.

ParameterTypeDescription
namestringName

Source:UI/GComponent.cs (line 443)

HandleControllerChanged(Controller)​

override public void HandleControllerChanged(Controller c);
ParameterTypeDescription
cController

Source:UI/GComponent.cs (line 1125)

HandleGrayedChanged()​

override protected void HandleGrayedChanged();

Source:UI/GComponent.cs (line 1116)

HandleSizeChanged()​

override protected void HandleSizeChanged();

Source:UI/GComponent.cs (line 1106)

InvalidateBatchingState(bool)​

public void InvalidateBatchingState(bool childChanged);
ParameterTypeDescription
childChangedbool

Source:UI/GComponent.cs (line 133)

IsAncestorOf(GObject)​

public bool IsAncestorOf(GObject obj);
ParameterTypeDescription
objGObject

Source:UI/GComponent.cs (line 649)

IsChildInView(GObject)​

public bool IsChildInView(GObject child);

Test if a child is in view.

returns

True if in view

ParameterTypeDescription
childGObjectA child object

Source:UI/GComponent.cs (line 1030)

OnUpdate()​

virtual protected void OnUpdate();

每帧调用的一个回调。如果你要override,请记住以下两点: 1、记得调用base.onUpdate; 2、不要在方法里进行任何会更改显示列表的操作,例如AddChild、RemoveChild、visible等。

Source:UI/GComponent.cs (line 1357)

RemoveChild(GObject)​

public GObject RemoveChild(GObject child);

Removes a child from the component. If the object is not a child, nothing happens.

returns

GObject

ParameterTypeDescription
childGObjectA child object

Source:UI/GComponent.cs (line 288)

RemoveChild(GObject, bool)​

public GObject RemoveChild(GObject child, bool dispose);

Removes a child from the component. If the object is not a child, nothing happens.

returns

GObject

ParameterTypeDescription
childGObjectA child object
disposeboolIf true, the child will be disposed right away.

Source:UI/GComponent.cs (line 299)

RemoveChildAt(int)​

public GObject RemoveChildAt(int index);

Removes a child at a certain index. Children above the child will move down.

returns

GObject

ParameterTypeDescription
indexintIndex

Source:UI/GComponent.cs (line 314)

RemoveChildAt(int, bool)​

virtual public GObject RemoveChildAt(int index, bool dispose);

Removes a child at a certain index. Children above the child will move down.

returns

GObject

ParameterTypeDescription
indexintIndex
disposeboolIf true, the child will be disposed right away.

Source:UI/GComponent.cs (line 325)

RemoveChildren()​

public void RemoveChildren();

Remove all children.

Source:UI/GComponent.cs (line 361)

RemoveChildren(int, int, bool)​

public void RemoveChildren(int beginIndex, int endIndex, bool dispose);

Removes a range of children from the container (endIndex included).

ParameterTypeDescription
beginIndexintBegin index.
endIndexintEnd index.(Included).
disposeboolIf true, the child will be disposed right away.

Source:UI/GComponent.cs (line 372)

RemoveController(Controller)​

public void RemoveController(Controller c);

Removes a controller from the container.

ParameterTypeDescription
cControllerController object.

Source:UI/GComponent.cs (line 728)

SetBounds(float, float, float, float)​

protected void SetBounds(float ax, float ay, float aw, float ah);
ParameterTypeDescription
axfloat
ayfloat
awfloat
ahfloat

Source:UI/GComponent.cs (line 1196)

SetBoundsChangedFlag()​

public void SetBoundsChangedFlag();

Notify the component the bounds should recaculate.

Source:UI/GComponent.cs (line 1136)

SetChildIndex(GObject, int)​

public void SetChildIndex(GObject child, int index);

Moves a child to a certain index. Children at and after the replaced position move up.

ParameterTypeDescription
childGObjectA Child
indexintIndex

Source:UI/GComponent.cs (line 511)

SetChildIndexBefore(GObject, int)​

public int SetChildIndexBefore(GObject child, int index);

Moves a child to a certain position which is in front of the child previously at given index. 与SetChildIndex不同的是,如果child原来在index的前面,那么child插入的位置是index-1,即保证排在原来占据index的对象的前面。

ParameterTypeDescription
childGObject
indexint

Source:UI/GComponent.cs (line 536)

SetLuaPeer(LuaTable)​

public void SetLuaPeer(LuaTable peerTable);

Compilation conditions:FAIRYGUI_TOLUA

ParameterTypeDescription
peerTableLuaTable

Source:UI/GComponent.cs (line 1690)

SetupOverflow(OverflowType)​

protected void SetupOverflow(OverflowType overflow);
ParameterTypeDescription
overflowOverflowType

Source:UI/GComponent.cs (line 1069)

SetupScroll(ByteBuffer)​

protected void SetupScroll(ByteBuffer buffer);
ParameterTypeDescription
bufferByteBuffer

Source:UI/GComponent.cs (line 1057)

Setup_AfterAdd(ByteBuffer, int)​

public override void Setup_AfterAdd(ByteBuffer buffer, int beginPos);
ParameterTypeDescription
bufferByteBuffer
beginPosint

Source:UI/GComponent.cs (line 1627)

ShouldSnapToNext(float, float, float)​

protected bool ShouldSnapToNext(float dir, float delta, float size);
ParameterTypeDescription
dirfloat
deltafloat
sizefloat

Source:UI/GComponent.cs (line 1252)

SwapChildren(GObject, GObject)​

public void SwapChildren(GObject child1, GObject child2);

Swaps the indexes of two children.

ParameterTypeDescription
child1GObjectA child object
child2GObjectA child object

Source:UI/GComponent.cs (line 613)

SwapChildrenAt(int, int)​

public void SwapChildrenAt(int index1, int index2);

Swaps the indexes of two children.

ParameterTypeDescription
index1intindex of first child
index2intindex of second child

Source:UI/GComponent.cs (line 627)

UpdateBounds()​

virtual protected void UpdateBounds();

Source:UI/GComponent.cs (line 1155)

Properties​

Controllers​

public List<Controller> Controllers { get; }

Returns controller list.

returns

Controller list

Source:UI/GComponent.cs (line 749)

Transitions​

public List<Transition> Transitions { get; }

Returns transition list.

returns

Transition list

Source:UI/GComponent.cs (line 786)

apexIndex​

public int apexIndex { get; set; }

Source:UI/GComponent.cs (line 185)

baseUserData​

public string baseUserData { get; }

Source:UI/GComponent.cs (line 1015)

childrenRenderOrder​

public ChildrenRenderOrder childrenRenderOrder { get; set; }

Source:UI/GComponent.cs (line 169)

clipSoftness​

public Vector2 clipSoftness { get; set; }

If clipping softness is set, clipped containers will have soft border effect.

Source:UI/GComponent.cs (line 974)

container​

public Container container { get; protected set; }

Content container. If the component is not clipped, then container==rootContainer.

Source:UI/GComponent.cs (line 23)

fairyBatching​

public bool fairyBatching { get; set; }

Draw call optimization switch.

Source:UI/GComponent.cs (line 123)

margin​

public Margin margin { get; set; }

Source:UI/GComponent.cs (line 154)

mask​

public DisplayObject mask { get; set; }

The mask of the component.

Source:UI/GComponent.cs (line 992)

numChildren​

public int numChildren { get; }

The number of children of this component.

Source:UI/GComponent.cs (line 639)

onDrop​

public EventListener onDrop { get; }

Dispatched when an object was dragged and dropped to this component.

Source:UI/GComponent.cs (line 115)

opaque​

public bool opaque { get; set; }

If true, mouse/touch events cannot pass through the empty area of the component. Default is true.

Source:UI/GComponent.cs (line 144)

reversedMask​

public bool reversedMask { get; set; }

Source:UI/GComponent.cs (line 1006)

rootContainer​

public Container rootContainer { get; private set; }

Root container.

Source:UI/GComponent.cs (line 19)

scrollPane​

public ScrollPane scrollPane { get; private set; }

ScrollPane of the component. If the component is not scrollable, the value is null.

Source:UI/GComponent.cs (line 27)

tabStopChildren​

public bool tabStopChildren { get; set; }

If true, children can be navigated by TAB from first to last, and repeat

Source:UI/GComponent.cs (line 203)

viewHeight​

public float viewHeight { get; set; }

View port height of the container.

Source:UI/GComponent.cs (line 1228)

viewWidth​

public float viewWidth { get; set; }

Viwe port width of the container.

Source:UI/GComponent.cs (line 1206)