前提
csvに書き込まれた座標を読み込み、Instanciate命令を使用して読み込んだ座標にプレハブを出現させたいが、引用方法がわからない。
実現したいこと
・Instanciateを使用してcsvで読み込んだ座標を1件ずつ呼び出し、座標位置にプレハブを出現させたい。
できていること
・csvの読み込みは Debug.Logを用いてできていることを確認済み。
・Instanciateを使用して座標を適当に入力し、該当地点にプレハブを出現させることはできている。
発生している問題・エラーメッセージ
エラー CS1503 引数 2: は 'string' から 'UnityEngine.Vector3' へ変換することはできません
該当のソースコード
using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; public class csvyomikomi : MonoBehaviour { public GameObject prefabObj; TextAsset csvFile; // CSVファイル List<string[]> csvDatas = new List<string[]>(); // CSVの中身を入れるリスト; // Start is called before the first frame update void Start() { csvFile = Resources.Load("xyz") as TextAsset; // Resouces下のCSV読み込み StringReader reader = new StringReader(csvFile.text); // , で分割しつつ一行ずつ読み込み // リストに追加していく while (reader.Peek() != -1) // reader.Peaekが-1になるまで { string line = reader.ReadLine(); // 一行ずつ読み込み csvDatas.Add(line.Split(',')); // , 区切りでリストに追加 } // csvDatas[行][列]を指定して値を自由に取り出せる Debug.Log(csvDatas[0][1]); Debug.Log(csvDatas[0][2]); Debug.Log(csvDatas[0][3]); Debug.Log(csvDatas[1][1]); Debug.Log(csvDatas[1][2]); Debug.Log(csvDatas[1][3]); Instantiate(prefabObj, csvDatas, Quaternion.identity); } // Update is called once per frame void Update() { } }
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。