Base class for all UI components that should be derived from when creating new Graphic types.
Inherited MembersComponent.GetComponentIndex()
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, InstantiateParameters)
Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Namespace: UnityEngine.UI Assembly: UnityEngine.UI.dll Syntax[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
[ExecuteAlways]
public abstract class Graphic : UIBehaviour, ICanvasElement
Constructors Graphic() Declaration Fields m_CachedMesh Declaration
[NonSerialized]
protected Mesh m_CachedMesh
Field Value m_CachedUvs Declaration
[NonSerialized]
protected Vector2[] m_CachedUvs
Field Value m_Material Declaration
[FormerlySerializedAs("m_Mat")]
[SerializeField]
protected Material m_Material
Field Value m_OnDirtyLayoutCallback Declaration
[NonSerialized]
protected UnityAction m_OnDirtyLayoutCallback
Field Value m_OnDirtyMaterialCallback Declaration
[NonSerialized]
protected UnityAction m_OnDirtyMaterialCallback
Field Value m_OnDirtyVertsCallback Declaration
[NonSerialized]
protected UnityAction m_OnDirtyVertsCallback
Field Value m_SkipLayoutUpdate Declaration
[NonSerialized]
protected bool m_SkipLayoutUpdate
Field Value m_SkipMaterialUpdate Declaration
[NonSerialized]
protected bool m_SkipMaterialUpdate
Field Value s_DefaultUI Declaration
protected static Material s_DefaultUI
Field Value s_Mesh Declaration
[NonSerialized]
protected static Mesh s_Mesh
Field Value s_WhiteTexture Declaration
protected static Texture2D s_WhiteTexture
Field Value Properties canvas
A reference to the Canvas this Graphic is rendering to.
Declarationpublic Canvas canvas { get; }
Property Value canvasRenderer
A reference to the CanvasRenderer populated by this Graphic.
Declarationpublic CanvasRenderer canvasRenderer { get; }
Property Value color
Base color of the Graphic.
Declarationpublic virtual Color color { get; set; }
Property Value 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.
Declarationpublic static Material defaultGraphicMaterial { get; }
Property Value defaultMaterial
Returns the default material for the graphic.
Declarationpublic virtual Material defaultMaterial { get; }
Property Value depth
Absolute depth of the graphic, used by rendering and events -- lowest to highest.
Declarationpublic int depth { get; }
Property Value 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.
mainTextureThe graphic's texture. (Read Only).
Declarationpublic virtual Texture mainTexture { get; }
Property Value Remarks material
The Material set by the user
Declarationpublic virtual Material material { get; set; }
Property Value materialForRendering
The material that will be sent for Rendering (Read only).
Declarationpublic virtual Material materialForRendering { get; }
Property Value raycastPadding
Padding to be applied to the masking X = Left Y = Bottom Z = Right W = Top
Declarationpublic Vector4 raycastPadding { get; set; }
Property Value raycastTarget
Should this graphic be considered a target for raycasting?
Declarationpublic virtual bool raycastTarget { get; set; }
Property Value rectTransform
The RectTransform component used by the Graphic. Cached for speed.
Declarationpublic RectTransform rectTransform { get; }
Property Value useLegacyMeshGeneration Declaration
protected bool useLegacyMeshGeneration { get; set; }
Property Value workerMesh Declaration
protected static Mesh workerMesh { get; }
Property Value Methods CrossFadeAlpha(float, float, bool)
Tweens the alpha of the CanvasRenderer color associated with this Graphic.
Declarationpublic virtual void CrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
Parameters Type Name Description float alpha
Target alpha.
float durationDuration of the tween in seconds.
bool ignoreTimeScaleShould ignore [[Time.scale]]?
CrossFadeColor(Color, float, bool, bool)Tweens the CanvasRenderer color associated with this Graphic.
Declarationpublic virtual void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
Parameters Type Name Description Color targetColor
Target color.
float durationTween duration.
bool ignoreTimeScaleShould ignore Time.scale?
bool useAlphaShould also Tween the alpha channel?
CrossFadeColor(Color, float, bool, bool, bool)Tweens the CanvasRenderer color associated with this Graphic.
Declarationpublic virtual void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB)
Parameters Type Name Description Color targetColor
Target color.
float durationTween duration.
bool ignoreTimeScaleShould ignore Time.scale?
bool useAlphaShould also Tween the alpha channel?
bool useRGBShould the color or the alpha be used to tween
GetPixelAdjustedRect()Returns a pixel perfect Rect closest to the Graphic RectTransform.
Declarationpublic Rect GetPixelAdjustedRect()
Returns Type Description Rect
A Pixel perfect Rect.
GraphicUpdateComplete()Callback sent when this ICanvasElement has completed Graphic rebuild.
Declarationpublic virtual void GraphicUpdateComplete()
LayoutComplete()
Callback sent when this ICanvasElement has completed layout.
Declarationpublic virtual void LayoutComplete()
OnBeforeTransformParentChanged() Declaration
protected override void OnBeforeTransformParentChanged()
Overrides OnCanvasHierarchyChanged()
Called when the state of the parent Canvas is changed.
Declarationprotected override void OnCanvasHierarchyChanged()
Overrides OnCullingChanged()
This method must be called when CanvasRenderer.cull
is modified.
public virtual void OnCullingChanged()
OnDestroy() Declaration
protected override void OnDestroy()
Overrides OnDidApplyAnimationProperties() Declaration
protected override void OnDidApplyAnimationProperties()
Overrides OnDisable()
Clear references.
Declarationprotected override void OnDisable()
Overrides OnEnable()
Mark the Graphic and the canvas as having been changed.
Declarationprotected override void OnEnable()
Overrides 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.
Declarationprotected virtual void OnPopulateMesh(VertexHelper vh)
Parameters OnRebuildRequested()
Editor-only callback that is issued by Unity if a rebuild of the Graphic is required. Currently sent when an asset is reimported.
Declarationpublic 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).
Declarationprotected override void OnRectTransformDimensionsChange()
Overrides OnTransformParentChanged() Declaration
protected override void OnTransformParentChanged()
Overrides OnValidate() Declaration
protected override void OnValidate()
Overrides PixelAdjustPoint(Vector2)
Adjusts the given pixel to be pixel perfect.
Declarationpublic Vector2 PixelAdjustPoint(Vector2 point)
Parameters Type Name Description Vector2 point
Local space point.
Returns Type Description Vector2Pixel perfect adjusted point.
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.
Declarationpublic virtual bool Raycast(Vector2 sp, Camera eventCamera)
Parameters Type Name Description Vector2 sp
Screen point being tested
Camera eventCameraCamera that is being used for the testing.
Returns Type Description boolTrue if the provided point is a valid location for GraphicRaycaster raycasts.
Rebuild(CanvasUpdate)Rebuilds the graphic geometry and its material on the PreRender cycle.
Declarationpublic virtual void Rebuild(CanvasUpdate update)
Parameters Type Name Description CanvasUpdate update
The current step of the rendering CanvasUpdate cycle.
RegisterDirtyLayoutCallback(UnityAction)Add a listener to receive notification when the graphics layout is dirtied.
Declarationpublic 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.
Declarationpublic 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.
Declarationpublic void RegisterDirtyVerticesCallback(UnityAction action)
Parameters Type Name Description UnityAction action
The method to call when invoked.
Reset() Declarationprotected override void Reset()
Overrides SetAllDirty()
Set all properties of the Graphic dirty and needing rebuilt. Dirties Layout, Vertices, and Materials.
Declarationpublic virtual void SetAllDirty()
SetLayoutDirty()
Mark the layout as dirty and needing rebuilt.
Declarationpublic virtual void SetLayoutDirty()
SetMaterialDirty()
Mark the material as dirty and needing rebuilt.
Declarationpublic virtual void SetMaterialDirty()
SetNativeSize()
Make the Graphic have the native size of its content.
Declarationpublic virtual void SetNativeSize()
SetRaycastDirty() Declaration
public void SetRaycastDirty()
SetVerticesDirty()
Mark the vertices as dirty and needing rebuilt.
Declarationpublic virtual void SetVerticesDirty()
UnregisterDirtyLayoutCallback(UnityAction)
Remove a listener from receiving notifications when the graphics layout are dirtied
Declarationpublic 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
Declarationpublic 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
Declarationpublic 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.
Declarationprotected virtual void UpdateGeometry()
UpdateMaterial()
Call to update the Material of the graphic onto the CanvasRenderer.
Declarationprotected virtual void UpdateMaterial()
Implements
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4