docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Graphic

    Base class for all UI components that should be derived from when creating new Graphic types.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    UIBehaviour
    Graphic
    MaskableGraphic
    ConcreteGraphic
    Implements
    ICanvasElement
    Inherited Members
    UIBehaviour.Awake()
    UIBehaviour.Start()
    UIBehaviour.IsActive()
    UIBehaviour.OnCanvasGroupChanged()
    UIBehaviour.IsDestroyed()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.didStart
    MonoBehaviour.didAwake
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.CompareTag(TagHandle)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.UI
    Assembly: UnityEngine.UI.dll
    Syntax
    [DisallowMultipleComponent]
    [RequireComponent(typeof(RectTransform))]
    [ExecuteAlways]
    public abstract class Graphic : UIBehaviour, ICanvasElement

    Constructors

    Graphic()

    Declaration
    protected Graphic()

    Fields

    m_CachedMesh

    Declaration
    [NonSerialized]
    protected Mesh m_CachedMesh
    Field Value
    Type Description
    Mesh

    m_CachedUvs

    Declaration
    [NonSerialized]
    protected Vector2[] m_CachedUvs
    Field Value
    Type Description
    Vector2[]

    m_Material

    Declaration
    [FormerlySerializedAs("m_Mat")]
    [SerializeField]
    protected Material m_Material
    Field Value
    Type Description
    Material

    m_OnDirtyLayoutCallback

    Declaration
    [NonSerialized]
    protected UnityAction m_OnDirtyLayoutCallback
    Field Value
    Type Description
    UnityAction

    m_OnDirtyMaterialCallback

    Declaration
    [NonSerialized]
    protected UnityAction m_OnDirtyMaterialCallback
    Field Value
    Type Description
    UnityAction

    m_OnDirtyVertsCallback

    Declaration
    [NonSerialized]
    protected UnityAction m_OnDirtyVertsCallback
    Field Value
    Type Description
    UnityAction

    m_SkipLayoutUpdate

    Declaration
    [NonSerialized]
    protected bool m_SkipLayoutUpdate
    Field Value
    Type Description
    bool

    m_SkipMaterialUpdate

    Declaration
    [NonSerialized]
    protected bool m_SkipMaterialUpdate
    Field Value
    Type Description
    bool

    s_DefaultUI

    Declaration
    protected static Material s_DefaultUI
    Field Value
    Type Description
    Material

    s_Mesh

    Declaration
    [NonSerialized]
    protected static Mesh s_Mesh
    Field Value
    Type Description
    Mesh

    s_WhiteTexture

    Declaration
    protected static Texture2D s_WhiteTexture
    Field Value
    Type Description
    Texture2D

    Properties

    canvas

    A reference to the Canvas this Graphic is rendering to.

    Declaration
    public Canvas canvas { get; }
    Property Value
    Type Description
    Canvas
    Remarks

    In the situation where the Graphic is used in a hierarchy with multiple Canvases, the Canvas closest to the root will be used.

    canvasRenderer

    A reference to the CanvasRenderer populated by this Graphic.

    Declaration
    public CanvasRenderer canvasRenderer { get; }
    Property Value
    Type Description
    CanvasRenderer

    color

    Base color of the Graphic.

    Declaration
    public virtual Color color { get; set; }
    Property Value
    Type Description
    Color
    Remarks

    The builtin UI Components use this as their vertex color. Use this to fetch or change the Color of visual UI elements, such as an Image.

    Examples
    //Place this script on a GameObject with a Graphic component attached e.g. a visual UI element (Image).
    
    using UnityEngine;
    using UnityEngine.UI;
    
    public class Example : MonoBehaviour
    {
        Graphic m_Graphic;
        Color m_MyColor;
    
        void Start()
        {
            //Fetch the Graphic from the GameObject
            m_Graphic = GetComponent<Graphic>();
            //Create a new Color that starts as red
            m_MyColor = Color.red;
            //Change the Graphic Color to the new Color
            m_Graphic.color = m_MyColor;
        }
    
        // Update is called once per frame
        void Update()
        {
            //When the mouse button is clicked, change the Graphic Color
            if (Input.GetKey(KeyCode.Mouse0))
            {
                //Change the Color over time between blue and red while the mouse button is pressed
                m_MyColor = Color.Lerp(Color.red, Color.blue, Mathf.PingPong(Time.time, 1));
            }
            //Change the Graphic Color to the new Color
            m_Graphic.color = m_MyColor;
        }
    }

    defaultGraphicMaterial

    Default material used to draw UI elements if no explicit material was specified.

    Declaration
    public static Material defaultGraphicMaterial { get; }
    Property Value
    Type Description
    Material

    defaultMaterial

    Returns the default material for the graphic.

    Declaration
    public virtual Material defaultMaterial { get; }
    Property Value
    Type Description
    Material

    depth

    Absolute depth of the graphic, used by rendering and events -- lowest to highest.

    Declaration
    public int depth { get; }
    Property Value
    Type Description
    int
    Examples

    The depth is relative to the first root canvas.

    Canvas Graphic - 1 Graphic - 2 Nested Canvas Graphic - 3 Graphic - 4 Graphic - 5

    This value is used to determine draw and event ordering.

    mainTexture

    The graphic's texture. (Read Only).

    Declaration
    public virtual Texture mainTexture { get; }
    Property Value
    Type Description
    Texture
    Remarks

    This is the Texture that gets passed to the CanvasRenderer, Material and then Shader _MainTex.

    When implementing your own Graphic you can override this to control which texture goes through the UI Rendering pipeline.

    Bear in mind that Unity tries to batch UI elements together to improve performance, so its ideal to work with atlas to reduce the number of draw calls.

    material

    The Material set by the user

    Declaration
    public virtual Material material { get; set; }
    Property Value
    Type Description
    Material

    materialForRendering

    The material that will be sent for Rendering (Read only).

    Declaration
    public virtual Material materialForRendering { get; }
    Property Value
    Type Description
    Material
    Remarks

    This is the material that actually gets sent to the CanvasRenderer. By default it's the same as [[Graphic.material]]. When extending Graphic you can override this to send a different material to the CanvasRenderer than the one set by Graphic.material. This is useful if you want to modify the user set material in a non destructive manner.

    raycastPadding

    Padding to be applied to the masking X = Left Y = Bottom Z = Right W = Top

    Declaration
    public Vector4 raycastPadding { get; set; }
    Property Value
    Type Description
    Vector4

    raycastTarget

    Should this graphic be considered a target for raycasting?

    Declaration
    public virtual bool raycastTarget { get; set; }
    Property Value
    Type Description
    bool

    rectTransform

    The RectTransform component used by the Graphic. Cached for speed.

    Declaration
    public RectTransform rectTransform { get; }
    Property Value
    Type Description
    RectTransform

    useLegacyMeshGeneration

    Declaration
    protected bool useLegacyMeshGeneration { get; set; }
    Property Value
    Type Description
    bool

    workerMesh

    Declaration
    protected static Mesh workerMesh { get; }
    Property Value
    Type Description
    Mesh

    Methods

    CrossFadeAlpha(float, float, bool)

    Tweens the alpha of the CanvasRenderer color associated with this Graphic.

    Declaration
    public virtual void CrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
    Parameters
    Type Name Description
    float alpha

    Target alpha.

    float duration

    Duration of the tween in seconds.

    bool ignoreTimeScale

    Should ignore [[Time.scale]]?

    CrossFadeColor(Color, float, bool, bool)

    Tweens the CanvasRenderer color associated with this Graphic.

    Declaration
    public virtual void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
    Parameters
    Type Name Description
    Color targetColor

    Target color.

    float duration

    Tween duration.

    bool ignoreTimeScale

    Should ignore Time.scale?

    bool useAlpha

    Should also Tween the alpha channel?

    CrossFadeColor(Color, float, bool, bool, bool)

    Tweens the CanvasRenderer color associated with this Graphic.

    Declaration
    public virtual void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB)
    Parameters
    Type Name Description
    Color targetColor

    Target color.

    float duration

    Tween duration.

    bool ignoreTimeScale

    Should ignore Time.scale?

    bool useAlpha

    Should also Tween the alpha channel?

    bool useRGB

    Should the color or the alpha be used to tween

    GetPixelAdjustedRect()

    Returns a pixel perfect Rect closest to the Graphic RectTransform.

    Declaration
    public Rect GetPixelAdjustedRect()
    Returns
    Type Description
    Rect

    A Pixel perfect Rect.

    Remarks

    Note: This is only accurate if the Graphic root Canvas is in Screen Space.

    GraphicUpdateComplete()

    Callback sent when this ICanvasElement has completed Graphic rebuild.

    Declaration
    public virtual void GraphicUpdateComplete()

    LayoutComplete()

    Callback sent when this ICanvasElement has completed layout.

    Declaration
    public virtual void LayoutComplete()

    OnBeforeTransformParentChanged()

    Declaration
    protected override void OnBeforeTransformParentChanged()
    Overrides
    UIBehaviour.OnBeforeTransformParentChanged()

    OnCanvasHierarchyChanged()

    Called when the state of the parent Canvas is changed.

    Declaration
    protected override void OnCanvasHierarchyChanged()
    Overrides
    UIBehaviour.OnCanvasHierarchyChanged()

    OnCullingChanged()

    This method must be called when CanvasRenderer.cull is modified.

    Declaration
    public virtual void OnCullingChanged()
    Remarks

    This can be used to perform operations that were previously skipped because the Graphic was culled.

    OnDestroy()

    Declaration
    protected override void OnDestroy()
    Overrides
    UIBehaviour.OnDestroy()

    OnDidApplyAnimationProperties()

    Declaration
    protected override void OnDidApplyAnimationProperties()
    Overrides
    UIBehaviour.OnDidApplyAnimationProperties()

    OnDisable()

    Clear references.

    Declaration
    protected override void OnDisable()
    Overrides
    UIBehaviour.OnDisable()

    OnEnable()

    Mark the Graphic and the canvas as having been changed.

    Declaration
    protected override void OnEnable()
    Overrides
    UIBehaviour.OnEnable()

    OnPopulateMesh(Mesh)

    Declaration
    [Obsolete("Use OnPopulateMesh(VertexHelper vh) instead.", false)]
    protected virtual void OnPopulateMesh(Mesh m)
    Parameters
    Type Name Description
    Mesh m

    OnPopulateMesh(VertexHelper)

    Callback function when a UI element needs to generate vertices. Fills the vertex buffer data.

    Declaration
    protected virtual void OnPopulateMesh(VertexHelper vh)
    Parameters
    Type Name Description
    VertexHelper vh

    VertexHelper utility.

    Remarks

    Used by Text, UI.Image, and RawImage for example to generate vertices specific to their use case.

    OnRebuildRequested()

    Editor-only callback that is issued by Unity if a rebuild of the Graphic is required. Currently sent when an asset is reimported.

    Declaration
    public virtual void OnRebuildRequested()

    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).

    Declaration
    protected override void OnRectTransformDimensionsChange()
    Overrides
    UIBehaviour.OnRectTransformDimensionsChange()

    OnTransformParentChanged()

    Declaration
    protected override void OnTransformParentChanged()
    Overrides
    UIBehaviour.OnTransformParentChanged()

    OnValidate()

    Declaration
    protected override void OnValidate()
    Overrides
    UIBehaviour.OnValidate()

    PixelAdjustPoint(Vector2)

    Adjusts the given pixel to be pixel perfect.

    Declaration
    public Vector2 PixelAdjustPoint(Vector2 point)
    Parameters
    Type Name Description
    Vector2 point

    Local space point.

    Returns
    Type Description
    Vector2

    Pixel perfect adjusted point.

    Remarks

    Note: This is only accurate if the Graphic root Canvas is in Screen Space.

    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.

    Declaration
    public virtual bool Raycast(Vector2 sp, Camera eventCamera)
    Parameters
    Type Name Description
    Vector2 sp

    Screen point being tested

    Camera eventCamera

    Camera that is being used for the testing.

    Returns
    Type Description
    bool

    True if the provided point is a valid location for GraphicRaycaster raycasts.

    Rebuild(CanvasUpdate)

    Rebuilds the graphic geometry and its material on the PreRender cycle.

    Declaration
    public virtual void Rebuild(CanvasUpdate update)
    Parameters
    Type Name Description
    CanvasUpdate update

    The current step of the rendering CanvasUpdate cycle.

    Remarks

    See CanvasUpdateRegistry for more details on the canvas update cycle.

    RegisterDirtyLayoutCallback(UnityAction)

    Add a listener to receive notification when the graphics layout is dirtied.

    Declaration
    public void RegisterDirtyLayoutCallback(UnityAction action)
    Parameters
    Type Name Description
    UnityAction action

    The method to call when invoked.

    RegisterDirtyMaterialCallback(UnityAction)

    Add a listener to receive notification when the graphics material is dirtied.

    Declaration
    public void RegisterDirtyMaterialCallback(UnityAction action)
    Parameters
    Type Name Description
    UnityAction action

    The method to call when invoked.

    RegisterDirtyVerticesCallback(UnityAction)

    Add a listener to receive notification when the graphics vertices are dirtied.

    Declaration
    public void RegisterDirtyVerticesCallback(UnityAction action)
    Parameters
    Type Name Description
    UnityAction action

    The method to call when invoked.

    Reset()

    Declaration
    protected override void Reset()
    Overrides
    UIBehaviour.Reset()

    SetAllDirty()

    Set all properties of the Graphic dirty and needing rebuilt. Dirties Layout, Vertices, and Materials.

    Declaration
    public virtual void SetAllDirty()

    SetLayoutDirty()

    Mark the layout as dirty and needing rebuilt.

    Declaration
    public virtual void SetLayoutDirty()
    Remarks

    Send a OnDirtyLayoutCallback notification if any elements are registered. See RegisterDirtyLayoutCallback

    SetMaterialDirty()

    Mark the material as dirty and needing rebuilt.

    Declaration
    public virtual void SetMaterialDirty()
    Remarks

    Send a OnDirtyMaterialCallback notification if any elements are registered. See RegisterDirtyMaterialCallback

    SetNativeSize()

    Make the Graphic have the native size of its content.

    Declaration
    public virtual void SetNativeSize()

    SetRaycastDirty()

    Declaration
    public void SetRaycastDirty()

    SetVerticesDirty()

    Mark the vertices as dirty and needing rebuilt.

    Declaration
    public virtual void SetVerticesDirty()
    Remarks

    Send a OnDirtyVertsCallback notification if any elements are registered. See RegisterDirtyVerticesCallback

    UnregisterDirtyLayoutCallback(UnityAction)

    Remove a listener from receiving notifications when the graphics layout are dirtied

    Declaration
    public void UnregisterDirtyLayoutCallback(UnityAction action)
    Parameters
    Type Name Description
    UnityAction action

    The method to call when invoked.

    UnregisterDirtyMaterialCallback(UnityAction)

    Remove a listener from receiving notifications when the graphics material are dirtied

    Declaration
    public void UnregisterDirtyMaterialCallback(UnityAction action)
    Parameters
    Type Name Description
    UnityAction action

    The method to call when invoked.

    UnregisterDirtyVerticesCallback(UnityAction)

    Remove a listener from receiving notifications when the graphics vertices are dirtied

    Declaration
    public void UnregisterDirtyVerticesCallback(UnityAction action)
    Parameters
    Type Name Description
    UnityAction action

    The method to call when invoked.

    UpdateGeometry()

    Call to update the geometry of the Graphic onto the CanvasRenderer.

    Declaration
    protected virtual void UpdateGeometry()

    UpdateMaterial()

    Call to update the Material of the graphic onto the CanvasRenderer.

    Declaration
    protected virtual void UpdateMaterial()

    Implements

    ICanvasElement

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • Graphic()
    • Fields
      • m_CachedMesh
      • m_CachedUvs
      • m_Material
      • m_OnDirtyLayoutCallback
      • m_OnDirtyMaterialCallback
      • m_OnDirtyVertsCallback
      • m_SkipLayoutUpdate
      • m_SkipMaterialUpdate
      • s_DefaultUI
      • s_Mesh
      • s_WhiteTexture
    • Properties
      • canvas
      • canvasRenderer
      • color
      • defaultGraphicMaterial
      • defaultMaterial
      • depth
      • mainTexture
      • material
      • materialForRendering
      • raycastPadding
      • raycastTarget
      • rectTransform
      • useLegacyMeshGeneration
      • workerMesh
    • Methods
      • CrossFadeAlpha(float, float, bool)
      • CrossFadeColor(Color, float, bool, bool)
      • CrossFadeColor(Color, float, bool, bool, bool)
      • GetPixelAdjustedRect()
      • GraphicUpdateComplete()
      • LayoutComplete()
      • OnBeforeTransformParentChanged()
      • OnCanvasHierarchyChanged()
      • OnCullingChanged()
      • OnDestroy()
      • OnDidApplyAnimationProperties()
      • OnDisable()
      • OnEnable()
      • OnPopulateMesh(Mesh)
      • OnPopulateMesh(VertexHelper)
      • OnRebuildRequested()
      • OnRectTransformDimensionsChange()
      • OnTransformParentChanged()
      • OnValidate()
      • PixelAdjustPoint(Vector2)
      • Raycast(Vector2, Camera)
      • Rebuild(CanvasUpdate)
      • RegisterDirtyLayoutCallback(UnityAction)
      • RegisterDirtyMaterialCallback(UnityAction)
      • RegisterDirtyVerticesCallback(UnityAction)
      • Reset()
      • SetAllDirty()
      • SetLayoutDirty()
      • SetMaterialDirty()
      • SetNativeSize()
      • SetRaycastDirty()
      • SetVerticesDirty()
      • UnregisterDirtyLayoutCallback(UnityAction)
      • UnregisterDirtyMaterialCallback(UnityAction)
      • UnregisterDirtyVerticesCallback(UnityAction)
      • UpdateGeometry()
      • UpdateMaterial()
    • Implements
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)