-
Notifications
You must be signed in to change notification settings - Fork 202
Description
当使用静态变量 + 成员变量 + 派生类时,基类成员函数无法识别。
重现代码:
`using System;
using UnityEngine;
namespace CSLua
{
public class BaseClass
{
public string memberValue = string.Empty;
public static bool staticValue = false;
public void Show()
{
}
}
public class TestClass : BaseClass
{
}
public sealed class GameMain : MonoBehaviour
{
public void Awake()
{
var ins = new TestClass();
ins.Show();
}
}
}
`
编译后代码:
`-- Generated by CSharp.lua Compiler 1.1.0
local System = System
local CSLua
System.usingDeclare(function (global)
CSLua = global.CSLua
end)
System.namespace("CSLua", function (namespace)
namespace.class("BaseClass", function (namespace)
local Show, staticCtor, ctor
staticCtor = function (this)
this.staticValue = false
end
ctor = function (this)
this.memberValue = ""
end
Show = function (this)
end
return {
Show = Show,
staticCtor = staticCtor,
ctor = ctor
}
end)
namespace.class("TestClass", function (namespace)
local ctor
ctor = function (this)
this.base.ctor(this)
end
return {
inherits = function (global)
return {
global.CSLua.BaseClass
}
end,
ctor = ctor
}
end)
namespace.class("GameMain", function (namespace)
local Awake
Awake = function (this)
local ins = CSLua.TestClass()
ins:Show()
end
return {
inherits = function (global)
return {
global.UnityEngine.MonoBehaviour
}
end,
Awake = Awake
}
end)
end)
`
报错堆栈:
LuaException: D:/OWM_Client3/Assets/CSharpLua/Lua/CompiledScripts/CSLua/GameMain.lua:43: attempt to call method 'Show' (a nil value) stack traceback: D:/OWM_Client3/Assets/CSharpLua/Lua/CompiledScripts/CSLua/GameMain.lua:43: in function 'Awake' D:/OWM_Client3/Assets/CSharpLua/Lua/UnityAdapter.lua:240: in function '__ctor__' D:/OWM_Client3/Assets/CSharpLua/Lua/CoreSystemLua/CoreSystem/Core.lua:48: in function <D:/OWM_Client3/Assets/CSharpLua/Lua/CoreSystemLua/CoreSystem/Core.lua:46> LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/CSharpLua/BaseScripts/ToLua/Core/LuaState.cs:738) LuaInterface.LuaFunction:PCall() (at Assets/CSharpLua/BaseScripts/ToLua/Core/LuaFunction.cs:96) LuaInterface.LuaFunction:Call(GameObject, String) (at Assets/CSharpLua/BaseScripts/ToLua/Core/LuaFunction.cs:137) CSharpLua.CSharpLuaClient:StartMain() (at Assets/CSharpLua/BaseScripts/CSharpLua/CSharpLuaClient.cs:97) LuaClient:OnLoadFinished() (at Assets/CSharpLua/BaseScripts/ToLua/Misc/LuaClient.cs:183) LuaClient:LoadLuaFiles() (at Assets/CSharpLua/BaseScripts/ToLua/Misc/LuaClient.cs:54) LuaClient:Init() (at Assets/CSharpLua/BaseScripts/ToLua/Misc/LuaClient.cs:166) LuaClient:Awake() (at Assets/CSharpLua/BaseScripts/ToLua/Misc/LuaClient.cs:172)