ToLua SimpleFramework NGUI/UGUI基础知识[5]

ToLua SimpleFramework NGUI/UGUI基础知识[5]

.lua中输出信息:

[csharp] view plain copy 

1. print("hello ") ;  

2. LuaFramework.Util.Log("World");   


其中Util这个类封装了很多实用的方法供lua调用,值得去看一下~

 

.重要的常量

1.Util.AppContentPath():游戏包资源目录。

[csharp] view plain copy 

1. Mac OS或Windows:Application.dataPath + "/StreamingAssets";  

2. IOS: Application.dataPath + "/Raw";  

3. Android:jar:file://" + Application.dataPath + "!/assets/";  


2.Util.DataPath:数据目录。外部路径。

[csharp] view plain copy 

1. Android或IOS:Application.persistentDataPath + "/LuaFramework"      

2. Mac OS或Windows:c:/LuaFramework/  

3. 调试模式下:Application.dataPath + "/StreamingAssets/"  


这里注意的是Application.platform这个东西,在Windowunity编辑器中,输出为RuntimePlatform.WindowsEditor,而不是RuntimePlatform.WindowsPlayer

[csharp] view plain copy 

1. Debug.Log(Application.platform);  

2. Debug.Log(Application.platform == RuntimePlatform.WindowsEditor);  

3. Debug.Log(Application.platform == RuntimePlatform.WindowsPlayer);  

4. Debug.Log(Util.DataPath);  

 

 

3.直接执行lua代码

找到AppConst.LuaBundleMode,如果为true,表示读取AB包内的lua文件,这意味着每次修改lua代码,都要重新build;为了提高效率,可以修改为false,表示直接读取lua文件。

 

4.从服务器下载东西来更新客户端

找到AppConst.UpdateMode,如果为true,表示将通过服务器更新资源。

 

.加载AB

AB包的加载方面,NGUI没有使用unity5的新打包方式,并没有处理好依赖关系,而UGUI使用的是新打包方式。因此建议将UGUI版本的ResourceManager替换NGUI版本的。至于LuaFrameworkAB包的加载流程,可以看一下http://blog.csdn.NET/lyh916/article/details/45021703

 

.常用的内置lua文件

1.LuaFramework\Lua\Common\functions.lua

Util一样,也是工具类,提供GameObject相关方法等

 

2.LuaFramework\ToLua\Lua\event.lua

提供每帧执行的方法

[csharp] view plain copy 

1. --主入口函数。从这里开始lua逻辑  

2. function Main()                                   

3.     UpdateBeat:Add(Update, self)  

4. end  

5.    

6. function Update()  

7.     Util.Log("Update");  

8. end  

除此之外,还有LateUpdateBeatFixedUpdateBeatCoUpdateBeat(协同)

3.LuaFramework\ToLua\Lua\UnityEngine

Vector3.luaMathf.lua

 

 

.常用的内置C#

1.LuaBehaviour

以例子实例化出来的PromptPanel为例,在AwakeStart中会调用PromptPanel.Awake(obj)PromptPanel.Start()

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值