CanvasRenderer
A component that will render to the screen after all normal rendering has completed when attached to a Canvas. Designed for GUI application.
Read time 8 minutesLast updated 4 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.UIModule
- Inherits from: Component
public sealed class CanvasRenderer : Component
Remarks
Additional Resources:Canvas.
Properties
Property | Description |
|---|---|
| absoluteDepth | Depth of the renderer relative to the root canvas. |
| clippingSoftness | The clipping softness to apply to the renderer. |
| cull | Indicates whether geometry emitted by this renderer is ignored. |
| cullTransparentMesh | Indicates whether geometry emitted by this renderer can be ignored when the vertex color alpha is close to zero for every vertex of the mesh. |
| hasMoved | True if any change has occured that would invalidate the positions of generated geometry. |
| hasPopInstruction | Enable 'render stack' pop draw call. |
| hasRectClipping | True if rect clipping has been enabled on this renderer. Additional Resources: CanvasRenderer.EnableRectClipping, CanvasRenderer.DisableRectClipping. |
| materialCount | The number of materials usable by this renderer. |
| popMaterialCount | The number of materials usable by this renderer. Used internally for masking. |
| relativeDepth | Depth of the renderer realative to the parent canvas. |
Methods
Method | Description |
|---|---|
| Clear | Remove all cached vertices. |
| DisableRectClipping | Disables rectangle clipping for this CanvasRenderer. |
| EnableRectClipping | Enables rect clipping on the CanvasRendered. Geometry outside of the specified rect will be clipped (not rendered). |
| GetAlpha | Get the current alpha of the renderer. |
| GetColor | Get the current color of the renderer. |
| GetInheritedAlpha | Get the final inherited alpha calculated by including all the parent alphas from included parent CanvasGroups. |
| GetMaterial | Gets the current Material assigned to the CanvasRenderer. |
| GetMesh | Returns the current mesh used to render the canvas content into. |
| GetPopMaterial | Gets the current Material assigned to the CanvasRenderer. Used internally for masking. |
| GetSecondaryTexture | Get the secondary texture at the specifed index. |
| GetSecondaryTextureCount | Get the number of secondary textures usable by this renderer. |
| GetSecondaryTextureName | Get the shader property name of the secondary texture at the specifed index. |
| SetAlpha | Set the alpha of the renderer. Will be multiplied with the UIVertex alpha and the Canvas alpha. |
| SetAlphaTexture | The Alpha Texture that will be passed to the Shader under the _AlphaTex property. |
| SetColor | Set the color of the renderer. Will be multiplied with the UIVertex color and the Canvas color. |
| SetMaterial | Set the material for the canvas renderer. If a texture is specified then it will be used as the 'MainTex' instead of the material's 'MainTex'. Additional Resources: CanvasRenderer.materialCount, CanvasRenderer.SetTexture. |
| SetMesh | Sets the Mesh used by this renderer. Note the Mesh must be read/write enabled. |
| SetPopMaterial | Set the material for the canvas renderer. Used internally for masking. |
| SetSecondaryTexture | Sets the secondary texture usable by this renderer at the specified index with the specified shader property name. |
| SetSecondaryTextureCount | Set the number of secondary textures usable by this renderer. If the size is increased then the new data is initialized with default empty values. |
| SetTexture | Sets the texture used by this renderer's material. |
Static Methods
Method | Description |
|---|---|
| AddUIVertexStream | Take the Vertex stream and split it corrisponding arrays (positions, colors, uv0s, uv1s, normals and tangents). |
| CreateUIVertexStream | Convert a set of vertex components into a stream of UIVertex. |
| SplitUIVertexStreams | Given a list of UIVertex, split the stream into it's component types. |
Static Events
Member | Description |
|---|---|
| onRequestRebuild | (Editor Only) Event that gets fired whenever the data in the CanvasRenderer gets invalidated and needs to be rebuilt. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |