我尝试从 txt 文件中的每一行获取位置,然后将它们提供给已生成的树。我在这方面提供帮助:从保存文件中加载坐标。
我希望以这样一种方式列出它,即每行中的 3 位数字都是多个整数 zb int1 = 第一个数字,int2 = 第二个数字,int3 = 三个数字中的所有数字。
我的 txt 文件如下所示:
-32,68481 1,5 -24,33997;
11,65891 1,5 29,67229;
33,34601 1,5 26,94939;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class SaveSystem : MonoBehaviour
{
//Loads the Coordinates from the save file
public void LoadSaveData()
{
string[] data = SaveBaumText.text.Split(new char[] { '\n' });
for(int i = 0;i < data.Length - 1;i++)
{
string[] row = data[i].Split(new char[] { ';' });
Bäume = GameObject.FindGameObjectsWithTag(BaumTag);
Debug.Log(row[0]);
}
}
}