我想从脚本中更改画布的背景颜色。以下脚本附加到画布:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CanvasController : MonoBehaviour {
Color lightBlue = new Color(173, 222, 246);
Color purple = new Color(107, 62, 143, 255);
void Start () {
Image img = transform.GetComponent<Image>();
img.color = lightBlue;
}
void Update () {
}
}
然而,当我按下播放时,颜色变为白色,我得到两个错误:
无效的标准化颜色:RGBA(107.000,62.000,143.000,1.000),标准化值:0
UnityEditor.DockArea:OnGUI()使用非标准化颜色设置标准化颜色:RGBA(107.000,62.000,143.000,1.000)
UnityEditor.DockArea:OnGUI()