Skip to content

Instantly share code, notes, and snippets.

@todorok1
Last active April 18, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/262425e5dc0c76c10c58a3e558676064 to your computer and use it in GitHub Desktop.
Save todorok1/262425e5dc0c76c10c58a3e558676064 to your computer and use it in GitHub Desktop.
Unityチュートリアル・ガイドを表示するスクリプト。
void InstantiateGuidePrefabs(){
// 『GuideParent』の位置を『Sphere』オブジェクトの位置へ移動
gameObject.transform.position = player.transform.position;
// 『GuideParent』の位置をguidePosにセット
Vector3 guidePos = gameObject.transform.position;
// Prefabをロードする
GameObject guidePrefab = (GameObject)Resources.Load("Prefabs/Guide");
for (int i = 0; i < prots; i++){
// Prefabをインスタンス化
GameObject guideObject = (GameObject)Instantiate(guidePrefab, guidePos, Quaternion.identity);
// インスタンス化したオブジェクトをGuideParentの子オブジェクトにする
guideObject.transform.SetParent(gameObject.transform);
// オブジェクト名を設定する
guideObject.name = "Guide_" + i.ToString();
// リストへ追加
guideList.Add(guideObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment