我想比较这两个功能
const string RADIO_ON_SPRITE_NAME = "popup_radiobtn01_on";
const string RADIO_OFF_SPRITE_NAME = "popup_radiobtn01_off";
[SerializeField] UIButton livestream = null;
[SerializeField] UIButton render = null;
public void LiveStreaming()
{
if (livestream.normalSprite == RADIO_OFF_SPRITE_NAME)
{
livestream.normalSprite = RADIO_ON_SPRITE_NAME ;
} else
{
livestream.normalSprite = RADIO_OFF_SPRITE_NAME;
}
}
public void Rendering()
{
if (render.normalSprite == RADIO_OFF_SPRITE_NAME)
{
render.normalSprite = RADIO_ON_SPRITE_NAME;
} else
{
render.normalSprite = RADIO_OFF_SPRITE_NAME;
}
}
我在这里要做的是,当选中一个复选框时,不应检查另一个复选框。顺便说一句,我正在使用Unity的NGUI,这是我想要做的事情的图像。
示例图片:
答案 0 :(得分:0)
解决了它
public void LiveStreaming()
{
//livestream.normalSprite = (livestream.normalSprite == RADIO_OFF_SPRITE_NAME) ? RADIO_ON_SPRITE_NAME : RADIO_OFF_SPRITE_NAME;
if (livestream.normalSprite == RADIO_OFF_SPRITE_NAME)
{
livestream.normalSprite = RADIO_ON_SPRITE_NAME;
isChecked = true;
if (isChecked && render.normalSprite == RADIO_ON_SPRITE_NAME)
{
render.normalSprite = RADIO_OFF_SPRITE_NAME;
}
} else
{
livestream.normalSprite = RADIO_OFF_SPRITE_NAME;
isChecked = false;
if (!isChecked && render.normalSprite == RADIO_OFF_SPRITE_NAME)
{
render.normalSprite = RADIO_ON_SPRITE_NAME;
}
}
}
public void Rendering()
{
//render.normalSprite = (render.normalSprite == RADIO_OFF_SPRITE_NAME) ? RADIO_ON_SPRITE_NAME : RADIO_OFF_SPRITE_NAME;
if (render.normalSprite == RADIO_OFF_SPRITE_NAME)
{
render.normalSprite = RADIO_ON_SPRITE_NAME;
isChecked = true;
if (isChecked && livestream.normalSprite == RADIO_ON_SPRITE_NAME)
{
livestream.normalSprite = RADIO_OFF_SPRITE_NAME;
}
} else
{
render.normalSprite = RADIO_OFF_SPRITE_NAME;
isChecked = false;
if (!isChecked && livestream.normalSprite == RADIO_OFF_SPRITE_NAME)
{
livestream.normalSprite = RADIO_ON_SPRITE_NAME;
}
}
}