unity のバックアップ(No.11)

Prefab生成時の(clone)を消す方法 Edit

public GameObject target1;
void Start()
{
GameObject newTarget1 = (GameObject)Instantiate(target1);
newTarget1.name = target1.name;
}

衝突判定時の相手の名前の取得 Edit

void OnTriggerEnter(Collider other)
{
Debug.Log(other.name);
}

親("oya")オブジェクトの設定 子にしたいやつにつける Edit

transform.SetParent(GameObject.Find("oya").transform);

transform操作 Edit

transform.position = new Vector3(x, y, z);
transform.rotation = new Quaternion(x, y, z, w);

  • 回転
    transform.Rotate(new Vector3(x, y, z));

子オブジェクトの数を取得 Edit

int Count = _RootObject.transform.childCount;

指定位置の方向に向ける Edit

public Transform target;
void Update()
{
transform.LookAt(target);
}

text変更 Edit

using UnityEngine.UI;

public Text B;
public int A;
void Update()
{
B.text = "AAA:" + A;
}

他のスクリプトの値にアクセス Edit

他のスクリプト名 AAA
他のスクリプト内にある値(int) BBB


FindObjectOfType<AAA>().BBB = 0

if(FindObjectOfType<AAA>().BBB == 0){}

スライダーの数値 Edit

using UnityEngine.UI;

public Slider B;
public float A;
void Update()
{
A=B.value;
Debug.Log (B.value);

}

Ray Edit

Edit

Edit


ホーム リロード   新規 下位ページ作成 コピー 編集 添付 一覧 最終更新 差分 バックアップ 検索   凍結 名前変更