The same LUA code works on Android, but it may not work properly on IOS, resulting in red, crash, and so on, some of the pits I encountered while using LUA programming are summarized below:
1. File.readalltext, such as the following code will collapse on iOS:
Local path= "C:/1.txt"; local File=luanet.import_type ("System.IO.File"); local text=file. ReadAllText (path);
The correct wording is as follows:
Local path="c:/1.txt"; local file=luanet.import_type (" System.IO.File");
Local Encoding=luanet.import_type ("System.Text.Encoding"); local Text=file. ReadAllText (path,encoding. UTF8);
You need to specify the encoding format.
2. Datetime.addminutes cannot find the AddMinutes method on iOS, but the AddSeconds method is possible.
Local DateTime = Luanet.import_type ("System.DateTime"); local Starttime=datetime.parse ("...");--local endtime= Starttime:addminutes (1); --in iOS report red: AddMinutes method not found local endtime=starttime:addseconds (60);
Unity3d development of Lua in IOS on the pit summary