Unity3d 开发之 ulua 坑的总结
2016-10-29 10:17
295 查看
原文地址
相同的 lua 代码在安卓上能正常运行,但在 IOS 上可能不会正常运行而导致报红,崩溃等,我在使用 lua 编程时遇到的一些坑总结如下:
1. File.ReadAllText, 诸如以下代码在 ios 上会崩:
正确写法如下:
需指定编码格式。
2. DateTime.AddMinutes 在 ios 会找不到 AddMinutes 方法,但 AddSeconds 方法是可以的。
3. 在 ios 64位 release 版本上,使用 Color 会导致崩溃。
4. 诸如以下代码在 ios 64 位 release 版本上会 crash,其中 c# 代码为:
然后 LoadCardHandler 类通过 wraps 的方式映射到 lua 中,在 lua 中使用如下:
5. 诸如以下代码会在 ios 上报红:
6. 以下代码会导致 ios 上闪退:
7. c#的长整型传到lua代码中时会有一点误差,所以最好是把在c#里把长整形转成字符串再传到lua里。
8. 以下方法通过 wrap 的方式映射到 lua 中,在 lua 中调用。在用 xcode6.4 打包的 release 版本,在 64 位手机上运行此方法时将导致未响应。
其中c#的代码为:
lua代码为:
转载请注明出处:http://www.cnblogs.com/jietian331/p/4971120.html
相同的 lua 代码在安卓上能正常运行,但在 IOS 上可能不会正常运行而导致报红,崩溃等,我在使用 lua 编程时遇到的一些坑总结如下:
1. File.ReadAllText, 诸如以下代码在 ios 上会崩:
local path="C:/1.txt"; local file=luanet.import_type("System.IO.File"); local text=file.ReadAllText(path);
正确写法如下:
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);
需指定编码格式。
2. DateTime.AddMinutes 在 ios 会找不到 AddMinutes 方法,但 AddSeconds 方法是可以的。
local DateTime = luanet.import_type("System.DateTime"); local startTime=DateTime.Parse("..."); --local endTime=startTime:AddMinutes(1); -- 在 ios 上报红:找不到 AddMinutes 方法 local endTime=startTime:AddSeconds(60);
3. 在 ios 64位 release 版本上,使用 Color 会导致崩溃。
local uiLabel=this.transform:Find("Label"):GetComponent("UILabel"); uiLabel.color=Color.red; -- 其中,Color是ulua提供的类,此行代码将导致崩溃
4. 诸如以下代码在 ios 64 位 release 版本上会 crash,其中 c# 代码为:
public class LoadCardHandler { public GameObject Load(string name, Transform parent, int depth = 0, string defaultName = null) { ... } }
然后 LoadCardHandler 类通过 wraps 的方式映射到 lua 中,在 lua 中使用如下:
local loader=LoadCardHandler.New(); loader:Load(m_activityItemConfig.ad_pic,m_advertisementParent,100,"11400008"); -- 这行代码将导致崩溃。
5. 诸如以下代码会在 ios 上报红:
local button=rootTrans:GetComponent("UIButton"); button.onClick:Clear(); -- 在ios上此方法会报错
6. 以下代码会导致 ios 上闪退:
LuaUtils.ShowLoadSystemAnim("LoadAndClose", DelegateFactory.Action(Conceal));
7. c#的长整型传到lua代码中时会有一点误差,所以最好是把在c#里把长整形转成字符串再传到lua里。
8. 以下方法通过 wrap 的方式映射到 lua 中,在 lua 中调用。在用 xcode6.4 打包的 release 版本,在 64 位手机上运行此方法时将导致未响应。
其中c#的代码为:
public static string[] StringSplit(string src, params string[] separator) { return src.Split(separator, StringSplitOptions.RemoveEmptyEntries); }
lua代码为:
local lines=LuaHelper.StringSplit(text,"\n"); -- 此行代码: ios xcode6.4 出的包,在64位手机上导致未响应。
转载请注明出处:http://www.cnblogs.com/jietian331/p/4971120.html
相关文章推荐
- Unity3d 开发之 ulua 坑的总结
- Unity3D开发总结3
- unity3d中隐藏/显示物体方法总结 – unity3d游戏开发
- Unity3D开发基础组件提取总结
- Unity3D开发总结一
- Unity3D手游开发实践《腾讯桌球》客户端开发经验总结
- Unity3D手游开发实践《腾讯桌球》客户端开发经验总结
- Unity3D开发总结一
- Unity3D开发和总结:用C#封装类似苹果NSNotificationCenter消息通信机制(KVO)
- [Unity3D]U3D开发项目总结(转)
- 中级Unity3D开发工程师-面试经验总结
- Unity3D开发基础组件提取总结
- Unity3D开发之Unity3D性能优化总结
- Unity3D常用游戏开发插件测评总结
- 【小松教你手游开发】【unity实用技能】Unity3D之OnGUI知识总结
- Unity3D手游开发实践《腾讯桌球》客户端开发经验总结
- Unity3D手游开发实践《腾讯桌球》客户端开发经验总结
- FairyGUI与Unity3D开发案例小总结
- vuforia 结合 unity3d 开发 AR 的 androidAPP 总结
- 【游戏客户端开发】Unity3D 学习笔记4 —— UGUI+uLua游戏框架