[英]How to change a UI.Button disabled color on runtime?
我想用這個精確循環中的代碼更改按鈕禁用顏色的不透明度,所以我想知道怎么做? 也許就像我如何禁用交互性一樣。 tictactoeSpaces 也應該這樣做。
for(int i = 0; i < tictactoeSpaces.Length; i++)
{
tictactoeSpaces[i].interactable = false;
}
是否需要通過代碼?
您實際上可以在Button
組件的 Inspector 中配置它
如果您確實需要在運行時執行此操作,您可以通過Button.colors
屬性更改它,例如
var button = tictactoeSpaces[i];
var colors = button.colors;
var disabledColor = colors.disabledColor;
disabledColor.a = /*NEWALPHA e.g.*/ 0.2f;
colors.disabledColor = disabledColor;
button.colors = colors;
button.interactable = false;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.