I have a lot of objects that have no renderer attached and I need to set the object’s colours at run-time.
object.renderer = new Renderer(); doesnt seem to work…
this is the error i get → Assets/ColouringScript.cs(15,32): error CS0200: Property or indexer `UnityEngine.GameObject.renderer’ cannot be assigned to (it is read only)
you can use
(Renderer is an ABSTRACT class, which means it cannot be added directly, you need to add a class which derives from it)
FYI, the updated way to add a renderer is now gameObject.AddComponent().
The IDE told me the (“T”) version was deprecated.
Thank you, @Seth-Bergman for leading me to the door of the answer!