Unity3d 开发之 ulua 坑的总结
来源:互联网 发布:linux基本命令的使用 编辑:程序博客网 时间:2024/05/16 14:48
原文地址
相同的 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
0 0
- Unity3d 开发之 ulua 坑的总结
- Unity3d为ulua提供更新的接口
- 关于uLua在Unity3D的性能测试
- Unity3D + ulua simpleframework的问题汇总
- Unity3D开发之Unity3D性能优化总结
- [Unity3D] 关于uLua在Unity3D的性能测试
- [Unity3D]uLua中类似Unity3D C# Messager的Event System
- unity3d ulua class
- Unity3d ulua 环境搭建与所遇到的问题
- android+unity3d游戏开发之事件总结
- unity3d热更新插件uLua
- 【游戏客户端开发】Unity3D 学习笔记4 —— UGUI+uLua游戏框架
- 自己总结的ulua代码写的一些方法
- [ulua]开发工具介绍
- 学习ULua之委托
- Unity3D开发总结一
- Unity3D开发总结2
- Unity3D开发总结3
- HDU 1048 The Hardest Problem Ever
- char数组赋值
- Android中Fragment数据保存和恢复
- [深度学习论文笔记][Visualizing] Striving for Simplicity: The All Convolutional Net
- Sublime text 3插件推荐
- Unity3d 开发之 ulua 坑的总结
- 认识J2EE, 解析J2EE中servlet标准, 理解web容器,java容器
- 安装linux和windows双系统
- ESC CenterOS 安装图形化界面
- TCP/IP网络编程之UDP
- hdu 5646 Partition数学+构造
- 关于班主任对于大数据的课堂介绍
- LeetCode 111. Minimum Depth of Binary Tree
- [深度学习论文笔记][Visualizing] 网络可视化部分论文导读