これは厳密にUnity3Dであり、私は100の配列を持っていますTransform
、Unity3dのテキストファイルにいくつかのTransformを書き込んで読み込む簡単な方法はありますか?
私はそれらをPCのデスクトップ上のファイルに書き、後でそれらを読みたいと思います。
は... ...
// write to desktop...
string s = "";
for (int i=0; i< sendMe.Length; ++i)
{
Transform tt = sendMe[i].transform;
s = s +tt.position.x +"," +tt.position.x +"," ...etc... "\n";
}
string d = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.DesktopDirectory);
string path = System.IO.Path.Combine(d, "happyData.txt");
System.IO.File.Delete(path);
System.IO.File.WriteAllText(path,s);
return;
を検討してからちょうど手動でテキスト形式を解析し、同様にそれを読んで。何かのように...
public ReadTrackFromDesktopFile()
{
GetSplineGetReady("development");
string tt = File.ReadAllText(.. path as above);
List<string> ts = new List<string>(
tt.Split(new string[] { "\r","\n" },
StringSplitOptions.RemoveEmptyEntries));
foreach (string t in ts)
{
string[] parts = t.Split(',');
Vector3 pos = new Vector3(parts[0],parts[1],parts[2]);
Quaternion rot = new Quaternion(parts[3],parts[4],parts[5],parts[6]);
GetSplineOneNode(pos, rot);
}
GetSplineFinalise();
}
しかし、これはナイーブだと思われます。これを行うための「単純な統一方法」は何ですか?
Jsonとplayerprefsは許可されていますか? – Programmer
@JoeBlowあなたがこれを見たことがありますか:https://gitgud.io/TheSniperFan/unityserializer-ng –
こんにちはプロ、Json確かめてください! playerprefs - 私はちょうどデスクトップのテキストファイルに書き込むと思います(上のコード行のみです)。それから、それらを入れ替えたり、変更したりすることができます。 – Fattie