Skip to main content

Controller

Namespace:FairyGUI
Source:Assets/Scripts/UI/Controller.cs (line 12)

public class Controller : EventDispatcher

Controller class. 控制器类。控制器的创建和设计需通过编辑器完成,不建议使用代码创建。 最常用的方法是通过selectedIndex获得或改变控制器的活动页面。如果要获得控制器页面改变的通知,使用onChanged事件。

Inheritance:EventDispatcher → Controller

Inherited members​

EventDispatcher

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

Constructors​

Controller()​

public Controller();

Source:UI/Controller.cs (line 34)

Fields​

name​

public string name;

Name of the controller 控制器名称。

Source:UI/Controller.cs (line 18)

Methods​

AddPage(string)​

public void AddPage(string name);

Add a new page to this controller.

ParameterTypeDescription
namestringPage name

Source:UI/Controller.cs (line 221)

AddPageAt(string, int)​

public void AddPageAt(string name, int index);

Add a new page to this controller at a certain index.

ParameterTypeDescription
namestringPage name
indexintInsert position

Source:UI/Controller.cs (line 234)

ClearPages()​

public void ClearPages();

Remove all pages.

Source:UI/Controller.cs (line 284)

Dispose()​

public void Dispose();

Source:UI/Controller.cs (line 42)

GetPageId(int)​

public string GetPageId(int index);

Get page id by an index. 通过页面索引获得页面id。

returns

Page Id

ParameterTypeDescription
indexintPage index

Source:UI/Controller.cs (line 198)

GetPageIdByName(string)​

public string GetPageIdByName(string aName);

Get page id by name

ParameterTypeDescription
aNamestring

Source:UI/Controller.cs (line 208)

GetPageName(int)​

public string GetPageName(int index);

Get page name by an index. 通过页面索引获得页面名称。

returns

Page Name

ParameterTypeDescription
indexintPage index

Source:UI/Controller.cs (line 187)

HasPage(string)​

public bool HasPage(string aName);

Check if the controller has a page.

ParameterTypeDescription
aNamestringPage name.

Source:UI/Controller.cs (line 299)

RemovePage(string)​

public void RemovePage(string name);

Remove a page.

ParameterTypeDescription
namestringPage name

Source:UI/Controller.cs (line 253)

RemovePageAt(int)​

public void RemovePageAt(int index);

Removes a page at a certain index.

ParameterTypeDescription
indexint

Source:UI/Controller.cs (line 271)

RunActions()​

public void RunActions();

Source:UI/Controller.cs (line 358)

SetSelectedIndex(int)​

public void SetSelectedIndex(int value);

Set current page index, no onChanged event. 通过索引设置当前活动页面,和selectedIndex的区别在于,这个方法不会触发onChanged事件。

ParameterTypeDescription
valueintPage index

Source:UI/Controller.cs (line 92)

SetSelectedPage(string)​

public void SetSelectedPage(string value);

Set current page by name, no onChanged event. 通过页面名称设置当前活动页面,和selectedPage的区别在于,这个方法不会触发onChanged事件。

ParameterTypeDescription
valuestringPage name

Source:UI/Controller.cs (line 112)

Setup(ByteBuffer)​

public void Setup(ByteBuffer buffer);
ParameterTypeDescription
bufferByteBuffer

Source:UI/Controller.cs (line 370)

Properties​

onChanged​

public EventListener onChanged { get; }

When controller page changed. 当控制器活动页面改变时,此事件被触发。

Source:UI/Controller.cs (line 52)

pageCount​

public int pageCount { get; }

Page count of this controller. 获得页面数量。

Source:UI/Controller.cs (line 176)

previousIndex​

public int previousIndex { get; }

Previouse page index. 获得上次活动页面索引

Source:UI/Controller.cs (line 152)

previousPage​

public string previousPage { get; }

Previous page name. 获得上次活动页面名称。

Source:UI/Controller.cs (line 161)

previsousIndex​

public int previsousIndex { get; }

Source:UI/Controller.cs (line 142)

selectedIndex​

public int selectedIndex { get; set; }

Current page index. 获得或设置当前活动页面索引。

Source:UI/Controller.cs (line 61)

selectedPage​

public string selectedPage { get; set; }

Current page name. 获得当前活动页面名称

Source:UI/Controller.cs (line 124)