言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Canvas

Namespace: UnityEngine

/

Inherits from: Behaviour

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

スクリーンレンダリングのために使用する事ができる要素

キャンバス上の要素はオーバーレイモードを使用しているかカメラがアタッチされているかどちらかでシーンのレンダリングが行われた後レンダリングされます。

#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;
}
no example available in C#
no example available in Boo

Variables

isRootCanvas Canvasがルートかどうか
overridePixelPerfect Allows for nested canvases to override pixelPerfect settings inherited from parent canvases.
overrideSorting Canvasのソートを上書きします
pixelPerfect ピクセルと整列するようにキャンバスの要素を焼成します。renderModeがScreen Spaceの時のみ適用されます。
pixelRect Canvasのためのレンダー矩形を取得します。
planeDistance 生成するCanvasのカメラからの距離
referencePixelsPerUnit デフォルトの1unitあたりのピクセル数
renderMode Canvasがワールドまたはオーバーレイモードかどうか
renderOrder Canvasをシーンに描画する順番
scaleFactor スクリーンにフィットさせながらキャンバス全体のスケールするために使用します。renderModeがScreen Spaceの時のみ適用されます。
sortingLayerID CanvasのソーティングレイヤーのID
sortingLayerName Canvasのソーティングレイヤーの名前
sortingOrder ソーティングレイヤーのオーダー順
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 コンテンツを更新するために強制的に全てのCanvasを更新します
GetDefaultCanvasMaterial Returns the default material that can be used for rendering normal elements on the Canvas.
GetDefaultCanvasTextMaterial Returns the default material that can be used for rendering text elements on the Canvas.

Inherited members

Variables

enabled 有効であれば更新され、無効であれば更新されません。
isActiveAndEnabled Has the Behaviour had enabled called.
animation GameObjectにアタッチされたAnimation (アタッチされていない場合はnull)
audio GameObjectにアタッチされたAudioSource (アタッチされていない場合はnull)
camera GameObjectにアタッチされたCamera (アタッチされていない場合はnull)
collider GameObjectにアタッチされたCollider (アタッチされていない場合はnull)
collider2D GameObjectにアタッチされたCollider2D
constantForce GameObjectにアタッチされたConstantForce (アタッチされていない場合はnull)
gameObject このコンポーネントはゲームオブジェクトにアタッチされます。コンポーネントはいつもゲームオブジェクトにアタッチされています。
guiText GameObjectにアタッチされたGUIText (アタッチされていない場合はnull)
guiTexture GameObjectにアタッチされたGUITexture (アタッチされていない場合はnull)
hingeJoint GameObjectにアタッチされたHingeJoint (アタッチされていない場合はnull)
light GameObjectにアタッチされたLight (アタッチされていない場合はnull)
networkView GameObjectにアタッチされたNetworkView (アタッチされていない場合はnull)
particleEmitter GameObjectにアタッチされたParticleEmitter (アタッチされていない場合はnull)
particleSystem GameObjectにアタッチされたParticleSystem (アタッチされていない場合はnull)
renderer GameObjectにアタッチされたRenderer (アタッチされていない場合はnull)
rigidbody GameObjectにアタッチされたRigidbody (アタッチされていない場合はnull)
rigidbody2D GameObjectにアタッチされたRigidbody2D
tag ゲームオブジェクトのタグ
transform GameObjectにアタッチされたTransform (アタッチされていない場合はnull)
hideFlags オブジェクトは非表示、シーンに保存、ユーザーが編集可能などを行うかどうか
name オブジェクト名

Functions

BroadcastMessage ゲームオブジェクトまたは子オブジェクトにある すべての MonoBehaviour を継承したクラスにある methodName 名のメソッドを呼び出します。
CompareTag Is this game object tagged with /tag/?
GetComponent Returns the component of Type type if the game object has one attached, null if it doesn't.
GetComponentInChildren Returns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParent Returns the component of Type type in the GameObject or any of its parents.
GetComponents Returns all components of Type type in the GameObject.
GetComponentsInChildren Returns all components of Type type in the GameObject or any of its children.
GetComponentsInParent Returns all components of Type type in the GameObject or any of its parents.
SendMessage Calls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwards Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
GetInstanceID Returns the instance id of the object.
ToString ゲームオブジェクトの名前を返します

Static Functions

Destroy ゲームオブジェクト、コンポーネントやアセットを削除します
DestroyImmediate 直ちにオブジェクトを破壊する。ですが、Destroy関数の方を使うことを推奨します
DontDestroyOnLoad 新しいシーンを読み込んでもオブジェクトが自動で破壊されないように設定します
FindObjectOfType タイプから最初に見つけたアクティブのオブジェクトを返します
FindObjectsOfType タイプから見つけた全てのアクティブのオブジェクト配列を返します
Instantiate original のオブジェクトをクローンします

Operators

bool オブジェクトが存在するかどうか
operator != 二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator == 二つのオブジェクトが同じオブジェクトを参照しているか比較します