1、c#
using System.IO;
public class playerpref : MonoBehaviour
{
public void Start()
{
FileStream stream = new FileStream( "text.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite);
for (int i = 1; i<20; i++)
{
stream.WriteByte((byte)i);
}
stream.Position = 0;
for(int i=20; i>=1; i--)
{
Debug.Log(stream.ReadByte() + ":");
}
stream.Close();
}
}
2、lua
function savedata( _content)
local file = io.open("aaa","a")
io.output(file)
io.write(_content)
io.close()
end
function readdata()
local file = io.open("aaa","r")
if file then
io.input(file)
local str = io.read("*a")
io.close()
end
end
保存的时候一特定分隔符保存
str为保存的所有str 然后拆分成数组
str1 = string.split(str,“:”)
然后遍历str1包装成数据表然后生成聊天记录
(2020--6--17)
网友评论