Change object colour script

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.

I am a bit confused on what you are doing. Are you trying to assign the color to the cube? It looks like you’re getting the renderer from an object this script is on, then you’re grabbing a cube object, then you’re changing the renderer material color.

Then in update, you’re trying to change the rend color over and over (honestly, not the best way to do that).

However, you really don’t do anything with the cube.