Version: 2021.3

CanvasRenderer

class in UnityEngine

/

继承自:Component

切换到手册

描述

附加到一个 Canvas 后,在完成所有正常渲染后将渲染到屏幕的组件。专为 GUI 应用程序设计。

另请参阅:Canvas

变量

absoluteDepth渲染器相对于根画布的深度。
clippingSoftnessThe clipping softness to apply to the renderer.
cull指示是否忽略该渲染器发射的几何形状。
cullTransparentMesh指示当网格的每个顶点的顶点颜色 Alpha 接近零时,是否可以忽略此渲染器发射的几何形状。
hasMoved如果发生的任何更改会使生成的几何形状的位置无效,则为 true。
hasPopInstruction启用“渲染堆栈”弹出绘制调用。
hasRectClipping如果在该渲染器上启用了矩形裁剪,则为 true。 另请参阅:CanvasRenderer.EnableRectClipping、CanvasRenderer.DisableRectClipping。
materialCount该渲染器可使用的材质数量。
popMaterialCount该渲染器可使用的材质数量。内部用于遮罩。
relativeDepth渲染器相对于父画布的深度。

公共函数

Clear删除所有缓存的顶点。
DisableRectClipping禁用该 CanvasRenderer 的矩形裁剪。
EnableRectClipping在该 CanvasRendered 上启用矩形裁剪。将对位于指定矩形外的几何形状进行裁剪(不渲染)。
GetAlpha获取渲染器的当前 Alpha。
GetColor获取渲染器的当前颜色。
GetInheritedAlpha通过包含所提供的父 CanvasGroups 中的所有父 Alpha 来计算最终继承的 Alpha。
GetMaterial获取指定给 CanvasRenderer 的当前 Material。
GetPopMaterial获取指定给 CanvasRenderer 的当前 Material。内部用于遮罩。
SetAlpha设置渲染器的 Alpha。将与 UIVertex Alpha 和 Canvas Alpha 相乘。
SetAlphaTexture将在 _AlphaTex 属性下传递给着色器的 Alpha 纹理。
SetColor设置渲染器的颜色。将与 UIVertex 颜色和 Canvas 颜色相乘。
SetMaterial设置画布渲染器的材质。如果指定了纹理,则将其用作 'MainTex' 而不是材质的 'MainTex'。 另请参阅:CanvasRenderer.SetMaterialCount、CanvasRenderer.SetTexture。
SetMesh设置渲染器使用的网格。注意,网格必须支持读取/写入。
SetPopMaterial设置画布渲染器的材质。内部用于遮罩。
SetTexture设置该渲染器的材质使用的纹理。

静态函数

AddUIVertexStream接受顶点流并将其拆分为相应的数组(positions、colors、uv0s、uv1s、normals 和 tangents)。
CreateUIVertexStream将一组顶点分量转换为 UIVertex 流。
SplitUIVertexStreams给定一个 UIVertex 列表,将流拆分为其分量类型。

Events

onRequestRebuild(仅限 Editor)每当 CanvasRenderer 中的数据失效并需要重建时触发的事件。

继承的成员

变量

gameObject此组件附加到的游戏对象。始终将组件附加到游戏对象。
tag此游戏对象的标签。
transform附加到此 GameObject 的 Transform。
hideFlags该对象应该隐藏、随场景一起保存还是由用户修改?
name对象的名称。

公共函数

BroadcastMessage调用此游戏对象或其任何子项中的每个 MonoBehaviour 上名为 methodName 的方法。
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentReturns the component of type if the GameObject has one attached.
GetComponentInChildrenReturns the Component of type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the Component of type in the GameObject or any of its parents.
GetComponents返回 GameObject 中类型为 type 的所有组件。
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children using depth first search. Works recursively.
GetComponentsInParent返回 GameObject 或其任何父项中类型为 type 的所有组件。
SendMessage调用此游戏对象中的每个 MonoBehaviour 上名为 methodName 的方法。
SendMessageUpwards调用此游戏对象中的每个 MonoBehaviour 上或此行为的每个父级上名为 methodName 的方法。
TryGetComponent获取指定类型的组件(如果存在)。
GetInstanceIDGets the instance ID of the object.
ToString返回对象的名称。

静态函数

Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。

运算符

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。