Version: 2022.3
LanguageEnglish
  • C#

CanvasRenderer

class in UnityEngine

/

Inherits from:Component

/

Implemented in:UnityEngine.UIModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

A component that will render to the screen after all normal rendering has completed when attached to a Canvas. Designed for GUI application.

Additional resources:Canvas.

Properties

absoluteDepthDepth of the renderer relative to the root canvas.
clippingSoftnessThe clipping softness to apply to the renderer.
cullIndicates whether geometry emitted by this renderer is ignored.
cullTransparentMeshIndicates whether geometry emitted by this renderer can be ignored when the vertex color alpha is close to zero for every vertex of the mesh.
hasMovedTrue if any change has occured that would invalidate the positions of generated geometry.
hasPopInstructionEnable 'render stack' pop draw call.
hasRectClippingTrue if rect clipping has been enabled on this renderer. Additional resources: CanvasRenderer.EnableRectClipping, CanvasRenderer.DisableRectClipping.
materialCountThe number of materials usable by this renderer.
popMaterialCountThe number of materials usable by this renderer. Used internally for masking.
relativeDepthDepth of the renderer realative to the parent canvas.

Public Methods

ClearRemove all cached vertices.
DisableRectClippingDisables rectangle clipping for this CanvasRenderer.
EnableRectClippingEnables rect clipping on the CanvasRendered. Geometry outside of the specified rect will be clipped (not rendered).
GetAlphaGet the current alpha of the renderer.
GetColorGet the current color of the renderer.
GetInheritedAlphaGet the final inherited alpha calculated by including all the parent alphas from included parent CanvasGroups.
GetMaterialGets the current Material assigned to the CanvasRenderer.
GetMeshReturns the current mesh used to render the canvas content into.
GetPopMaterialGets the current Material assigned to the CanvasRenderer. Used internally for masking.
SetAlphaSet the alpha of the renderer. Will be multiplied with the UIVertex alpha and the Canvas alpha.
SetAlphaTextureThe Alpha Texture that will be passed to the Shader under the _AlphaTex property.
SetColorSet the color of the renderer. Will be multiplied with the UIVertex color and the Canvas color.
SetMaterialSet 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.
SetMeshSets the Mesh used by this renderer. Note the Mesh must be read/write enabled.
SetPopMaterialSet the material for the canvas renderer. Used internally for masking.
SetTextureSets the texture used by this renderer's material.

Static Methods

AddUIVertexStreamTake the Vertex stream and split it corrisponding arrays (positions, colors, uv0s, uv1s, normals and tangents).
CreateUIVertexStreamConvert a set of vertex components into a stream of UIVertex.
SplitUIVertexStreamsGiven a list of UIVertex, split the stream into it's component types.

Events

onRequestRebuild(Editor Only) Event that gets fired whenever the data in the CanvasRenderer gets invalidated and needs to be rebuilt.

Inherited Members

Properties

gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentGets a reference to a component of type T on the same GameObject as the component specified.
GetComponentInChildrenGets a reference to a component of type T on the same GameObject as the component specified, or any child of the GameObject.
GetComponentIndexGets the index of the component on its parent GameObject.
GetComponentInParentGets a reference to a component of type T on the same GameObject as the component specified, or any parent of the GameObject.
GetComponentsGets references to all components of type T on the same GameObject as the component specified.
GetComponentsInChildrenGets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject.
GetComponentsInParentGets references to all components of type T on the same GameObject as the component specified, and any parent of the GameObject.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.
InstantiateAsyncCaptures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961