Version: 5.4

Canvas

class in UnityEngine

/

Inherits from:Behaviour

Switch to Manual

Description

Элемент, который может быть использован для рендеринга экрана.

Элементы на полотне (canvas), которые рендерятся после рендеринга сцены, либо от присоединенной камеры или с помощью режима наложения (overlay mode).

#pragma strict
@script RequireComponent(Canvas)
@script RequireComponent(UIRenderer)

var verts : UIVertex[];

function Start () { var canvas : Canvas = GetComponent ("Canvas"); canvas.renderMode = RenderMode.Overlay; verts = new UIVertex[4]; GenerateVerts(); }

function GenerateVerts() { GenerateSquare(); var uiRenderer : UIRenderer = GetComponent ("UIRenderer") ; uiRenderer.SetVertices (verts); var mat = Material (Shader.Find ("Sprites/Default")); uiRenderer.SetMaterial (mat, null); }

function GenerateSquare() { var vert : UIVertex; vert.color = Color32 (255, 0, 0, 255); vert.uv = Vector2 (0, 0); vert.position = Vector3 (0, 0); verts[0] = vert; vert.position = Vector3 (0, 300); verts[1] = vert; vert.position = Vector3 (300, 300); verts[2] = vert; vert.position = Vector3 (300, 0); verts[3] = vert; }

Variables

cachedSortingLayerValueCached calculated value based upon SortingLayerID.
isRootCanvasЭто корень Canvas?
overridePixelPerfectИспользуется с вложенными полотнами, позволяющими иметь разные настройки pixelPerfect в иерархии.
overrideSortingПереопределяет сортировку на полотне (canvas).
pixelPerfectЗаставляет элементы на полотне прийти в соответствие с пикселями. Применяется только с RenderMode в экранном пространстве.
pixelRectGet the render rect for the Canvas.
planeDistanceКак далеко от камеры полотно (Canvas) было сгенерировано.
referencePixelsPerUnitКоличество пикселей на единицу, которая считается по умолчанию.
renderModeЭтот Canvas в мировом режиме или режиме наложения?
renderOrderПорядок рендеринга, в котором полотно отображается на сцене.
rootCanvasReturns the Canvas closest to root, by checking through each parent and returning the last canvas found. If no other canvas is found then the canvas will return itself.
scaleFactorИспользуется для масштабирования всего полотна, пока он располагается по размеру экрана. Применяется только с RenderMode в экранном пространстве.
sortingGridNormalizedSizeThe normalized grid size that the canvas will split the renderable area into.
sortingLayerIDИдентификатор слоя сортировки полотна (Canvas).
sortingLayerNameНазвание слоя сортировки полотна (Canvas).
sortingOrderПорядок полотна (Canvas) без слоя сортировки.
targetDisplayFor Overlay mode, display index on which the UI canvas will appear.
worldCamera Camera used for sizing the Canvas when in Screen Space - Camera. Also used as the Camera that events will be sent through for a World Space [[Canvas].

Static Functions

ForceUpdateCanvasesЗаставляет все полотна (canvases) обновить их содержание.
GetDefaultCanvasMaterialВозвращает материал по умолчанию, который может быть использован для рендеринга обычных элементов на полотне (Canvas).
GetETC1SupportedCanvasMaterialGets or generates the ETC1 material.

Events

willRenderCanvasesСобытие, которое вызывается непосредственно перед тем как произойдет рендеринг Canvas.

Inherited members

Variables

enabledВключенное Поведение обновляется, выключенное Поведение не обновляется.
isActiveAndEnabledHas the Behaviour had enabled called.
gameObjectИгровой объект к которому прикреплён данный компонент. Компонент всегда прикреплён к игровому объекту.
tagТег данного игрового объекта.
transformThe Transform attached to this GameObject (null if there is none attached).
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.

Public Functions

BroadcastMessageВызывает метод с именем methodName на каждом скрипте MonoBehaviour этого игрового объекта или на любом из его потомков.
CompareTagПомечен ли данный игровой объект тегом tag?
GetComponentВозвращает компонент типа type, если он прикреплен к игровому объекту и null, если не прикреплен.
GetComponentInChildrenВозвращает компонент типа type в GameObject или некоторого его потомка через поиск в глубину.
GetComponentInParentВозвращает компонент типа type в GameObject или любого из его родителей.
GetComponentsВозвращает все компоненты типа type в GameObject.
GetComponentsInChildrenВозвращает все компоненты типа type в GameObject или любому из его потомков.
GetComponentsInParentВозвращает все компоненты типа type в GameObject или любому из его родителей.
SendMessageВызывает метод с именем methodName в каждом MonoBehaviour на этом объекте.
SendMessageUpwardsВызывает метод с именем methodName в каждом MonoBehaviour в этом игровом объекте и в каждом предке поведения.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.

Static Functions

DestroyУдаляет GameObject, Component или Asset.
DestroyImmediateDestroys the object obj immediately.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateReturns a copy of the object original.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.