在 NGUI 不工作的情况下在运行时更改 UISprite 色调颜色
Changing the UISprite tint color during runtime with NGUI not working
我有以下代码尝试更改为 UISprite 的色调以指示错误,我可以在检查器中看到色调已更改为红色,但场景中的精灵保持不变,我做了什么错了吗?
private void ShowErr(string errMsg)
{
gameObject.GetComponent<UIWidget>().color = Color.red;
//gameObject.GetComponent<UISprite>().color = Color.green;
transform.GetChild(0).gameObject.SetActive(true);
transform.GetChild(0).GetChild(0).GetComponent<UILabel>().text = errMsg;
}
以下是播放场景的截图,请注意精灵(虚线边框)保持原始颜色但不是预期的红色。
已尝试使用 UIWidget
和 UISprite
更改颜色,两者都适用于检查器,但不适用于游戏场景。
编辑你的精灵为白色而不是黑色,然后你可以设置颜色。
我有以下代码尝试更改为 UISprite 的色调以指示错误,我可以在检查器中看到色调已更改为红色,但场景中的精灵保持不变,我做了什么错了吗?
private void ShowErr(string errMsg)
{
gameObject.GetComponent<UIWidget>().color = Color.red;
//gameObject.GetComponent<UISprite>().color = Color.green;
transform.GetChild(0).gameObject.SetActive(true);
transform.GetChild(0).GetChild(0).GetComponent<UILabel>().text = errMsg;
}
以下是播放场景的截图,请注意精灵(虚线边框)保持原始颜色但不是预期的红色。
已尝试使用 UIWidget
和 UISprite
更改颜色,两者都适用于检查器,但不适用于游戏场景。
编辑你的精灵为白色而不是黑色,然后你可以设置颜色。