Элемент, который может быть использован для рендеринга экрана.
Elements on a canvas are rendered AFTER Scene rendering, either from an attached camera or using overlay mode.
using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.UI;
// Create a Canvas that holds a Text GameObject.
public class ExampleClass : MonoBehaviour { void Start() { GameObject myGO; GameObject myText; Canvas myCanvas; Text text; RectTransform rectTransform;
// Canvas myGO = new GameObject(); myGO.name = "TestCanvas"; myGO.AddComponent<Canvas>();
myCanvas = myGO.GetComponent<Canvas>(); myCanvas.renderMode = RenderMode.ScreenSpaceOverlay; myGO.AddComponent<CanvasScaler>(); myGO.AddComponent<GraphicRaycaster>();
// Text myText = new GameObject(); myText.transform.parent = myGO.transform; myText.name = "wibble";
text = myText.AddComponent<Text>(); text.font = (Font)Resources.Load("MyFont"); text.text = "wobble"; text.fontSize = 100;
// Text position rectTransform = text.GetComponent<RectTransform>(); rectTransform.localPosition = new Vector3(0, 0, 0); rectTransform.sizeDelta = new Vector2(400, 200); } }
| additionalShaderChannels | Get or set the mask of additional shader channels to be used when creating the Canvas mesh. |
| cachedSortingLayerValue | Cached calculated value based upon SortingLayerID. |
| isRootCanvas | Это корень Canvas? |
| normalizedSortingGridSize | The normalized grid size that the canvas will split the renderable area into. |
| overridePixelPerfect | Используется с вложенными полотнами, позволяющими иметь разные настройки pixelPerfect в иерархии. |
| overrideSorting | Переопределяет сортировку на полотне (canvas). |
| pixelPerfect | Заставляет элементы на полотне прийти в соответствие с пикселями. Применяется только с RenderMode в экранном пространстве. |
| pixelRect | Get the render rect for the Canvas. |
| planeDistance | Как далеко от камеры полотно (Canvas) было сгенерировано. |
| referencePixelsPerUnit | Количество пикселей на единицу, которая считается по умолчанию. |
| renderMode | Этот Canvas в мировом режиме или режиме наложения? |
| renderOrder | The render order in which the canvas is being emitted to the Scene. (Read Only) |
| rootCanvas | Returns 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 в экранном пространстве. |
| sortingLayerID | Идентификатор слоя сортировки полотна (Canvas). |
| sortingLayerName | Название слоя сортировки полотна (Canvas). |
| sortingOrder | Порядок полотна (Canvas) без слоя сортировки. |
| targetDisplay | For 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]. |
| ForceUpdateCanvases | Заставляет все полотна (canvases) обновить их содержание. |
| GetDefaultCanvasMaterial | Возвращает материал по умолчанию, который может быть использован для рендеринга обычных элементов на полотне (Canvas). |
| GetETC1SupportedCanvasMaterial | Gets or generates the ETC1 Material. |
| willRenderCanvases | Событие, которое вызывается непосредственно перед тем как произойдет рендеринг Canvas. |
| enabled | Включенное Поведение обновляется, выключенное Поведение не обновляется. |
| isActiveAndEnabled | Has the Behaviour had active and enabled called? |
| gameObject | Игровой объект к которому прикреплён данный компонент. Компонент всегда прикреплён к игровому объекту. |
| tag | Тег данного игрового объекта. |
| transform | The Transform attached to this GameObject. |
| hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
| name | The name of the object. |
| BroadcastMessage | Вызывает метод названный methodName на каждом MonoBehaviour этого game object-а или любого из его потомков. |
| 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 в этом игровом объекте и в каждом предке поведения. |
| TryGetComponent | Gets the component of the specified type, if it exists. |
| GetInstanceID | Returns the instance id of the object. |
| ToString | Returns the name of the object. |
| Destroy | Removes a GameObject, component or asset. |
| DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. |
| DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. |
| FindObjectOfType | Returns the first active loaded object of Type type. |
| FindObjectsOfType | Returns a list of all active loaded objects of Type type. |
| Instantiate | Clones the object original and returns the clone. |
| bool | Does 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. |