Skip to content

Commit

Permalink
iOS默认加载luaopen_bit。
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin committed Dec 18, 2015
1 parent b0cd3fe commit f086925
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 38 deletions.
11 changes: 3 additions & 8 deletions Assets/Lua/Common/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ function log(str)
Util.Log(str);
end

--打印字符串--
function print(str)
Util.Log(str);
end

--错误日志--
function error(str)
function logError(str)
Util.LogError(str);
end

--警告日志--
function warn(str)
function logWarn(str)
Util.LogWarning(str);
end

Expand All @@ -28,7 +23,7 @@ function destroy(obj)
GameObject.Destroy(obj);
end

function newobject(prefab)
function newObject(prefab)
return GameObject.Instantiate(prefab);
end

Expand Down
6 changes: 3 additions & 3 deletions Assets/Lua/Controller/MessageCtrl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ local gameObject;

--构建函数--
function MessageCtrl.New()
warn("MessageCtrl.New--->>");
logWarn("MessageCtrl.New--->>");
return this;
end

function MessageCtrl.Awake()
warn("MessageCtrl.Awake--->>");
logWarn("MessageCtrl.Awake--->>");
PanelManager:CreatePanel('Message', this.OnCreate);
end

Expand All @@ -27,7 +27,7 @@ function MessageCtrl.OnCreate(obj)
message = gameObject:GetComponent('LuaBehaviour');
message:AddClick(MessagePanel.btnClose, this.OnClick);

warn("Start lua--->>"..gameObject.name);
logWarn("Start lua--->>"..gameObject.name);
end

--单击事件--
Expand Down
10 changes: 5 additions & 5 deletions Assets/Lua/Controller/PromptCtrl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ local gameObject;

--构建函数--
function PromptCtrl.New()
warn("PromptCtrl.New--->>");
logWarn("PromptCtrl.New--->>");
return this;
end

function PromptCtrl.Awake()
warn("PromptCtrl.Awake--->>");
logWarn("PromptCtrl.Awake--->>");
PanelManager:CreatePanel('Prompt', this.OnCreate);
end

Expand All @@ -33,7 +33,7 @@ function PromptCtrl.OnCreate(obj)

panel = transform:GetComponent('UIPanel');
prompt = transform:GetComponent('LuaBehaviour');
warn("Start lua--->>"..gameObject.name);
logWarn("Start lua--->>"..gameObject.name);

this.InitPanel(); --初始化面板--
prompt:AddClick(PromptPanel.btnOpen, this.OnClick);
Expand All @@ -45,7 +45,7 @@ function PromptCtrl.InitPanel()
local parent = PromptPanel.gridParent;
local itemPrefab = prompt:GetGameObject('PromptItem');
for i = 1, 100 do
local go = newobject(itemPrefab);
local go = newObject(itemPrefab);
go.name = tostring(i);
go.transform.parent = parent;
go.transform.localScale = Vector3.one;
Expand Down Expand Up @@ -80,7 +80,7 @@ function PromptCtrl.OnClick(go)
if TestProtoType == ProtocalType.SPROTO then
this.TestSendSproto();
end
warn("OnClick---->>>"..go.name);
logWarn("OnClick---->>>"..go.name);
end

--测试发送SPROTO--
Expand Down
4 changes: 2 additions & 2 deletions Assets/Lua/Logic/CtrlManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local this = CtrlManager;
local ctrlList = {}; --控制器列表--

function CtrlManager.Init()
warn("CtrlManager.Init----->>>");
logWarn("CtrlManager.Init----->>>");
ctrlList[CtrlName.Prompt] = PromptCtrl.New();
ctrlList[CtrlName.Message] = MessageCtrl.New();
return this;
Expand All @@ -30,5 +30,5 @@ end

--关闭控制器--
function CtrlManager.Close()
warn('CtrlManager.Close---->>>');
logWarn('CtrlManager.Close---->>>');
end
14 changes: 7 additions & 7 deletions Assets/Lua/Logic/GameManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ function GameManager.OnInitOK()
ctrl:Awake();
end

warn('SimpleFramework InitOK--->>>');
logWarn('SimpleFramework InitOK--->>>');
end

--测试协同--
function GameManager.test_coroutine()
warn("1111");
logWarn("1111");
coroutine.wait(1);
warn("2222");
logWarn("2222");

local www = WWW("http://bbs.ulua.org/readme.txt");
coroutine.www(www);
warn(www.text);
logWarn(www.text);
end

--测试sproto--
function GameManager.test_sproto_func()
warn("test_sproto_func-------->>");
logWarn("test_sproto_func-------->>");
local sp = sproto.parse [[
.Person {
name 0 : string
Expand Down Expand Up @@ -129,7 +129,7 @@ end

--测试lpeg--
function GameManager.test_lpeg_func()
warn("test_lpeg_func-------->>");
logWarn("test_lpeg_func-------->>");
-- matches a word followed by end-of-string
local p = lpeg.R"az"^1 * -1

Expand Down Expand Up @@ -216,5 +216,5 @@ end

--销毁--
function GameManager.OnDestroy()
--warn('OnDestroy--->>>');
--logWarn('OnDestroy--->>>');
end
2 changes: 1 addition & 1 deletion Assets/Lua/Logic/LuaClass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

--测试打印方法--
function LuaClass:test()
warn("x:>" .. self.x .. " y:>" .. self.y);
logWarn("x:>" .. self.x .. " y:>" .. self.y);
end

--endregion
12 changes: 6 additions & 6 deletions Assets/Lua/Logic/Network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local gameObject;
local islogging = false;

function Network.Start()
warn("Network.Start!!");
logWarn("Network.Start!!");
Event.AddListener(Connect, this.OnConnect);
Event.AddListener(Login, this.OnLogin);
Event.AddListener(Exception, this.OnException);
Expand All @@ -33,20 +33,20 @@ end

--当连接建立时--
function Network.OnConnect()
warn("Game Server connected!!");
logWarn("Game Server connected!!");
end

--异常断线--
function Network.OnException()
islogging = false;
NetManager:SendConnect();
error("OnException------->>>>");
logError("OnException------->>>>");
end

--连接中断,或者被踢掉--
function Network.OnDisconnect()
islogging = false;
error("OnDisconnect------->>>>");
logError("OnDisconnect------->>>>");
end

--登录返回--
Expand All @@ -69,7 +69,7 @@ function Network.OnLogin(buffer)
if ctrl ~= nil then
ctrl:Awake();
end
warn('OnLogin----------->>>');
logWarn('OnLogin----------->>>');
end

--二进制登录--
Expand Down Expand Up @@ -145,5 +145,5 @@ function Network.Unload()
Event.RemoveListener(Login);
Event.RemoveListener(Exception);
Event.RemoveListener(Disconnect);
warn('Unload Network...');
logWarn('Unload Network...');
end
4 changes: 2 additions & 2 deletions Assets/Lua/View/MessagePanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function MessagePanel.Awake(obj)
transform = obj.transform;

this.InitPanel();
warn("Awake lua--->>"..gameObject.name);
logWarn("Awake lua--->>"..gameObject.name);
end

--初始化面板--
Expand All @@ -20,6 +20,6 @@ end

--单击事件--
function MessagePanel.OnDestroy()
warn("OnDestroy---->>>");
logWarn("OnDestroy---->>>");
end

4 changes: 2 additions & 2 deletions Assets/Lua/View/PromptPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function PromptPanel.Awake(obj)
transform = obj.transform;

this.InitPanel();
warn("Awake lua--->>"..gameObject.name);
logWarn("Awake lua--->>"..gameObject.name);
end

--初始化面板--
Expand All @@ -21,5 +21,5 @@ end

--单击事件--
function PromptPanel.OnDestroy()
warn("OnDestroy---->>>");
logWarn("OnDestroy---->>>");
end
3 changes: 3 additions & 0 deletions Assets/uLua/Core/LuaDLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public class LuaDLL

[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_cjson_safe(IntPtr L);

[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_bit(IntPtr L);
#if UNITY_EDITOR
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_socket_core(IntPtr L);
Expand Down
4 changes: 4 additions & 0 deletions Assets/uLua/Source/Base/LuaScriptMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public LuaScriptMgr()
if (AppConst.UseSproto) {
LuaDLL.luaopen_sproto_core(lua.L);
}
if (Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.OSXEditor) {
LuaDLL.luaopen_bit(lua.L);
}
#if UNITY_EDITOR
LuaDLL.luaopen_socket_core(lua.L);
#endif
Expand Down
5 changes: 3 additions & 2 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
游戏案例地址 http://www.ulua.org/showcase.html
框架详细介绍 http://doc.ulua.org/default.asp?cateID=4

//-------------2015-11-28-------------
(1)修复清理纹理引用遗留BUG。
//-------------2015-12-18-------------
(1)iOS默认加载bit。
(2)修改functions.lua里面warn、error、newobject函数为logWarn、logError、newObject。

//-------------2015-11-10-------------
(1)添加lua中使用self关键字例子A6_LuaCall
Expand Down

0 comments on commit f086925

Please sign in to comment.