I am trying to change colour of cube from start function. I enter this c# script, attached it to cube, but the colour does not change. Can someone please explain why?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playercolor : MonoBehaviour
{
public GameObject cube;
// Start is called before the first frame update
void Start()
{
cube.GetComponent<Renderer>().material.color = Color.red;
}
// Update is called once per frame
void Update()
{
}
}