110,534
社区成员
发帖
与我相关
我的任务
分享
using UnityEngine;
using System.Collections;
using System.IO;
using UnityEngine.UI;
using System.Collections.Generic;
public class loadtest : MonoBehaviour
{
public TextAsset txtRawFile;
public Text uiText;
public float timer = 1.0f;
public int z = 0;
public float[,] spaces;
private List<string> eachLine;
private string theWholeFileAsOneLongString;
// Use this for initialization
void Start ()
{
theWholeFileAsOneLongString = txtRawFile.text;
eachLine = new List<string>();
eachLine.AddRange(theWholeFileAsOneLongString.Split("\n"[0]));
float[,] spaces = new float[eachLine.Count, 6]; // 获取整数数组
for (int i = 0; i < eachLine.Count; i++) { // 逐行转换
string st = eachLine[i]; // 取得一行
string[] nums = st.Split(new[] { ',' });
if (nums.Length != 6) {
Debug.Log ("Misforned input on line "+i+1);
}
for (int j = 0; j < Mathf.Min (nums.Length, 6); j++) {
float val;
if (float.TryParse (nums[j], out val))
spaces[i,j] = val;
else
spaces[i,j] = -1;
}
}
}
void Update(){
timer -= Time.deltaTime;
if(timer<=0) {
transform.localEulerAngles = new Vector3 (0, 0,-spaces[z,0]*57);
Debug.Log (z);
timer = 1.0f;
z = z + 1;
}
}
}