This is because colors is a struct and so its returning a copy(value type) which you then apply the normal color to, the compiler is stopping you from writing buggy code.
Make a copy, apply the change and then apply the copy back.
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start ()
{
//Changes the button's Normal color to the new color.
button.colors.normalColor = newColor;
}
}
[[quote=“TonyLi, post:3, topic: 591325, username:TonyLi”]
The example code on the ColorBlock.normalColor documentation page should probably be updated:
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class ExampleClass : MonoBehaviour
{
public Button button;
public Color newColor;
void Start ()
{
//Changes the button's Normal color to the new color.
button.colors.normalColor = newColor;
}
}