Class Graphic
Base class for all UI components that should be derived from when creating new Graphic types.
Implements
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
[ExecuteAlways]
public abstract class Graphic : UIBehaviour, ICanvasElement
Constructors
| Name | Description |
|---|---|
| Graphic() |
Fields
| Name | Description |
|---|---|
| m_CachedMesh | |
| m_CachedUvs | |
| m_Material | |
| m_OnDirtyLayoutCallback | |
| m_OnDirtyMaterialCallback | |
| m_OnDirtyVertsCallback | |
| m_SkipLayoutUpdate | |
| m_SkipMaterialUpdate | |
| s_DefaultUI | |
| s_Mesh | |
| s_WhiteTexture |
Properties
| Name | Description |
|---|---|
| canvas | A reference to the Canvas this Graphic is rendering to. |
| canvasRenderer | A reference to the CanvasRenderer populated by this Graphic. |
| color | Base color of the Graphic. |
| defaultGraphicMaterial | Default material used to draw UI elements if no explicit material was specified. |
| defaultMaterial | Returns the default material for the graphic. |
| depth | Absolute depth of the graphic, used by rendering and events -- lowest to highest. |
| mainTexture | The graphic's texture. (Read Only). |
| material | The Material set by the user |
| materialForRendering | The material that will be sent for Rendering (Read only). |
| raycastPadding | Padding to be applied to the masking X = Left Y = Bottom Z = Right W = Top |
| raycastTarget | Should this graphic be considered a target for raycasting? |
| rectTransform | The RectTransform component used by the Graphic. Cached for speed. |
| useLegacyMeshGeneration | |
| workerMesh |
Methods
| Name | Description |
|---|---|
| CrossFadeAlpha(float, float, bool) | Tweens the alpha of the CanvasRenderer color associated with this Graphic. |
| CrossFadeColor(Color, float, bool, bool) | Tweens the CanvasRenderer color associated with this Graphic. |
| CrossFadeColor(Color, float, bool, bool, bool) | Tweens the CanvasRenderer color associated with this Graphic. |
| GetPixelAdjustedRect() | Returns a pixel perfect Rect closest to the Graphic RectTransform. |
| GraphicUpdateComplete() | Callback sent when this ICanvasElement has completed Graphic rebuild. |
| LayoutComplete() | Callback sent when this ICanvasElement has completed layout. |
| OnBeforeTransformParentChanged() | |
| OnCanvasHierarchyChanged() | Called when the state of the parent Canvas is changed. |
| OnCullingChanged() | This method must be called when |
| OnDestroy() | |
| OnDidApplyAnimationProperties() | |
| OnDisable() | Clear references. |
| OnEnable() | Mark the Graphic and the canvas as having been changed. |
| OnPopulateMesh(Mesh) | |
| OnPopulateMesh(VertexHelper) | Callback function when a UI element needs to generate vertices. Fills the vertex buffer data. |
| OnRebuildRequested() | Editor-only callback that is issued by Unity if a rebuild of the Graphic is required. Currently sent when an asset is reimported. |
| OnRectTransformDimensionsChange() | This callback is called when the dimensions of an associated RectTransform change. It is always called before Awake, OnEnable, or Start. The call is also made to all child RectTransforms, regardless of whether their dimensions change (which depends on how they are anchored). |
| OnTransformParentChanged() | |
| OnValidate() | |
| PixelAdjustPoint(Vector2) | Adjusts the given pixel to be pixel perfect. |
| Raycast(Vector2, Camera) | When a GraphicRaycaster is raycasting into the scene it does two things. First it filters the elements using their RectTransform rect. Then it uses this Raycast function to determine the elements hit by the raycast. |
| Rebuild(CanvasUpdate) | Rebuilds the graphic geometry and its material on the PreRender cycle. |
| RegisterDirtyLayoutCallback(UnityAction) | Add a listener to receive notification when the graphics layout is dirtied. |
| RegisterDirtyMaterialCallback(UnityAction) | Add a listener to receive notification when the graphics material is dirtied. |
| RegisterDirtyVerticesCallback(UnityAction) | Add a listener to receive notification when the graphics vertices are dirtied. |
| Reset() | |
| SetAllDirty() | Set all properties of the Graphic dirty and needing rebuilt. Dirties Layout, Vertices, and Materials. |
| SetLayoutDirty() | Mark the layout as dirty and needing rebuilt. |
| SetMaterialDirty() | Mark the material as dirty and needing rebuilt. |
| SetNativeSize() | Make the Graphic have the native size of its content. |
| SetRaycastDirty() | |
| SetVerticesDirty() | Mark the vertices as dirty and needing rebuilt. |
| UnregisterDirtyLayoutCallback(UnityAction) | Remove a listener from receiving notifications when the graphics layout are dirtied |
| UnregisterDirtyMaterialCallback(UnityAction) | Remove a listener from receiving notifications when the graphics material are dirtied |
| UnregisterDirtyVerticesCallback(UnityAction) | Remove a listener from receiving notifications when the graphics vertices are dirtied |
| UpdateGeometry() | Call to update the geometry of the Graphic onto the CanvasRenderer. |
| UpdateMaterial() | Call to update the Material of the graphic onto the CanvasRenderer. |