The Renderer class in Unity serves as the control center for displaying and customizing 3D objects. Integral to creating immersive game environments, it's the stage director that dictates how each Mesh object appears on the screen.
Employing the power of Materials and their attached Shaders, the Renderer class not only determines what you see on the screen but how you see it. It shapes the visual attributes of every object from their color and texture to their response to lighting, painting a visual symphony for players to interact with. Renderer is the foundational base to the functional renderers you will be using like Class.MeshRenderer or Class.TrailRenderer.
This class is the secret sauce in delivering visually compelling and immersive gaming experiences. Take a deeper exploration into its capabilities with the official Unity Renderer documentation. It reveals the nitty-gritty of leveraging this class effectively in Unity game creation.
Properties
allowOcclusionWhenDynamic is a toggle for advanced use. If true, dynamic occlusion culling will be performed for this Renderer.
Unity's Renderer.allowOcclusionWhenDynamic Documentation
The bounds property is a read-only attribute that provides the access-aligned 3D bounding box that fully encompasses the object in the world space. Unity's Renderer.bounds Documentation
The enabled property determines whether this renderer is enabled or not. If false, Renderer will not produce any rendering output. Unity's Renderer.enabled Documentation
If forceRenderingOff is true, rendering is forced off and will not be updated. This might be used for complex scenarios where you need full control over the rendering.
Unity's Renderer.forceRenderingOff Documentation
The read-only property isPartOfStaticBatch determines if this Renderer is part of a static batch.
Unity's Renderer.isPartOfStaticBatch Documentation
The isVisible property indicates whether the Renderer is visible from any camera. Unity's Renderer.isVisible Documentation
The GameObject assigned to lightProbeProxyVolumeOverride property will provide light probe Proxy Volume’s settings to this Renderer.
Unity's Renderer.lightProbeProxyVolumeOverride Documentation
lightmapIndex allows you to set a specific lightmap to this Renderer.
Unity's Renderer.lightmapIndex Documentation
lightmapScaleOffset is a four-dimensional vector that modifies how the object blends with static lightmaps.
Unity's Renderer.lightmapScaleOffset Documentation
The localBounds property is a read-only attribute that aids in obtaining the local bounding volume of the Renderer. Unity's Renderer.localBounds Documentation
localToWorldMatrix property gives a matrix that transforms a point from local space into world space.
Unity's Renderer.localToWorldMatrix Documentation
material property allows getting or setting the material to the renderer dynamically at runtime. Note that this creates a new instance of the material, impacting performance and memory.
Unity's Renderer.material Documentation
The GameObject assigned to probeAnchor property will be used to find the light or reflection probe. If nothing is assigned, the Renderer’s GameObject’s Transform will be used for this.
Unity's Renderer.probeAnchor Documentation
realtimeLightmapIndex property provides the ability to set a specific real-time lightmap to use for this Renderer.
Unity's Renderer.realtimeLightmapIndex Documentation
realtimeLightmapScaleOffset is a four-dimensional vector property that modifies how 3D objects blend with real-time lightmaps.
Unity's Renderer.realtimeLightmapScaleOffset Documentation
receiveShadows property is a toggle to control whether the object will receive shadows by casting objects.
Unity's Renderer.receiveShadows Documentation
The rendererPriority property allows you to override the render order for this particular Renderer.
Unity's Renderer.rendererPriority Documentation
renderingLayerMask represents custom Light Layer this Renderer uses.
Unity's Renderer.renderingLayerMask Documentation
With sharedMaterial property, it lets you directly access the material used by the renderer. This avoids creating a new instance of the material and is more performance-friendly.
Unity's Renderer.sharedMaterial Documentation
sortingLayerID gives read/write access to the unique ID for the Renderer's sorting layer.
Unity's Renderer.sortingLayerID Documentation
sortingLayerName controls the name of the Renderer's sorting layer.
Unity's Renderer.sortingLayerName Documentation
sortingOrder property controls the Renderer's place in its sorting layer.
Unity's Renderer.sortingOrder Documentation
In case staticShadowCaster is set to true, Renderer will be part of static shadow caster culling even though it is a dynamic Renderer.
Unity's Renderer.staticShadowCaster Documentation
worldToLocalMatrix property provides a matrix that transforms a point from world space into local space.
Unity's Renderer.worldToLocalMatrix Documentation
Methods
HasPropertyBlock method checks if the renderer has a MaterialPropertyBlock assigned to it. MaterialPropertyBlocks are used for changing the material properties without instancing materials.
Unity's Renderer.HasPropertyBlock Documentation
Returns
Returns true if the Renderer has a MaterialPropertyBlock, otherwise false.
This method updates the bounding volume of the renderer (Bounds property) to fully encapsulate the rendered content, including modifications done in the LateUpdate callbacks. Unity's Renderer.ResetBounds Documentation
Returns
The ResetLocalBounds method forcefully updates the local bounding volume of the renderer. It's compulsory to call this manually after changing the geometry of the rendered object.
Unity's Renderer.ResetLocalBounds Documentation
Returns
Parameters
materials
Returns
Parameters
properties
Returns
Parameters
properties
materialIndex
Returns
Parameters
materials
Returns
Updated 18 days ago