Unity5質問スレ [転載禁止]©5ch.net
■ このスレッドは過去ログ倉庫に格納されています
0177名前は開発中のものです。
2015/08/23(日) 17:58:55.76ID:PndBQK9j上に寄せて拡大縮小してるように見えるんだが
いまいちやりたい事伝わらんけど、何か適当に置いとくわ
・空のGameObjectにアタッチして使うスクリプト。
・プレハブ1インスタンスの下に2インスタンスが、
2インスタンスの下に3インスタンスが並ぶ
public Object obj1; //Inspectorにて、プレハブをドラッグ&ドロップ
public Object obj2;
public Object obj3;
void Start(){
//インスタンスをGameObjectへ変換しつつ代入
var instance1 = Instantiate(obj1, Vector3.zero, Quaternion.identity) as GameObject;
var instance2 = Instantiate(obj2, Vector3.zero, Quaternion.identity) as GameObject;
var instance3 = Instantiate(obj3, Vector3.zero, Quaternion.identity) as GameObject;
//obj2の移動先
var pos_Instance2 = new Vector3(
instance1.transform.position.x,
instance1.transform.position.y - (instance1.GetComponent<Renderer>().bounds.size.y + instance2.GetComponent<Renderer>().bounds.size.y)/2,
instance1.transform.position.z);
//obj3の移動先
var pos_Instance3 = new Vector3(
instance2.transform.position.x,
pos_Instance2.y - (instance2.GetComponent<Renderer>().bounds.size.y + instance3.GetComponent<Renderer>().bounds.size.y)/2,
instance2.transform.position.z);
//移動
instance2.transform.Translate(pos_Instance2);
instance3.transform.Translate(pos_Instance3);
}
■ このスレッドは過去ログ倉庫に格納されています