xlua.dll,反编译查看LuaVersion
coroutine.start(function()
coroutine.waitforseconds(math.random(0, 3))
-- local generatedPos = Vector3.new(from.x + randX, from.y, from.z + randZ)
end)
-- hitInfo一直为空 static int _m_Raycast_xlua_st_(RealStatePtr L)
local ray = self.tile_camera:ScreenPointToRay(screenPoint)
local res, hitInfo = CS.UnityEngine.Physics.Raycast(ray)
if res then
print("hitInfo.transform", hitInfo.transform)
end
function TerrainAgent:WorldToUGUIPosition(envCamera, worldPosition)
local viewPos = envCamera:WorldToViewportPoint(worldPosition)
local screenSize = lt.GameUtil:getScreenSize()
return Vector2.new(screenSize.x * viewPos.x, screenSize.y * viewPos.y)
end
GenAttributes.cs
:
[GCOptimize]
static List<Type> GCOptimize
{
get
{
return new List<Type>() {
typeof(UnityEngine.Vector2),
typeof(UnityEngine.Vector3),
typeof(UnityEngine.Vector4),
typeof(UnityEngine.Color),
typeof(UnityEngine.Quaternion),
typeof(UnityEngine.Ray),
typeof(UnityEngine.Bounds),
typeof(UnityEngine.Ray2D),
};
}
}
CS.UnityEngine.Screen.width
CS.UnityEngine.Screen.height
tilemap->右键->reimport
ModelCustomData.cs
:
public Action<int, string> modelEvent = null;
...
public void onModelEvent(int key, string json){
if (modelEvent != null) {
modelEvent.Invoke(key, json);
}
}
SoldierActorModel.lua
:
local model_custom_data_type = typeof(CS.ModelCustomData)
self.soldier_model_custom_data = go:AddComponent(model_custom_data_type)
self.soldier_model_custom_data.modelEvent = BindCallback(self.onModelEvent, self)
...
function SoldierActorModel:onModelEvent(key, value)
lt.CommonUtil.print("SoldierActorModel:onModelEvent", key, value)
end
*.cs
var UpdaterManager = luaEnv.Global.Get<LuaTable>("UpdaterManager");
UpdaterManager.Get<Action<LuaTable>>("testFunc")(UpdaterManager);
*.lua
function UpdaterManager:testFunc()
print("UpdaterManager:testFunc()")
end
重新打开Unity3D
CMake Error: Could not create named generator Visual Studio 16 2019 Win64
cmake -DLUA_VERSION=5.4.1 -G "Visual Studio 16 2019 Win64" -A "x64" ..
改为
cmake -DLUA_VERSION=5.4.1 -G "Visual Studio 16 2019" -A "x64" ..
c#对lua的引用在luaenv.Tick里头处理
collectgarbage("collect")
CS.System.GC.Collect()
CS.XLuaManager.Instance.Env:FullGc()
CS.XLuaManager.Instance.Env:GC()
定时调用
CS.XLuaManager.Instance.Env:Tick()
lua握着的c#对象的引用,在析构的时候要解绑掉 不然一直引用着必须等lua gc掉,c#才可能在未来的某刻回收掉此销毁对象 材质球new Materail需要手动Destroy掉