public static Bounds ToBounds(IntPtr L, int stackPos) { int top = LuaDLL.lua_gettop(L); LuaStatic.GetUnpackBounds(L); LuaDLL.lua_pushvalue(L, stackPos); if (LuaDLL.lua_pcall(L, 1, 2, 0) == 0) { Vector3 center = ToVector3(L, top + 1); Vector3 size = ToVector3(L, top + 2); return(new Bounds(center, size)); } else { string error = LuaDLL.lua_tostring(L, -1); throw new LuaException(error); } }
public static Ray ToRay(IntPtr L, int stackPos) { int top = LuaDLL.lua_gettop(L); LuaStatic.GetUnpackRayRef(L); LuaDLL.lua_pushvalue(L, stackPos); if (LuaDLL.lua_pcall(L, 1, 2, 0) == 0) { Vector3 origin = ToVector3(L, top + 1); Vector3 dir = ToVector3(L, top + 2); return(new Ray(origin, dir)); } else { string error = LuaDLL.lua_tostring(L, -1); throw new LuaException(error); } }
public static void PushValue(IntPtr L, ValueType v) { if (v == null) { LuaDLL.lua_pushnil(L); return; } Type type = v.GetType(); int reference = LuaStatic.GetMetaReference(L, type); ObjectTranslator translator = ObjectTranslator.Get(L); if (reference > 0) { int index = translator.AddObject(v); LuaDLL.tolua_pushnewudata(L, reference, index); } else { LuaCSFunction LuaOpenLib = LuaStatic.GetPreModule(L, type); if (LuaOpenLib != null) { #if UNITY_EDITOR lhDebug.LogWarning("register PreLoad type {0} to lua", LuaMisc.GetTypeName(type)); #endif LuaOpenLib(L); reference = LuaStatic.GetMetaReference(L, type); if (reference > 0) { int index = translator.AddObject(v); LuaDLL.tolua_pushnewudata(L, reference, index); return; } } //类型未Wrap LuaDLL.lua_pushnil(L); lhDebug.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type)); } }
public static void Push(IntPtr L, Touch t, int flag) { LuaStatic.GetPackTouch(L); LuaDLL.lua_pushinteger(L, t.fingerId); if ((flag & TouchBits.Position) != 0) { Push(L, t.position); } else { LuaDLL.lua_pushnil(L); } if ((flag & TouchBits.RawPosition) != 0) { Push(L, t.rawPosition); } else { LuaDLL.lua_pushnil(L); } if ((flag & TouchBits.DeltaPosition) != 0) { Push(L, t.deltaPosition); } else { LuaDLL.lua_pushnil(L); } LuaDLL.lua_pushnumber(L, t.deltaTime); LuaDLL.lua_pushinteger(L, t.tapCount); LuaDLL.lua_pushinteger(L, (int)t.phase); if (LuaDLL.lua_pcall(L, 7, -1, 0) != 0) { string error = LuaDLL.lua_tostring(L, -1); throw new LuaException(error); } }
static void PushPreLoadType(IntPtr L, object o, Type type) { LuaCSFunction LuaOpenLib = LuaStatic.GetPreModule(L, type); if (LuaOpenLib != null) { #if UNITY_EDITOR lhDebug.LogWarning("register PreLoad type {0} to lua", LuaMisc.GetTypeName(type)); #endif LuaPCall(L, LuaOpenLib); int reference = LuaStatic.GetMetaReference(L, type); if (reference > 0) { PushUserData(L, o, reference); return; } } //类型未Wrap LuaDLL.lua_pushnil(L); lhDebug.LogError("Type {0} not wrap to lua", LuaMisc.GetTypeName(type)); }
public static object ToVarTable(IntPtr L, int stackPos) { stackPos = LuaDLL.abs_index(L, stackPos); LuaValueType ret = LuaDLL.tolua_getvaluetype(L, stackPos); switch (ret) { case LuaValueType.Vector3: return(ToVector3(L, stackPos)); case LuaValueType.Quaternion: return(ToQuaternion(L, stackPos)); case LuaValueType.Vector4: return(ToVector4(L, stackPos)); case LuaValueType.Color: return(ToColor(L, stackPos)); case LuaValueType.Ray: return(ToRay(L, stackPos)); case LuaValueType.Bounds: return(ToBounds(L, stackPos)); case LuaValueType.Vector2: return(ToVector2(L, 2)); case LuaValueType.LayerMask: return(ToLayerMask(L, stackPos)); default: LuaDLL.lua_pushvalue(L, stackPos); int reference = LuaDLL.toluaL_ref(L); return(LuaStatic.GetTable(L, reference)); } }