Unity3d NGUI UICheckbox

Unity3d NGUI UICheckbox

单选按钮:

一,常用属性:

1,CheckSprite:选中后,才显示的Sprite,即为“选中”状态;

2,Starts Checked:true,一开始就显示“选中”状态;

3,RadioButtonRoot:一组UICheckbox,在这组UICheckbox中只能是一个被“选中”状态,其它的UICheckbox为“初始”状态;

4,Option Can Be None :true,在“选中”状态下,再次选中,即向“初始”状态转变;为fase,不做任何转变;

5,Function Name:状态改变,提供接口;

二,接口说明:

1:UICheckbox.Set(bool );

state:true,"选中"状态;

UICheckbox.Set (bool state){

mChecked = state;

if (onStateChange != null) onStateChange(mChecked);

if (eventReceiver != null && !string.IsNullOrEmpty(functionName))

{

current = this;

eventReceiver.SendMessage(functionName, mChecked, SendMessageOptions.DontRequireReceiver);

}

}

 

2:UICheckbox.

public OnStateChange onStateChange;

UICheckbox的OnStateChange,NGUI自动提供一个脚本:

UICheckboxControlledComponent.cs;当UICheckbox 运行:if (onStateChange != null) onStateChange(mChecked);

自动运行 UICheckboxControlledComponent的

void OnActivateDelegate (bool isActive)

{

if (enabled && target != null) target.enabled = inverse ? !isActive : isActive;

}

 

你可能感兴趣的:(checkbox)