Things have changed since I last looked at Unity 4.x
I’ve written a script to change the colour of an object at runtime. The colour swatch in the inspector changes from black to blue as expected, but not the object. I’ve assigned the script to the cube in question, but I need to assign the colour to the object - only I’m not sure how.
using UnityEngine;
using System.Collections;
public class ChangeCol : MonoBehaviour
{
public Renderer rend;
public Color nuColor = Color.black;
// Use this for initialization
void Start ()
{
rend = GetComponent<Renderer>();
GameObject myCube = GameObject.Find("Cube");
rend.material.color = nuColor;
}
// Update is called once per frame
void Update ()
{
nuColor = Color.blue;
rend.material.SetColor("_Color", nuColor);
}
}
Thank you.