Initial commit: Client Doc docs Server Tools

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ud18010
2026-07-10 10:24:29 +08:00
co-authored by Cursor
commit 7e35d8da31
3374 changed files with 680813 additions and 0 deletions
@@ -0,0 +1,3 @@
{
"name": "ExternFunc"
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3a32835850a4b6847ab1e412d20c51ae
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+999
View File
@@ -0,0 +1,999 @@
/*
* Tencent is pleased to support the open source community by making xLua available.
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
namespace XLuaBase
{
using System;
using System.Runtime.InteropServices;
using System.Text;
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || XLUA_GENERAL || (UNITY_WSA && !UNITY_EDITOR)
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int lua_CSFunction(IntPtr L);
#if GEN_CODE_MINIMIZE
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int CSharpWrapperCaller(IntPtr L, int funcidx, int top);
#endif
#else
public delegate int lua_CSFunction(IntPtr L);
#if GEN_CODE_MINIMIZE
public delegate int CSharpWrapperCaller(IntPtr L, int funcidx, int top);
#endif
#endif
public partial class Lua
{
#if (UNITY_IPHONE || UNITY_TVOS || UNITY_WEBGL || UNITY_SWITCH) && !UNITY_EDITOR
const string LUADLL = "__Internal";
#else
const string LUADLL = "xlua";
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_tothread(IntPtr L, int index);
public static IntPtr lua_tothread(IntPtr L, int index)
{
return cxx_lua_tothread(L, index);
}
#else
public static extern IntPtr lua_tothread(IntPtr L, int index);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_get_lib_version();
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_gc(IntPtr L, int what, int data);
public static int lua_gc(IntPtr L, int what, int data)
{
return cxx_lua_gc(L, what, data);
}
#else
public static extern int lua_gc(IntPtr L, int what, int data);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_getupvalue(IntPtr L, int funcindex, int n);
public static IntPtr lua_getupvalue(IntPtr L, int funcindex, int n)
{
return cxx_lua_getupvalue(L, funcindex, n);
}
#else
public static extern IntPtr lua_getupvalue(IntPtr L, int funcindex, int n);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_setupvalue(IntPtr L, int funcindex, int n);
public static IntPtr lua_setupvalue(IntPtr L, int funcindex, int n)
{
return cxx_lua_setupvalue(L, funcindex, n);
}
#else
public static extern IntPtr lua_setupvalue(IntPtr L, int funcindex, int n);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_pushthread(IntPtr L);
public static int lua_pushthread(IntPtr L)
{
return cxx_lua_pushthread(L);
}
#else
public static extern int lua_pushthread(IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_setfenv(IntPtr L, int stackPos);
public static int lua_setfenv(IntPtr L, int stackPos)
{
return cxx_lua_setfenv(L, stackPos);
}
#else
public static extern int lua_setfenv(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_luaL_newstate();
public static IntPtr luaL_newstate()
{
return cxx_luaL_newstate();
}
#else
public static extern IntPtr luaL_newstate();
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_close(IntPtr L);
public static void lua_close(IntPtr L)
{
cxx_lua_close(L);
}
#else
public static extern void lua_close(IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[-0, +0, m]
public static extern void luaopen_xlua(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[-0, +0, m]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_luaL_openlibs(IntPtr L);
public static void luaL_openlibs(IntPtr L)
{
cxx_luaL_openlibs(L);
}
#else
public static extern void luaL_openlibs(IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern uint xlua_objlen(IntPtr L, int stackPos);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_createtable(IntPtr L, int narr, int nrec);
public static void lua_createtable(IntPtr L, int narr, int nrec)
{
cxx_lua_createtable(L, narr, nrec);
}
#else
public static extern void lua_createtable(IntPtr L, int narr, int nrec); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_settop(IntPtr L, int stackPos);
public static void lua_settop(IntPtr L, int stackPos)
{
cxx_lua_settop(L, stackPos);
}
#else
#if UNITY_WEBGL
public static extern void lua_settop(IntPtr L, int stackPos);
#else
public static extern int lua_settop(IntPtr L, int stackPos);
#endif
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_insert(IntPtr L, int stackPos);
public static void lua_insert(IntPtr L, int stackPos)
{
cxx_lua_insert(L, stackPos);
}
#else
#if UNITY_WEBGL
public static extern void lua_insert(IntPtr L, int stackPos);
#else
public static extern int lua_insert(IntPtr L, int stackPos);
#endif
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_remove(IntPtr L, int stackPos);
public static void lua_remove(IntPtr L, int stackPos)
{
cxx_lua_remove(L, stackPos);
}
#else
#if UNITY_WEBGL
public static extern void lua_remove(IntPtr L, int stackPos);
#else
public static extern int lua_remove(IntPtr L, int stackPos);
#endif
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_rawget(IntPtr L, int stackPos);
public static int lua_rawget(IntPtr L, int stackPos)
{
return cxx_lua_rawget(L, stackPos);
}
#else
public static extern int lua_rawget(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_rawset(IntPtr L, int stackPos);
public static void lua_rawset(IntPtr L, int stackPos)
{
cxx_lua_rawset(L, stackPos);
}
#else
#if UNITY_WEBGL
public static extern void lua_rawset(IntPtr L, int stackPos);
#else
public static extern int lua_rawset(IntPtr L, int stackPos);
#endif
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_setmetatable(IntPtr L, int stackPos);
public static int lua_setmetatable(IntPtr L, int stackPos)
{
return cxx_lua_setmetatable(L, stackPos);
}
#else
public static extern int lua_setmetatable(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_rawequal(IntPtr L, int index1, int index2);
public static int lua_rawequal(IntPtr L, int index1, int index2)
{
return cxx_lua_rawequal(L, index1, index2);
}
#else
public static extern int lua_rawequal(IntPtr L, int index1, int index2);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushvalue(IntPtr L, int stackPos);
public static void lua_pushvalue(IntPtr L, int stackPos)
{
cxx_lua_pushvalue(L, stackPos);
}
#else
public static extern void lua_pushvalue(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushcclosure(IntPtr L, IntPtr fn, int n); //[-n, +1, m]
public static void lua_pushcclosure(IntPtr L, IntPtr fn, int n)
{
cxx_lua_pushcclosure(L, fn, n);
}
#else
public static extern void lua_pushcclosure(IntPtr L, IntPtr fn, int n); //[-n, +1, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_replace(IntPtr L, int stackPos); //[-n, +1, m]
public static void lua_replace(IntPtr L, int stackPos)
{
cxx_lua_replace(L, stackPos);
}
#else
public static extern void lua_replace(IntPtr L, int stackPos); //[-n, +1, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_gettop(IntPtr L);
public static int lua_gettop(IntPtr L)
{
return cxx_lua_gettop(L);
}
#else
public static extern int lua_gettop(IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_type(IntPtr L, int stackPos);
public static int lua_type(IntPtr L, int stackPos)
{
return cxx_lua_type(L, stackPos);
}
#else
public static extern int lua_type(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_isnumber(IntPtr L, int stackPos);
public static bool lua_isnumber(IntPtr L, int stackPos)
{
return cxx_lua_isnumber(L, stackPos);
}
#else
public static extern bool lua_isnumber(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaL_ref(IntPtr L, int stackPos);
public static int luaL_ref(IntPtr L, int stackPos)
{
return cxx_luaL_ref(L, stackPos);
}
#else
public static extern int luaL_ref(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_luaL_unref(IntPtr L, int stackPos, int r);
public static void luaL_unref(IntPtr L, int stackPos, int r)
{
cxx_luaL_unref(L, stackPos, r);
}
#else
#if UNITY_WEBGL
public static extern void luaL_unref(IntPtr L, int stackPos, int r);
#else
public static extern int luaL_unref(IntPtr L, int stackPos, int r);
#endif
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_isstring(IntPtr L, int stackPos);
public static bool lua_isstring(IntPtr L, int stackPos)
{
return cxx_lua_isstring(L, stackPos);
}
#else
public static extern bool lua_isstring(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_isinteger(IntPtr L, int stackPos);
public static bool lua_isinteger(IntPtr L, int stackPos)
{
return cxx_lua_isinteger(L, stackPos);
}
#else
public static extern bool lua_isinteger(IntPtr L, int stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushnil(IntPtr L);
public static void lua_pushnil(IntPtr L)
{
cxx_lua_pushnil(L);
}
#else
public static extern void lua_pushnil(IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_atpanic(IntPtr L, lua_CSFunction panicf);
public static IntPtr lua_atpanic(IntPtr L, lua_CSFunction panicf)
{
return cxx_lua_atpanic(L, panicf);
}
#else
public static extern IntPtr lua_atpanic(IntPtr L, lua_CSFunction panicf);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushnumber(IntPtr L, double stackPos);
public static void lua_pushnumber(IntPtr L, double stackPos)
{
cxx_lua_pushnumber(L, stackPos);
}
#else
public static extern void lua_pushnumber(IntPtr L, double stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushboolean(IntPtr L, bool stackPos);
public static void lua_pushboolean(IntPtr L, bool stackPos)
{
cxx_lua_pushboolean(L, stackPos);
}
#else
public static extern void lua_pushboolean(IntPtr L, bool stackPos);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaL_newmetatable(IntPtr L, string meta);
public static int luaL_newmetatable(IntPtr L, string meta)
{
return cxx_luaL_newmetatable(L, meta);
}
#else
public static extern int luaL_newmetatable(IntPtr L, string meta); //[-0, +1, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_pcall(IntPtr L, int nArgs, int nResults, int errfunc);
public static int lua_pcall(IntPtr L, int nArgs, int nResults, int errfunc)
{
return cxx_lua_pcall(L, nArgs, nResults, errfunc);
}
#else
public static extern int lua_pcall(IntPtr L, int nArgs, int nResults, int errfunc);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern double cxx_lua_tonumber(IntPtr L, int index);
public static double lua_tonumber(IntPtr L, int index)
{
return cxx_lua_tonumber(L, index);
}
#else
public static extern double lua_tonumber(IntPtr L, int index);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_toboolean(IntPtr L, int index);
public static bool lua_toboolean(IntPtr L, int index)
{
return cxx_lua_toboolean(L, index);
}
#else
public static extern bool lua_toboolean(IntPtr L, int index);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_topointer(IntPtr L, int index);
public static IntPtr lua_topointer(IntPtr L, int index)
{
return cxx_lua_topointer(L, index);
}
#else
public static extern IntPtr lua_topointer(IntPtr L, int index);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_tolstring(IntPtr L, int index, out IntPtr strLen);
public static IntPtr lua_tolstring(IntPtr L, int index, out IntPtr strLen)
{
return cxx_lua_tolstring(L, index, out strLen);
}
#else
public static extern IntPtr lua_tolstring(IntPtr L, int index, out IntPtr strLen); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_checkstack(IntPtr L, int index);
public static bool lua_checkstack(IntPtr L, int index)
{
return cxx_lua_checkstack(L, index);
}
#else
public static extern bool lua_checkstack(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_lua_next(IntPtr L, int index);
public static int lua_next(IntPtr L, int index)
{
return cxx_lua_next(L, index);
}
#else
public static extern int lua_next(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushlightuserdata(IntPtr L, IntPtr index);
public static void lua_pushlightuserdata(IntPtr L, IntPtr index)
{
cxx_lua_pushlightuserdata(L, index);
}
#else
public static extern void lua_pushlightuserdata(IntPtr L, IntPtr index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_i64lib(IntPtr L);
public static int luaopen_i64lib(IntPtr L)
{
return cxx_luaopen_i64lib(L);
}
#else
public static extern int luaopen_i64lib(IntPtr L); //[-0, +0, m]
#endif
#if !UNITY_WEBGL
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_socket_core(IntPtr L);
public static int luaopen_socket_core(IntPtr L)
{
return cxx_luaopen_socket_core(L);
}
#else
public static extern int luaopen_socket_core(IntPtr L); //[,,m]
#endif
#endif
//sproto
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int luaopen_cjson(System.IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_lpeg(IntPtr L);
public static int luaopen_lpeg(IntPtr L)
{
return cxx_luaopen_lpeg(L);
}
#else
public static extern int luaopen_lpeg(System.IntPtr L);
#endif
// [DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
// public static extern int luaopen_pb(System.IntPtr L);
// [DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
// public static extern int luaopen_ffi(System.IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_sproto_core(IntPtr L);
public static int luaopen_sproto_core(IntPtr L)
{
return cxx_luaopen_sproto_core(L);
}
#else
public static extern int luaopen_sproto_core(System.IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_crypt(IntPtr L);
public static int luaopen_crypt(IntPtr L)
{
return cxx_luaopen_crypt(L);
}
#else
public static extern int luaopen_crypt(System.IntPtr L);
#endif
#if !UNITY_WEBGL
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_lsocket(IntPtr L);
public static int luaopen_lsocket(IntPtr L)
{
return cxx_luaopen_lsocket(L);
}
#else
public static extern int luaopen_lsocket(System.IntPtr L);
#endif
#endif//!UNITY_WEBGL
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushint64(IntPtr L, long n);
public static void lua_pushint64(IntPtr L, long n)
{
cxx_lua_pushint64(L, n);
}
#else
public static extern void lua_pushint64(IntPtr L, long n); //[,,m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushuint64(IntPtr L, ulong n);
public static void lua_pushuint64(IntPtr L, ulong n)
{
cxx_lua_pushuint64(L, n);
}
#else
public static extern void lua_pushuint64(IntPtr L, ulong n); //[,,m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_isint64(IntPtr L, int index);
public static bool lua_isint64(IntPtr L, int index)
{
return cxx_lua_isint64(L, index);
}
#else
public static extern bool lua_isint64(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern bool cxx_lua_isuint64(IntPtr L, int index);
public static bool lua_isuint64(IntPtr L, int index)
{
return cxx_lua_isuint64(L, index);
}
#else
public static extern bool lua_isuint64(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern long cxx_lua_toint64(IntPtr L, int index);
public static long lua_toint64(IntPtr L, int index)
{
return cxx_lua_toint64(L, index);
}
#else
public static extern long lua_toint64(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern ulong cxx_lua_touint64(IntPtr L, int index);
public static ulong lua_touint64(IntPtr L, int index)
{
return cxx_lua_touint64(L, index);
}
#else
public static extern ulong lua_touint64(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern IntPtr cxx_lua_touserdata(IntPtr L, int index);
public static IntPtr lua_touserdata(IntPtr L, int index)
{
return cxx_lua_touserdata(L, index);
}
#else
public static extern IntPtr lua_touserdata(IntPtr L, int index); //[-0, +0, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_luaL_where(IntPtr L, int level); //[-0, +1, m]
public static void luaL_where(IntPtr L, int level)
{
cxx_luaL_where(L, level);
}
#else
public static extern void luaL_where(IntPtr L, int level); //[-0, +1, m]
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_getglobal(IntPtr L, string name); //[-1, +0, m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_setglobal(IntPtr L, string name); //[-1, +0, m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_getloaders(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_rawgeti(IntPtr L, int tableIndex, long index);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_rawseti(IntPtr L, int tableIndex, long index); //[-1, +0, m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int pcall_prepare(IntPtr L, int error_func_ref, int func_ref);
public static void lua_pushstdcallcfunction(IntPtr L, lua_CSFunction function, int n = 0) //[-0, +1, m]
{
#if XLUA_GENERAL || (UNITY_WSA && !UNITY_EDITOR)
GCHandle.Alloc(function);
#endif
IntPtr fn = Marshal.GetFunctionPointerForDelegate(function);
xlua_push_csharp_function(L, fn, n);
}
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_upvalueindex(int n);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_tointeger(IntPtr L, int index);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern uint xlua_touint(IntPtr L, int index);
public static string lua_tostring(IntPtr L, int index)
{
IntPtr strlen;
IntPtr str = lua_tolstring(L, index, out strlen);
if (str != IntPtr.Zero)
{
#if XLUA_GENERAL || (UNITY_WSA && !UNITY_EDITOR)
int len = strlen.ToInt32();
byte[] buffer = new byte[len];
Marshal.Copy(str, buffer, 0, len);
return Encoding.UTF8.GetString(buffer);
#else
string ret = Marshal.PtrToStringAnsi(str, strlen.ToInt32());
if (ret == null)
{
int len = strlen.ToInt32();
byte[] buffer = new byte[len];
Marshal.Copy(str, buffer, 0, len);
return Encoding.UTF8.GetString(buffer);
}
return ret;
#endif
}
else
{
return null;
}
}
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_pushinteger(IntPtr L, int value);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_pushuint(IntPtr L, uint value);
public static byte[] lua_tobytes(IntPtr L, int index) //[-0, +0, m]
{
if (lua_type(L, index) == 4)
{
IntPtr strlen;
IntPtr str = lua_tolstring(L, index, out strlen);
if (str != IntPtr.Zero)
{
int buff_len = strlen.ToInt32();
byte[] buffer = new byte[buff_len];
Marshal.Copy(str, buffer, 0, buff_len);
return buffer;
}
}
return null;
}
#if NATIVE_LUA_PUSHSTRING
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_UDIPHONE && !UNITY_EDITOR
public static extern void cxx_lua_pushstring(IntPtr L, string str);
public static long lua_pushstring(IntPtr L, string str){cxx_lua_pushstring(L, str);}
#else
public static extern void lua_pushstring(IntPtr L, string str);
#endif
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_pushlstring(IntPtr L, byte[] str, int size);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_pgettable(IntPtr L, int idx);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_psettable(IntPtr L, int idx);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xluaL_loadbuffer(IntPtr L, byte[] buff, int size, string name);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_tocsobj_safe(IntPtr L, int obj); //[-0, +0, m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_tocsobj_fast(IntPtr L, int obj);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr xlua_tag();
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_tryget_cachedud(IntPtr L, int key, int cache_ref);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void
xlua_pushcsobj(IntPtr L, int key, int meta_ref, bool need_cache, int cache_ref); //[-0, +1, m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[,,m]
public static extern int gen_obj_indexer(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[,,m]
public static extern int gen_obj_newindexer(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[,,m]
public static extern int gen_cls_indexer(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[,,m]
public static extern int gen_cls_newindexer(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[,,m]
public static extern int get_error_func_ref(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[,,m]
public static extern int load_error_func(IntPtr L, int Ref);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_push_csharp_function(IntPtr L, IntPtr fn, int n); //[-0,+1,m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_csharp_str_error(IntPtr L, string message); //[-0,+1,m]
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)] //[-0,+0,m]
public static extern int xlua_csharp_error(IntPtr L);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_int8_t(IntPtr buff, int offset, byte field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_int8_t(IntPtr buff, int offset, out byte field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_int16_t(IntPtr buff, int offset, short field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_int16_t(IntPtr buff, int offset, out short field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_int32_t(IntPtr buff, int offset, int field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_int32_t(IntPtr buff, int offset, out int field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_int64_t(IntPtr buff, int offset, long field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_int64_t(IntPtr buff, int offset, out long field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_float(IntPtr buff, int offset, float field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_float(IntPtr buff, int offset, out float field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_double(IntPtr buff, int offset, double field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_double(IntPtr buff, int offset, out double field);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr xlua_pushstruct(IntPtr L, uint size, int meta_ref);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_pushcstable(IntPtr L, uint field_count, int meta_ref);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_gettypeid(IntPtr L, int idx);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_get_registry_index();
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_pgettable_bypath(IntPtr L, int idx, string path);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern int xlua_psettable_bypath(IntPtr L, int idx, string path);
//对于Unity,仅浮点组成的struct较多,这几个api用于优化这类struct
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_float2(IntPtr buff, int offset, float f1, float f2);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_float2(IntPtr buff, int offset, out float f1, out float f2);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_float3(IntPtr buff, int offset, float f1, float f2, float f3);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_float3(IntPtr buff, int offset, out float f1, out float f2, out float f3);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_float4(IntPtr buff, int offset, float f1, float f2, float f3, float f4);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_float4(IntPtr buff, int offset, out float f1, out float f2, out float f3,
out float f4);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_float5(IntPtr buff, int offset, float f1, float f2, float f3, float f4,
float f5);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_float5(IntPtr buff, int offset, out float f1, out float f2, out float f3,
out float f4, out float f5);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_float6(IntPtr buff, int offset, float f1, float f2, float f3, float f4,
float f5, float f6);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_float6(IntPtr buff, int offset, out float f1, out float f2, out float f3,
out float f4, out float f5, out float f6);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_pack_decimal(IntPtr buff, int offset, ref decimal dec);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_unpack_decimal(IntPtr buff, int offset, out byte scale, out byte sign,
out int hi32, out ulong lo64);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern bool xlua_is_eq_str(IntPtr L, int index, string str, int str_len);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr xlua_gl(IntPtr L);
#if GEN_CODE_MINIMIZE
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_set_csharp_wrapper_caller(IntPtr wrapper);
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
public static extern void xlua_push_csharp_wrapper(IntPtr L, int wrapperID);
#endif
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20552ea90837cd84c822ff8c26b7b964
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using System.Runtime.InteropServices;
namespace XLuaBase
{
public partial class Lua
{
/*
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_IPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_rapidjson(System.IntPtr L);
public static int luaopen_rapidjson(System.IntPtr L)
{
return cxx_luaopen_rapidjson(L);
}
#else
public static extern int luaopen_rapidjson(System.IntPtr L);
#endif
[DllImport(LUADLL, CallingConvention = CallingConvention.Cdecl)]
#if UNITY_IPHONE && !UNITY_EDITOR
public static extern int cxx_luaopen_md5(System.IntPtr L);
public static int luaopen_md5(System.IntPtr L)
{
return cxx_luaopen_md5(L);
}
#else
public static extern int luaopen_md5(System.IntPtr L);
#endif//*/
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cb5dc246d291cf4da1db75bebf5db47
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+297
View File
@@ -0,0 +1,297 @@
using UnityEngine;
using System;
using System.Runtime.InteropServices;
//using GYEngine;
public class WindowsHelper
{
#if UNITY_STANDALONE_WIN
//设置当前窗口的显示状态
[DllImport("user32.dll")]
public static extern bool ShowWindow(System.IntPtr hwnd, int nCmdShow);
//获取当前激活窗口
[DllImport("user32.dll", EntryPoint = "GetForegroundWindow")]
public static extern System.IntPtr GetForegroundWindow();
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
//程序当前的激活窗口
[DllImport("user32.dll", EntryPoint = "GetActiveWindow")]
public static extern IntPtr GetActiveWindow();
//设置窗口边框
[DllImport("user32.dll")]
public static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong);
//设置窗口位置,尺寸
[DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
//更改标题栏
[DllImport("user32.dll")]
public static extern int SetWindowText(IntPtr hWnd, string text);
//使用查找任务栏
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string strClassName, int nptWindowName);
[DllImport("User32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//获取窗口位置以及大小
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetClientRect(IntPtr hWnd, ref RECT lpRect);
[DllImport("user32.dll", SetLastError = true)]
public static extern int GetSystemMetrics(int nIndex);
private static int SM_CXSCREEN = 0; //主屏幕分辨率宽度
private static int SM_CYSCREEN = 1; //主屏幕分辨率高度
private static int SM_CYCAPTION = 4; //标题栏高度
private static int SM_CXFULLSCREEN = 16; //最大化窗口宽度(减去任务栏)
private static int SM_CYFULLSCREEN = 17; //最大化窗口高度(减去任务栏)
public static Rect GetWorkingArea()
{
Rect rect = new Rect();
// 屏幕WorkingArea
rect.width = GetSystemMetrics(SM_CXFULLSCREEN);
rect.height = GetSystemMetrics(SM_CYFULLSCREEN);
return rect;
}
public static Rect GetScreen()
{
Rect rect = new Rect();
// 屏幕分辨率
rect.width = GetSystemMetrics(SM_CXSCREEN);
rect.height = GetSystemMetrics(SM_CYSCREEN);
// 标题栏高度
//int title = GetSystemMetrics(SM_CYCAPTION);
// 不最大化、不全屏的最大窗口高度
//int maxHeight = y1 - title;
return rect;
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left; //最左坐标
public int Top; //最上坐标
public int Right; //最右坐标
public int Bottom; //最下坐标
}
//边框参数
private const uint SWP_SHOWWINDOW = 0x0040;
private const int GWL_STYLE = -16;
private const int WS_BORDER = 1;
//隐藏标题栏图标
private const int WS_POPUP = 0x800000;
private const int WS_SYSMENU = 0x80000;
//最大最小化
private const int SW_SHOWMINIMIZED = 2;//(最小化窗口)
private const int SW_SHOWMAXIMIZED = 3;//最大化窗口
//去除标题栏保留边框
private const int WS_CAPTION = 0x00C00000;
private const int WS_THICKFRAME = 0x00040000;
private static IntPtr windowHandler = IntPtr.Zero;
public static void InitWindowHandler()
{
WindowsHelper.windowHandler = GetActiveWindow();
}
public static void SaveWindowPosAndSize()
{
if (windowHandler == IntPtr.Zero) return;
RECT clientrc = new RECT();
GetClientRect(windowHandler, ref clientrc); //获得窗口客户区大小
RECT windowrc = new RECT();
GetWindowRect(windowHandler, ref windowrc); //获得窗口大小
// Debug.Log($"[{clientrc.Top},{clientrc.Bottom},{clientrc.Left},{clientrc.Right}] [{windowrc.Top},{windowrc.Bottom},{windowrc.Left},{windowrc.Right}]");
int borderwidth = (windowrc.Right - windowrc.Left) - (clientrc.Right - clientrc.Left);
int borderheight = (windowrc.Bottom - windowrc.Top) - (clientrc.Bottom - clientrc.Top);
int width = Mathf.Abs(windowrc.Right - windowrc.Left);
int height = Mathf.Abs(windowrc.Top - windowrc.Bottom);
int x = windowrc.Left;
int y = windowrc.Top;
x += borderwidth / 2;
y += borderheight / 2;
width -= borderwidth;
height -= borderheight;
if (width < 375 || height < 812)
{
return;
}
//SettingManager.Instance.SetString("UNITY_STANDALONE_WIN_POS_AND_SIZE", string.Format($"{x}*{y}*{width}*{height}"));
}
//最小化窗口
public static void SetMinWindows()
{
if (windowHandler == IntPtr.Zero) return;
ShowWindow(windowHandler, SW_SHOWMINIMIZED);
//具体窗口参数看这 https://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
}
/// <summary>
/// 最大化窗口
/// </summary>
public static void SetMaxWindows()
{
if (windowHandler == IntPtr.Zero) return;
int currMaxScreenHeight = Screen.currentResolution.height - GetTaskBarHeight();
SetWindowPos(windowHandler, 0, 0, 0, Screen.currentResolution.width, currMaxScreenHeight, SWP_SHOWWINDOW);
//ShowWindow(windowHandler, SW_SHOWMAXIMIZED);
}
public static bool SetCenterNoFrameWindow(int width, int height)
{
int startX = (Display.main.systemWidth - width) / 2;
int startY = (Display.main.systemHeight - height) / 2;
return SetNoFrameWindow(startX, startY, width, height);
}
public static bool SetUpperLeftNoFrameWindow(int width, int height)
{
int startX = 0;
int startY = 0;
return SetNoFrameWindow(startX, startY, width, height);
}
/// <summary>
/// 设置无边框,窗口位置及分辨率
/// </summary>
/// <param name="rect">尺寸数据</param>
public static bool SetNoFrameWindow(int x, int y, int width, int height)
{
if (windowHandler == IntPtr.Zero) return false;
SetForegroundWindow(windowHandler);
//去除上边栏(不可拖拽缩放)
SetWindowLong(windowHandler, GWL_STYLE, WS_POPUP);
//设置窗口位置及分辨率
bool result = SetWindowPos(windowHandler, 0, x, y, width, height, SWP_SHOWWINDOW);
return result;
}
public static bool SetCenterNoResizeWindow(int width, int height)
{
int startX = (Display.main.systemWidth - width) / 2;
int startY = (Display.main.systemHeight - height) / 2;
return SetNoResizeWindow(startX, startY, width, height);
}
public static bool SetUpperLeftNoResizeWindow(int width, int height)
{
int startX = 0;
int startY = 0;
return SetNoResizeWindow(startX, startY, width, height);
}
/// <summary>
/// 设置不可调整大小,窗口位置及分辨率
/// </summary>
/// <param name="rect">尺寸数据</param>
public static bool SetNoResizeWindow(int x, int y, int width, int height)
{
if (windowHandler == IntPtr.Zero) return false;
SetForegroundWindow(windowHandler);
//设置不可缩放
SetWindowLong(windowHandler, GWL_STYLE, GetWindowLong(windowHandler, GWL_STYLE) & ~WS_THICKFRAME);
RECT clientrc = new RECT();
GetClientRect(windowHandler, ref clientrc); //获得窗口客户区大小
RECT windowrc = new RECT();
GetWindowRect(windowHandler, ref windowrc); //获得窗口大小
int borderwidth = (windowrc.Right - windowrc.Left) - (clientrc.Right - clientrc.Left);
int borderheight = (windowrc.Bottom - windowrc.Top) - (clientrc.Bottom - clientrc.Top);
x -= borderwidth / 2;
y -= borderheight / 2;
width += borderwidth;
height += borderheight;
//设置窗口位置及分辨率
bool result = SetWindowPos(windowHandler, 0, x, y, width, height, SWP_SHOWWINDOW);
return result;
}
/// <summary>
/// 改变标题栏标题
/// </summary>
public static void ChangeTitleText()
{
if (windowHandler == IntPtr.Zero) return;
SetWindowText(windowHandler, string.Empty);
}
/// <summary>
/// 获取当前窗口尺寸
/// </summary>
/// <returns></returns>
public static Rect GetWindowInfo()
{
if (windowHandler == IntPtr.Zero) return new Rect();
RECT rect = new RECT();
Rect targetRect = new Rect();
GetWindowRect(windowHandler, ref rect);
targetRect.width = Mathf.Abs(rect.Right - rect.Left);
targetRect.height = Mathf.Abs(rect.Top - rect.Bottom);
targetRect.x = rect.Left;
targetRect.y = rect.Top;
return targetRect;
}
/// <summary>
/// 获取任务栏高度
/// </summary>
/// <returns>任务栏高度</returns>
private static int GetTaskBarHeight()
{
int taskbarHeight = 10;
IntPtr hWnd = FindWindow("Shell_TrayWnd", 0);
RECT rect = new RECT();
GetWindowRect(hWnd, ref rect);
taskbarHeight = rect.Bottom - rect.Top;
return taskbarHeight;
}
#endif
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 910ab9d208d7d55469712e5754f0303a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: