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; } }
adaptiveModeThreshold | The current threshold for Sprite Renderer tiling. |
color | スプライトグラフィックスのレンダリングする際のカラー |
drawMode | スプライトレンダラーの現在の描画モード |
flipX | スプライトを X 軸で反転します |
flipY | スプライトを Y 軸で反転します |
maskInteraction | Specifies how the sprite interacts with the masks. |
size | Property to set or get the size to render when the SpriteRenderer.drawMode is set to SpriteDrawMode.Sliced or SpriteDrawMode.Tiled. |
sprite | レンダリング対象のスプライト |
spriteSortPoint | Determines the position of the Sprite used for sorting the SpriteRenderer. |
tileMode | The current tile mode of the Sprite Renderer. |
RegisterSpriteChangeCallback | Registers a callback to receive a notification when the SpriteRenderer's Sprite reference changes. |
UnregisterSpriteChangeCallback | Removes a callback (that receives a notification when the Sprite reference changes) that was previously registered to a SpriteRenderer. |
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 | オブジェクト名 |
allowOcclusionWhenDynamic | Controls if dynamic occlusion culling should be performed for this renderer. |
bounds | The bounding box of the renderer in world space. |
enabled | 有効にした場合、レンダリングされた 3D オブジェクトが表示されます |
forceRenderingOff | Allows turning off rendering for a specific component. |
isPartOfStaticBatch | Indicates whether the renderer is part of a static batch with other renderers. |
isVisible | カメラにレンダラーが表示されているか(読み取り専用) |
lightmapIndex | このレンダラーに適用されるベイクされるライトマップのインデックス |
lightmapScaleOffset | UV スケールとオフセットをライトマップに使用します。 |
lightProbeProxyVolumeOverride | これを設定すると、レンダラーはソースのゲームオブジェクトにアタッチされた **ライトプローブプロキシボリューム** コンポーネントを使用します。 |
lightProbeUsage | ライトプローブ補間のタイプ |
localBounds | The bounding box of the renderer in local space. |
localToWorldMatrix | ローカル座標からワールド座標へ変換した行列(読み取り専用) |
material | レンダラーに割り当てられている最初にインスタンス化された Material を返します。 |
materials | このオブジェクトのすべてのインスタンス化されたマテリアルを返します。 |
motionVectorGenerationMode | Specifies the mode for motion vector rendering. |
probeAnchor | 設定する場合、レンダラーはライトプローブや反射プローブを見つけるためにこの Transform の位置を使用します。 |
rayTracingMode | Describes how this renderer is updated for ray tracing. |
realtimeLightmapIndex | The index of the real-time lightmap applied to this renderer. |
realtimeLightmapScaleOffset | The UV scale & offset used for a real-time lightmap. |
receiveShadows | このオブジェクトが影の影響を受けるかどうか |
reflectionProbeUsage | 反射プローブはこのレンダラーのために使用する必要があるか。 |
rendererPriority | This value sorts renderers by priority. Lower values are rendered first and higher values are rendered last. |
renderingLayerMask | Determines which rendering layer this renderer lives on. |
shadowCastingMode | このオブジェクトが影をキャストするかどうか |
sharedMaterial | このオブジェクトの共有マテリアル |
sharedMaterials | このオブジェクトのすべての共有マテリアル |
sortingLayerID | レンダラーの Sorting Layer の Unique ID |
sortingLayerName | レンダラーの Sorting Layer の名前 |
sortingOrder | Sorting Layer によるレンダラーのオーダー順 |
staticShadowCaster | Is this renderer a static shadow caster? |
worldToLocalMatrix | ワールド座標からローカル座標へ変換した行列(読み取り専用) |
BroadcastMessage | ゲームオブジェクトまたは子オブジェクトにあるすべての MonoBehaviour を継承したクラスにある methodName 名のメソッドを呼び出します。 |
CompareTag | Checks the GameObject's tag against the defined tag. |
GetComponent | Gets a reference to a component of type T on the same GameObject as the component specified. |
GetComponentInChildren | Gets a reference to a component of type T on the same GameObject as the component specified, or any child of the GameObject. |
GetComponentInParent | Gets a reference to a component of type T on the same GameObject as the component specified, or any parent of the GameObject. |
GetComponents | Gets references to all components of type T on the same GameObject as the component specified. |
GetComponentsInChildren | Gets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject. |
GetComponentsInParent | Gets references to all components of type T on the same GameObject as the component specified, and any parent of the GameObject. |
SendMessage | ゲームオブジェクトにアタッチされているすべての MonoBehaviour にある methodName と名付けたメソッドを呼び出します |
SendMessageUpwards | ゲームオブジェクトと親(の親、さらに親 ... )にアタッチされているすべての MonoBehaviour にある methodName と名付けたメソッドを呼び出します |
TryGetComponent | Gets the component of the specified type, if it exists. |
GetInstanceID | Gets the instance ID of the object. |
ToString | Returns the name of the object. |
GetClosestReflectionProbes | 重みを持つ最も近い反射プローブの配列を返します。重みはプローブがレンダラーでどのくらい影響するかを示しています。反射プローブが発生する間のブレンドにもこの値が使用されます。 |
GetMaterials | このオブジェクトのすべてのインスタンス化されたマテリアルを返します。 |
GetPropertyBlock | Get per-Renderer or per-Material property block. |
GetSharedMaterials | Returns all the shared materials of this object. |
HasPropertyBlock | Returns true if the Renderer has a material property block attached via SetPropertyBlock. |
ResetBounds | Reset custom world space bounds. |
ResetLocalBounds | Reset custom local space bounds. |
SetMaterials | Assigns the shared materials of this object using the list of materials provided. |
SetPropertyBlock | Lets you set or clear per-renderer or per-material parameter overrides. |
SetSharedMaterials | Assigns the shared materials of this object using the list of materials provided. |
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. |
FindAnyObjectByType | Retrieves any active loaded object of Type type. |
FindFirstObjectByType | Retrieves the first active loaded object of Type type. |
FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
Instantiate | original のオブジェクトをクローンします |
bool | オブジェクトが存在するかどうか |
operator != | 二つのオブジェクトが異なるオブジェクトを参照しているか比較します |
operator == | 2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。 |
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. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.