unity日本語翻訳のスクリプト解説で安心アプリ制作 -2ページ目

unity日本語翻訳のスクリプト解説で安心アプリ制作

アプリ制作ソフトunityの「スクリプトリファレンス」が英語で書かれているので、その英語解説を日本語に訳します。
http://docs-jp.unity3d.com/Documentation/ScriptReference/

Overview: Accessing Other Components
http://docs-jp.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Components.html
のunity日本語翻訳



前::Time
次:Accessing Objects



コンポーネントはゲーム・オブジェクトに付けられています。
ゲーム・オブジェクトに脂肪精製工場技師コンポーネントを付けることはそれをカメラを付けて、スクリーン上で与えさせるものです、それをカメラ・オブジェクトに変えます。
スクリプトはすべてこのようにコンポーネントです、それらはゲーム・オブジェクトに付けることができます。
最多の共通成分は単純なメンバー変数のようにアクセス可能です:


Component Accessible as
Transform  transform
Rigidbody  rigidbody
Renderer    renderer
Camera    camera (only on camera objects)
Light    light (only on light objects)
Animation    animation
Collider    collider
... etc.



あらかじめ定められたメンバー変数の完全リストのために、コンポーネント、振る舞いおよびMonoBehaviourクラスのためのドキュメンテーションを見ます。
ゲーム・オブジェクトにあなたが取って来たいタイプのコンポーネントがなければ、上記の変数は無効のことにセットされるでしょう。
ゲーム・オブジェクトに付けられたどんなコンポーネントあるいはスクリプトも、GetComponentによってアクセスすることができます。



JavaScript
------------------------
transform.Translate(0, 1, 0);
// is equivalent to
GetComponent(Transform).Translate(0, 1, 0);
------------------------




C#
------------------------
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Example() {
transform.Translate(0, 1, 0);
GetComponent().Translate(0, 1, 0);
}
}
------------------------







Boo
------------------------
import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Example():
transform.Translate(0, 1, 0)
GetComponent[of Transform]().Translate(0, 1, 0)
------------------------






ケース差に間に注意する、変形するとトランスフォームする。
前者は変数(小文字)です、後者はクラスまたはスクリプトの名(大文字)です。
このケース差は、変数とclass&script名を区別するためにあなたをさせます。
私たちが学習したものを適用すると、私たちは、今GetComponentを使用して、同じゲーム・オブジェクトに付けられているあらゆるスクリプトまたはbuiltinのコンポーネントを見つけることができます。
次の例仕事を作るために、関数DoSomethingを含んでいるOtherScriptと呼ばれるスクリプトを持つ必要があることに注意してください。
OtherScriptスクリプトは次のスクリプトと同じゲーム・オブジェクトに付けられるに違いありません。


JavaScript
-----------------------
// This finds the script called OtherScript in the same game object
// and calls DoSomething on it.

function Update () {
var otherScript: OtherScript = GetComponent(OtherScript);
otherScript.DoSomething();
}
-----------------------






C#
-----------------------
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Update() {
OtherScript otherScript = GetComponent();
otherScript.DoSomething();
}
}
------------------------








Boo
------------------------
import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Update():
otherScript as OtherScript = GetComponent[of OtherScript]()
otherScript.DoSomething()
--------------------------





前::Time
次:Accessing Objects