Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Component.renderer

var renderer: Renderer;
Renderer renderer;
renderer as Renderer

Description

The Renderer attached to this GameObject (null if there is none attached).

	renderer.material.color = Color.red;
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        renderer.material.color = Color.red;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void:
		renderer.material.color = Color.red