Skip to content

Commit c59fa62

Browse files
committed
对例子进行了一些修改
1 parent 1e2b2ac commit c59fa62

File tree

70 files changed

+257
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+257
-93
lines changed

HotUpdate/uLuaDemo/Assets/Editor/Custom/CustomSettings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public static class CustomSettings
5252
//_GT(typeof(Dictionary<int, TestAccount>.ValueCollection)),
5353
//_GT(typeof(TestExport)),
5454
//_GT(typeof(TestExport.Space)),
55-
//-------------------------------------------------------------------
56-
_GT(typeof(CSLuaTest)),
55+
//-------------------------------------------------------------------
56+
_GT(typeof(CSFunctionTest)),
5757
_GT(typeof(Debugger)).SetNameSpace(null),
5858

5959
#if USING_DOTWEENING
Binary file not shown.

HotUpdate/uLuaDemo/Assets/Scenes/RegisterFunctionAuto.unity.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class CSFunctionTest
6+
{
7+
/// <summary>
8+
/// 此方法可以通过ulua自动生成warp文件
9+
/// </summary>
10+
/// <param name="name"></param>
11+
/// <returns></returns>
12+
public static void CSFunction(string name)
13+
{
14+
Debug.Log("Hello," + name);
15+
}
16+
17+
public static void CSAdd(int num)
18+
{
19+
Debug.Log("Result: " + num + 1);
20+
}
21+
}

HotUpdate/uLuaDemo/Assets/Source/Generate/CSLuaTestWrap.cs.meta renamed to HotUpdate/uLuaDemo/Assets/Scripts/CSFunctionTest.cs.meta

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using LuaInterface;
4+
using UnityEngine;
5+
6+
public class CSLuaTest2 : MonoBehaviour {
7+
8+
/// <summary>
9+
/// lua虚拟机
10+
/// </summary>
11+
private LuaState luaState;
12+
13+
14+
// Use this for initialization
15+
void Start () {
16+
17+
//创建lua虚拟机
18+
luaState = new LuaState();
19+
DelegateFactory.Init();
20+
luaState.Start();
21+
22+
//在lua虚拟机(全局)中注册自定义函数
23+
luaState.BeginModule(null);
24+
CSFunctionTestWrap.Register(luaState);
25+
luaState.EndModule();
26+
27+
//加载lua脚本
28+
this.luaState.DoFile(Application.streamingAssetsPath + "/MyLua2.lua");
29+
30+
//加载完lua以后,获取lua中的函数,并执行。(此lua脚本回调了C#中的方法)
31+
LuaFunction luaFunction = luaState.GetFunction("LuaFunction");
32+
luaFunction.BeginPCall();
33+
luaFunction.Push("张三");
34+
luaFunction.PCall();
35+
luaFunction.EndPCall();
36+
37+
luaFunction = luaState.GetFunction("LuaAdd");
38+
luaFunction.BeginPCall();
39+
luaFunction.Push(100);
40+
luaFunction.PCall();
41+
luaFunction.EndPCall();
42+
43+
luaFunction.Dispose();
44+
luaState.Dispose();
45+
luaFunction = null;
46+
luaState = null;
47+
}
48+
49+
// Update is called once per frame
50+
void Update () {
51+
52+
}
53+
}

HotUpdate/uLuaDemo/Assets/Scripts/CSLuaTest2.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//this source code was auto-generated by tolua#, do not modify it
2+
using System;
3+
using LuaInterface;
4+
5+
public class CSFunctionTestWrap
6+
{
7+
public static void Register(LuaState L)
8+
{
9+
L.BeginClass(typeof(CSFunctionTest), typeof(System.Object));
10+
L.RegFunction("CSFunction", CSFunction);
11+
L.RegFunction("CSAdd", CSAdd);
12+
L.RegFunction("New", _CreateCSFunctionTest);
13+
L.RegFunction("__tostring", ToLua.op_ToString);
14+
L.EndClass();
15+
}
16+
17+
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
18+
static int _CreateCSFunctionTest(IntPtr L)
19+
{
20+
try
21+
{
22+
int count = LuaDLL.lua_gettop(L);
23+
24+
if (count == 0)
25+
{
26+
CSFunctionTest obj = new CSFunctionTest();
27+
ToLua.PushObject(L, obj);
28+
return 1;
29+
}
30+
else
31+
{
32+
return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: CSFunctionTest.New");
33+
}
34+
}
35+
catch (Exception e)
36+
{
37+
return LuaDLL.toluaL_exception(L, e);
38+
}
39+
}
40+
41+
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
42+
static int CSFunction(IntPtr L)
43+
{
44+
try
45+
{
46+
ToLua.CheckArgsCount(L, 1);
47+
string arg0 = ToLua.CheckString(L, 1);
48+
CSFunctionTest.CSFunction(arg0);
49+
return 0;
50+
}
51+
catch (Exception e)
52+
{
53+
return LuaDLL.toluaL_exception(L, e);
54+
}
55+
}
56+
57+
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
58+
static int CSAdd(IntPtr L)
59+
{
60+
try
61+
{
62+
ToLua.CheckArgsCount(L, 1);
63+
int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
64+
CSFunctionTest.CSAdd(arg0);
65+
return 0;
66+
}
67+
catch (Exception e)
68+
{
69+
return LuaDLL.toluaL_exception(L, e);
70+
}
71+
}
72+
}
73+

HotUpdate/uLuaDemo/Assets/Source/Generate/CSFunctionTestWrap.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/CSLuaTestWrap.cs

-33
This file was deleted.

HotUpdate/uLuaDemo/Assets/Source/Generate/LuaBinder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static void Bind(LuaState L)
99
{
1010
float t = Time.realtimeSinceStartup;
1111
L.BeginModule(null);
12-
CSLuaTestWrap.Register(L);
12+
CSFunctionTestWrap.Register(L);
1313
LuaInterface_DebuggerWrap.Register(L);
1414
L.BeginModule("UnityEngine");
1515
UnityEngine_ComponentWrap.Register(L);

HotUpdate/uLuaDemo/Assets/Source/Generate/LuaInterface_DebuggerWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AnimationBlendModeWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AnimationClipWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AnimationStateWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AnimationWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AnimatorWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_ApplicationWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AssetBundleWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AsyncOperationWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AudioClipWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_AudioSourceWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_BehaviourWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_BlendWeightsWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_BoxColliderWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_CameraClearFlagsWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_CameraWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_CapsuleColliderWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_CharacterControllerWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HotUpdate/uLuaDemo/Assets/Source/Generate/UnityEngine_ColliderWrap.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)