using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Text;
public class LoadTxt : MonoBehaviour
{
private string MyTxT;
public static float txt1;
private string path;
private StreamReader sr;
// Use this for initialization
void Start()
{
path = Application.dataPath + "/TXT/txt.txt";
//第一步访问Txt文件,在unity里面时,TXT文件夹在asstes里面的文件夹,导出的时候是在data文件夹里面
}
// Update is called once per frame
void Update()
{
//读取内容
sr = new StreamReader(path);
MyTxT = sr.ReadToEnd();
txt1 = float.Parse(MyTxT);
}
}
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Text;
public class LoadTxt : MonoBehaviour
{
private string MyTxT;
public static float txt1;
private string path;
private StreamReader sr;
// Use this for initialization
void Start()
{
path = Application.dataPath + "/TXT/txt.txt";
//第一步访问Txt文件,在unity里面时,TXT文件夹在asstes里面的文件夹,导出的时候是在data文件夹里面
}
// Update is called once per frame
void Update()
{
//读取内容
sr = new StreamReader(path);
MyTxT = sr.ReadToEnd();
txt1 = float.Parse(MyTxT);
}
}