SpriteRenderer

class in UnityEngine

/

Inherits from:Renderer

Switch to Manual

Description

Визуализирует спрайт для 2D графики.

//This example outputs Sliders that control the red green and blue elements of a sprite's color
//Attach this to a GameObject and attach a SpriteRenderer component

using UnityEngine;

public class Example : MonoBehaviour { SpriteRenderer m_SpriteRenderer; //The Color to be assigned to the Renderer’s Material Color m_NewColor;

//These are the values that the Color Sliders return float m_Red, m_Blue, m_Green;

void Start() { //Fetch the SpriteRenderer from the GameObject m_SpriteRenderer = GetComponent<SpriteRenderer>(); //Set the GameObject's Color quickly to a set Color (blue) m_SpriteRenderer.color = Color.blue; }

void OnGUI() { //Use the Sliders to manipulate the RGB component of Color //Use the Label to identify the Slider GUI.Label(new Rect(0, 30, 50, 30), "Red: "); //Use the Slider to change amount of red in the Color m_Red = GUI.HorizontalSlider(new Rect(35, 25, 200, 30), m_Red, 0, 1);

//The Slider manipulates the amount of green in the GameObject GUI.Label(new Rect(0, 70, 50, 30), "Green: "); m_Green = GUI.HorizontalSlider(new Rect(35, 60, 200, 30), m_Green, 0, 1);

//This Slider decides the amount of blue in the GameObject GUI.Label(new Rect(0, 105, 50, 30), "Blue: "); m_Blue = GUI.HorizontalSlider(new Rect(35, 95, 200, 30), m_Blue, 0, 1);

//Set the Color to the values gained from the Sliders m_NewColor = new Color(m_Red, m_Green, m_Blue);

//Set the SpriteRenderer to the Color defined by the Sliders m_SpriteRenderer.color = m_NewColor; } }

Variables

adaptiveModeThresholdThe current threshold for Sprite Renderer tiling.
colorВизуализация цвета спрайта.
drawModeThe current draw mode of the Sprite Renderer.
flipXЗеркально отражает спрайт по оси X.
flipYЗеркально отражает спрайт по оси Y.
maskInteractionSpecifies how the sprite interacts with the masks.
sizeProperty to set/get the size to render when the SpriteRenderer.drawMode is set to SpriteDrawMode.Sliced.
spriteСпрайт для визуализации.
spriteSortPointDetermines the position of the Sprite used for sorting the SpriteRenderer.
tileModeThe current tile mode of the Sprite Renderer.

Inherited members

Variables

gameObjectИгровой объект к которому прикреплён данный компонент. Компонент всегда прикреплён к игровому объекту.
tagТег данного игрового объекта.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.
allowOcclusionWhenDynamicControls if dynamic occlusion culling should be performed for this renderer.
boundsThe bounding volume of the renderer (Read Only).
enabledMakes the rendered 3D object visible if enabled.
forceRenderingOffAllows turning off rendering for a specific component.
isPartOfStaticBatchHas this renderer been statically batched with any other renderers?
isVisibleIs this renderer visible in any camera? (Read Only)
lightmapIndexИндекс карты освещения, примененной при визуализации.
lightmapScaleOffsetThe UV scale & offset used for a lightmap.
lightProbeProxyVolumeOverrideIf set, the Renderer will use the Light Probe Proxy Volume component attached to the source GameObject.
lightProbeUsageThe light probe interpolation type.
localToWorldMatrixMatrix that transforms a point from local space into world space (Read Only).
materialReturns the first instantiated Material assigned to the renderer.
materialsReturns all the instantiated materials of this object.
motionVectorGenerationModeSpecifies the mode for motion vector rendering.
probeAnchorЕсли установлено, Renderer будет использовать позицию Transform's, чтобы найти интерполированные светопробы.
rayTracingModeDescribes how this renderer is updated for ray tracing.
realtimeLightmapIndexИндекс карты освещения, примененной при визуализации.
realtimeLightmapScaleOffsetThe UV scale & offset used for a realtime lightmap.
receiveShadowsDoes this object receive shadows?
reflectionProbeUsageShould reflection probes be used for this Renderer?
rendererPriorityThis value sorts renderers by priority. Lower values are rendered first and higher values are rendered last.
renderingLayerMaskDetermines which rendering layer this renderer lives on.
shadowCastingModeDoes this object cast shadows?
sharedMaterialThe shared material of this object.
sharedMaterialsAll the shared materials of this object.
sortingLayerIDUnique ID of the Renderer's sorting layer.
sortingLayerNameName of the Renderer's sorting layer.
sortingOrderRenderer's order within a sorting layer.
worldToLocalMatrixMatrix that transforms a point from world space into local space (Read Only).

Public Functions

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 в этом игровом объекте и в каждом предке поведения.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the object.
GetClosestReflectionProbesReturns an array of closest reflection probes with weights, weight shows how much influence the probe has on the renderer, this value is also used when blending between reflection probes occur.
GetMaterialsReturns all the instantiated materials of this object.
GetPropertyBlockGet per-Renderer or per-Material property block.
GetSharedMaterialsReturns all the shared materials of this object.
HasPropertyBlockReturns true if the Renderer has a material property block attached via SetPropertyBlock.
SetPropertyBlockLets you set or clear per-renderer or per-material parameter overrides.

Static Functions

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object 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.
InstantiateClones the object original and returns the clone.

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.

Messages

OnBecameInvisible OnBecameInvisible is called when the object is no longer visible by any camera.
OnBecameVisible OnBecameVisible is called when the object became visible by any camera.