A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.UI.Graphic.html below:

Class Graphic

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

Inherited Members

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

Declaration
public Canvas canvas { get; }
Property Value canvasRenderer

A reference to the CanvasRenderer populated by this Graphic.

Declaration
public CanvasRenderer canvasRenderer { get; }
Property Value color

Base color of the Graphic.

Declaration
public 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.

Declaration
public static Material defaultGraphicMaterial { get; }
Property Value defaultMaterial

Returns the default material for the graphic.

Declaration
public virtual Material defaultMaterial { get; }
Property Value depth

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

Declaration
public 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.

mainTexture

The graphic's texture. (Read Only).

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

The Material set by the user

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

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

Declaration
public virtual Material materialForRendering { get; }
Property Value raycastPadding

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

Declaration
public Vector4 raycastPadding { get; set; }
Property Value raycastTarget

Should this graphic be considered a target for raycasting?

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

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

Declaration
public 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.

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.

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 OnCanvasHierarchyChanged()

Called when the state of the parent Canvas is changed.

Declaration
protected override void OnCanvasHierarchyChanged()
Overrides OnCullingChanged()

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

Declaration
public virtual void OnCullingChanged()
OnDestroy() Declaration
protected override void OnDestroy()
Overrides OnDidApplyAnimationProperties() Declaration
protected override void OnDidApplyAnimationProperties()
Overrides OnDisable()

Clear references.

Declaration
protected override void OnDisable()
Overrides OnEnable()

Mark the Graphic and the canvas as having been changed.

Declaration
protected 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.

Declaration
protected 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.

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 OnTransformParentChanged() Declaration
protected override void OnTransformParentChanged()
Overrides OnValidate() Declaration
protected override void OnValidate()
Overrides 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.

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.

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 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()
SetMaterialDirty()

Mark the material as dirty and needing rebuilt.

Declaration
public virtual void SetMaterialDirty()
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()
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

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