├── Doc ├── DragOK.png ├── DefineList.png ├── JsonSerialize.png ├── ObjSerialize.png ├── AssistantScript.png ├── SetLuaBehaviour.png └── DragToLuaBehaviour.png ├── LuaBehaviour ├── Assets │ ├── XLua │ │ ├── Src │ │ │ ├── LuaDLL.cs │ │ │ ├── LuaEnv.cs │ │ │ ├── Editor.meta │ │ │ ├── Editor │ │ │ │ ├── Template.meta │ │ │ │ ├── Template │ │ │ │ │ ├── TemplateCommon.lua.txt.meta │ │ │ │ │ ├── LuaEnumWrap.tpl.txt.meta │ │ │ │ │ ├── LuaRegister.tpl.txt.meta │ │ │ │ │ ├── PackUnpack.tpl.txt.meta │ │ │ │ │ ├── LuaClassWrap.tpl.txt.meta │ │ │ │ │ ├── LuaClassWrapGCM.tpl.txt.meta │ │ │ │ │ ├── LuaDelegateWrap.tpl.txt.meta │ │ │ │ │ ├── LuaEnumWrapGCM.tpl.txt.meta │ │ │ │ │ ├── LuaRegisterGCM.tpl.txt.meta │ │ │ │ │ ├── LuaWrapPusher.tpl.txt.meta │ │ │ │ │ ├── LuaDelegateBridge.tpl.txt.meta │ │ │ │ │ ├── LuaInterfaceBridge.tpl.txt.meta │ │ │ │ │ ├── LuaEnumWrapGCM.tpl.txt │ │ │ │ │ ├── LuaDelegateBridge.tpl.txt │ │ │ │ │ ├── LuaEnumWrap.tpl.txt │ │ │ │ │ ├── PackUnpack.tpl.txt │ │ │ │ │ ├── LuaRegister.tpl.txt │ │ │ │ │ ├── LuaRegisterGCM.tpl.txt │ │ │ │ │ └── LuaDelegateWrap.tpl.txt │ │ │ │ ├── Generator.cs.meta │ │ │ │ ├── LinkXmlGen │ │ │ │ │ ├── LinkXmlGen.tpl.txt.meta │ │ │ │ │ ├── LinkXmlGen.tpl.txt │ │ │ │ │ ├── LinkXmlGen.cs.meta │ │ │ │ │ └── LinkXmlGen.cs │ │ │ │ ├── LinkXmlGen.meta │ │ │ │ ├── Hotfix.cs.meta │ │ │ │ ├── TemplateRef.cs │ │ │ │ └── TemplateRef.cs.meta │ │ │ ├── TemplateEngine.meta │ │ │ ├── LuaDLL.cs.meta │ │ │ ├── LuaEnv.cs.meta │ │ │ ├── Utils.cs.meta │ │ │ ├── LuaBase.cs.meta │ │ │ ├── LuaFunction.cs.meta │ │ │ ├── LuaTable.cs.meta │ │ │ ├── LuaException.cs.meta │ │ │ ├── MethodWarpsCache.cs.meta │ │ │ ├── ObjectCasters.cs.meta │ │ │ ├── ObjectTranslator.cs.meta │ │ │ ├── ObjectTranslatorPool.cs.meta │ │ │ ├── TemplateEngine │ │ │ │ └── TemplateEngine.cs.meta │ │ │ ├── CodeEmit.cs.meta │ │ │ ├── CopyByValue.cs.meta │ │ │ ├── GenAttributes.cs.meta │ │ │ ├── ObjectPool.cs.meta │ │ │ ├── RawObject.cs.meta │ │ │ ├── DelegateBridge.cs.meta │ │ │ ├── InternalGlobals.cs.meta │ │ │ ├── SignatureLoader.cs.meta │ │ │ ├── StaticLuaCallbacks.cs.meta │ │ │ ├── TypeExtensions.cs.meta │ │ │ ├── GenericDelegateBridge.cs.meta │ │ │ ├── LuaException.cs │ │ │ ├── SignatureLoader.cs │ │ │ ├── RawObject.cs │ │ │ ├── InternalGlobals.cs │ │ │ ├── ObjectTranslatorPool.cs │ │ │ ├── LuaBase.cs │ │ │ ├── TypeExtensions.cs │ │ │ ├── GenAttributes.cs │ │ │ ├── ObjectPool.cs │ │ │ └── CopyByValue.cs │ │ ├── Src.meta │ │ ├── CHANGELOG.txt.meta │ │ ├── Resources │ │ │ ├── perf │ │ │ │ ├── memory.lua.txt.meta │ │ │ │ ├── profiler.lua.txt.meta │ │ │ │ ├── memory.lua.txt │ │ │ │ └── profiler.lua.txt │ │ │ ├── tdr │ │ │ │ ├── tdr.lua.txt.meta │ │ │ │ └── tdr.lua.txt │ │ │ ├── xlua │ │ │ │ ├── util.lua.txt.meta │ │ │ │ └── util.lua.txt │ │ │ ├── perf.meta │ │ │ ├── tdr.meta │ │ │ └── xlua.meta │ │ ├── Editor.meta │ │ ├── Resources.meta │ │ └── Editor │ │ │ └── ExampleConfig.cs.meta │ ├── Plugins │ │ ├── iOS │ │ │ ├── libxlua.a │ │ │ ├── libxlua.a.meta │ │ │ ├── HotfixFlags.cpp.meta │ │ │ └── HotfixFlags.cpp │ │ ├── x86 │ │ │ ├── xlua.dll │ │ │ ├── libxlua.so │ │ │ ├── xlua.dll.meta │ │ │ └── libxlua.so.meta │ │ ├── x86_64 │ │ │ ├── xlua.dll │ │ │ ├── libxlua.so │ │ │ ├── libxlua.so.meta │ │ │ └── xlua.dll.meta │ │ ├── WSA │ │ │ ├── ARM │ │ │ │ ├── xlua.dll │ │ │ │ └── xlua.dll.meta │ │ │ ├── x64 │ │ │ │ ├── xlua.dll │ │ │ │ └── xlua.dll.meta │ │ │ ├── x86 │ │ │ │ ├── xlua.dll │ │ │ │ └── xlua.dll.meta │ │ │ ├── ARM.meta │ │ │ ├── x64.meta │ │ │ └── x86.meta │ │ ├── iOS.meta │ │ ├── x86.meta │ │ ├── Android.meta │ │ ├── Android │ │ │ ├── libs │ │ │ │ ├── x86 │ │ │ │ │ ├── libxlua.so │ │ │ │ │ └── libxlua.so.meta │ │ │ │ ├── arm64-v8a │ │ │ │ │ ├── libxlua.so │ │ │ │ │ └── libxlua.so.meta │ │ │ │ ├── armeabi-v7a │ │ │ │ │ ├── libxlua.so │ │ │ │ │ └── libxlua.so.meta │ │ │ │ ├── x86.meta │ │ │ │ ├── armeabi-v7a.meta │ │ │ │ └── arm64-v8a.meta │ │ │ └── libs.meta │ │ ├── xlua.bundle │ │ │ ├── Contents │ │ │ │ ├── MacOS │ │ │ │ │ ├── xlua │ │ │ │ │ └── xlua.meta │ │ │ │ ├── Info.plist.meta │ │ │ │ ├── MacOS.meta │ │ │ │ └── Info.plist │ │ │ └── Contents.meta │ │ ├── WSA.meta │ │ ├── WebGL.meta │ │ ├── x86_64.meta │ │ ├── WebGL │ │ │ ├── xlua_webgl.cpp.meta │ │ │ └── xlua_webgl.cpp │ │ └── xlua.bundle.meta │ ├── Lua │ │ ├── Core │ │ │ ├── LuaBehaviour.lua.meta │ │ │ ├── middleClass.lua.meta │ │ │ ├── LuaBehaviour.lua │ │ │ └── middleClass.lua │ │ ├── Core.meta │ │ ├── Game.meta │ │ └── Game │ │ │ ├── LuaBehaviourTest.lua.meta │ │ │ ├── LuaBehaviourTest2.lua.meta │ │ │ ├── LuaBehaviourTest2.lua │ │ │ └── LuaBehaviourTest.lua │ └── Script │ │ ├── Editor.meta │ │ ├── Lua.meta │ │ ├── Lua │ │ ├── LuaBehaviour.meta │ │ ├── LuaBehaviour │ │ │ ├── Assistant.meta │ │ │ ├── Editor.meta │ │ │ ├── Assistant │ │ │ │ ├── LuaAssistantBase.cs │ │ │ │ ├── LuaAssistantBase.cs.meta │ │ │ │ ├── LuaLateUpdateAssistant.cs.meta │ │ │ │ ├── LuaUpdateAssistant.cs.meta │ │ │ │ ├── LuaFixedUpdateAssistant.cs.meta │ │ │ │ ├── LuaOnPointerClickAssistant.cs.meta │ │ │ │ ├── LuaUpdateAssistant.cs │ │ │ │ ├── LuaLateUpdateAssistant.cs │ │ │ │ ├── LuaFixedUpdateAssistant.cs │ │ │ │ └── LuaOnPointerClickAssistant.cs │ │ │ ├── LuaBehaviour.cs.meta │ │ │ ├── Editor │ │ │ │ └── LuaBehaviorEditor.cs.meta │ │ │ └── LuaBehaviour.cs │ │ ├── LuaManager.cs.meta │ │ └── LuaManager.cs │ │ ├── AssetBundleManagerForLua.cs.meta │ │ ├── Editor │ │ ├── AssetBundleManagerForLua.cs.meta │ │ └── AssetBundleManagerForLua.cs │ │ └── AssetBundleManagerForLua.cs └── ProjectSettings │ ├── ProjectVersion.txt │ ├── ClusterInputManager.asset │ ├── PresetManager.asset │ ├── XRSettings.asset │ ├── TimeManager.asset │ ├── EditorBuildSettings.asset │ ├── VFXManager.asset │ ├── AudioManager.asset │ ├── TagManager.asset │ ├── UnityConnectSettings.asset │ ├── DynamicsManager.asset │ ├── EditorSettings.asset │ ├── NavMeshAreas.asset │ ├── Physics2DSettings.asset │ ├── GraphicsSettings.asset │ ├── QualitySettings.asset │ └── InputManager.asset ├── LICENSE └── README.md /Doc/DragOK.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/DragOK.png -------------------------------------------------------------------------------- /Doc/DefineList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/DefineList.png -------------------------------------------------------------------------------- /Doc/JsonSerialize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/JsonSerialize.png -------------------------------------------------------------------------------- /Doc/ObjSerialize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/ObjSerialize.png -------------------------------------------------------------------------------- /Doc/AssistantScript.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/AssistantScript.png -------------------------------------------------------------------------------- /Doc/SetLuaBehaviour.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/SetLuaBehaviour.png -------------------------------------------------------------------------------- /Doc/DragToLuaBehaviour.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/Doc/DragToLuaBehaviour.png -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaDLL.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/XLua/Src/LuaDLL.cs -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaEnv.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/XLua/Src/LuaEnv.cs -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2019.4.7f1 2 | m_EditorVersionWithRevision: 2019.4.7f1 (c96ffa5b8cd5) 3 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/iOS/libxlua.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/iOS/libxlua.a -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86/xlua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/x86/xlua.dll -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86/libxlua.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/x86/libxlua.so -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86_64/xlua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/x86_64/xlua.dll -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/ARM/xlua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/WSA/ARM/xlua.dll -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/x64/xlua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/WSA/x64/xlua.dll -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/x86/xlua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/WSA/x86/xlua.dll -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86_64/libxlua.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/x86_64/libxlua.so -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/iOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a4ab2e5e00054b03a7bf96d03e5b4e1 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b0b0c4ffe67d2f4292c5211de91e55f 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac2f50d02ed9ec24b8fcc1921bfb244c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0004c0a5ad641d4468ebb65779ee48b2 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e53aa922da0a00469e5760902833e71 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/x86/libxlua.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/Android/libs/x86/libxlua.so -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c7307955fb71fc4090eb2a906a78a0a 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/TemplateEngine.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f996f6400fcbdd4db02eeab46d9dd1e 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/arm64-v8a/libxlua.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/Android/libs/arm64-v8a/libxlua.so -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle/Contents/MacOS/xlua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/xlua.bundle/Contents/MacOS/xlua -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/TemplateCommon.lua.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb41d53afe75a9443b182e284298feeb 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/armeabi-v7a/libxlua.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blueberryzzz/LuaBehaviour/HEAD/LuaBehaviour/Assets/Plugins/Android/libs/armeabi-v7a/libxlua.so -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: [] 7 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cd62bafd75e7604daf2b561b80d136d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/x86.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 079ea0ed741ff194a80cce029630b5ac 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Core/LuaBehaviour.lua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94f14c4b43d507d41a54cb2146d9eae9 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Core/middleClass.lua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c39777a73597d42498cfb1f447adc794 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf636958486abbe408c4464706ffd55a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Game.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5783123eb0e0bba40b88dab99688a053 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Game/LuaBehaviourTest.lua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dd5bee3ee575fa4f9b7bdbd081fa52c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Game/LuaBehaviourTest2.lua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62b69138a0407994e93d6af631bb26bf 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/armeabi-v7a.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8d0cd0f5702f0144af2498bce3ee3e9 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e79cc0fa65cf0ec428f41a51f3c958c4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 349d4f2540c214d4b91d5bdfdbe4730c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb022b3ae034d4a4cac5bb36f1397776 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/CHANGELOG.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be3fe4ee249c5274693e7b6f8053e861 3 | timeCreated: 1470364015 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaDLL.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d60cef534e986e849a829838fbeb74b5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaEnv.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a72df23459239b4d901cdacabd469d1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9c14a5b76adb7d41926526af904beda 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36f6e0ab03586ce4493d45dbc2a0ff5c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaFunction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c45cd490d853cb409d042c641784718 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaTable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a4d72d338110544b8538c1a5fd33c11 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/arm64-v8a.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 084116138e3349d48bdf50214aebefc5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2e49cb2a4c5d5c45b049b7ac645c24a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5bcbbddf074fcc40abd689de45ad36e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Generator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e866a5f1000c29940843aece98d0c706 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b209468b680ef7d4195de21a39bfcae0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/MethodWarpsCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5f029e1a01fd984f92bf8d5c2b51923 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/ObjectCasters.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04cef766c4f15b341bcb4659831e6748 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/ObjectTranslator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41d53bdd4bbda0f41a6bd1eb35af4f99 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/perf/memory.lua.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a5cba5df35473342b614686c15f8a4c 3 | timeCreated: 1461833890 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/tdr/tdr.lua.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e05f05f4a331bc45a04832062650a9e 3 | timeCreated: 1458812943 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/xlua/util.lua.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4397ec772c2d41e46a9766cf46b8bec6 3 | timeCreated: 1463477791 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/ObjectTranslatorPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 069f15dde2065491db1e68ca5fb1279d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle/Contents/Info.plist.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac30af4fb2add4d41a9f50fe4f8292a3 3 | timeCreated: 1457422749 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle/Contents/MacOS/xlua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f3b1cda03ac84924b1ee0595fc019f5 3 | timeCreated: 1457422749 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f890416e958ceb54694b165fb109582a 3 | folderAsset: yes 4 | timeCreated: 1534492498 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/perf/profiler.lua.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4841b87b13a684649aab9de0e72132b7 3 | timeCreated: 1461553714 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8c5688e381fddc4eb22e6f96f69541c 3 | folderAsset: yes 4 | timeCreated: 1489995541 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/ARM.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6375603a0a1e2647b0c426b27646eb7 3 | folderAsset: yes 4 | timeCreated: 1490146877 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/x64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d5a7116d7e9a33409205303635b8635 3 | folderAsset: yes 4 | timeCreated: 1490146877 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/x86.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e0f35de38a8ed24fa8b20d444c9ee5e 3 | folderAsset: yes 4 | timeCreated: 1490146877 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WebGL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7f3a5adb034d684cb13cb257c29a1c3 3 | folderAsset: yes 4 | timeCreated: 1504062948 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86_64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dba1dfb80e5b7d40bd214fc4ed2ed6b 3 | folderAsset: yes 4 | timeCreated: 1451020766 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa4f7e825d6ae9742bd6f88af5865c13 3 | folderAsset: yes 4 | timeCreated: 1458812833 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaEnumWrap.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae16c73aad9a21a44aef65decb7e4928 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaRegister.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e416b82ec9fe340458f97cf1e3468ef7 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/PackUnpack.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9ef7e8f2a3b37744aad49b99370c16b 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/TemplateEngine/TemplateEngine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d416b4da0b828854c8e997f0c1ae4072 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/perf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 866368b69ae1a2040943783fa31d2f74 3 | folderAsset: yes 4 | timeCreated: 1461553627 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/tdr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f08dfe3f4634334ea0810ea31d8b593 3 | folderAsset: yes 4 | timeCreated: 1454039150 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/xlua.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0924e56a40ddb34e9b004c2056288fa 3 | folderAsset: yes 4 | timeCreated: 1463477791 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/LinkXmlGen/LinkXmlGen.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 384feb229d259f549bbbac9e910b782b 3 | timeCreated: 1481621844 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaClassWrap.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8503038eabbabe44dac0f5f749d4411a 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaClassWrapGCM.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bd79d95fd859724283926ad8fa4df30 3 | timeCreated: 1501232428 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaDelegateWrap.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33b33e1cd617f794b8c801a32f3b2539 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaEnumWrapGCM.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea84a5ee7abf8e347a810eb7848add46 3 | timeCreated: 1501232428 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaRegisterGCM.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46c7366d55afbf1459674448d92c44c8 3 | timeCreated: 1501232428 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaWrapPusher.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1a916469d261d447972d287b6c5b7a0 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/LinkXmlGen.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f94464b9267f9b4cbf2f98681e22880 3 | folderAsset: yes 4 | timeCreated: 1479105499 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaDelegateBridge.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d992756e2469044484be75f78e4e556 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaInterfaceBridge.tpl.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7165d08e91378494dadeb10e5338accb 3 | timeCreated: 1481620508 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle/Contents.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e4b7549f5e4a4e71806e3ec8e428b15 3 | folderAsset: yes 4 | timeCreated: 1457422691 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle/Contents/MacOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9d8e68fa0fd1465294f1255f6ed8563 3 | folderAsset: yes 4 | timeCreated: 1457422691 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaAssistantBase.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class LuaAssistantBase : MonoBehaviour 4 | { 5 | protected LuaBehaviour luaBehaviour; 6 | 7 | protected virtual void Awake() 8 | { 9 | luaBehaviour = GetComponent(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbdec567908ab6b4689b75d708da4d43 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/AssetBundleManagerForLua.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32b1962c1d5e8ea4697ed61d19b16ae2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/LuaBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0c9d1e131efe664d9773f71fe17ded9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Editor/AssetBundleManagerForLua.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 199220d2d8b4e274cbf44f07bd1a1138 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/CodeEmit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93ce5fd372271b04199841c920eb0268 3 | timeCreated: 1470883945 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/CopyByValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aba23a1792dbc49438a2357566447979 3 | timeCreated: 1467189953 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Hotfix.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9f175d9e85601f4da903e391b8b7c77 3 | timeCreated: 1482299911 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/GenAttributes.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4455254bac5b6644893ae8183b9eb87c 3 | timeCreated: 1452509750 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/ObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acf2cec75841d9646900284e2ba1ca4f 3 | timeCreated: 1480296949 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/RawObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3f2b65020c56dc4985af0768b06c63c 3 | timeCreated: 1498116130 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/LuaBehaviourTestScene.unity 10 | guid: 455366ca34297064b9c4af3a47e840f1 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaAssistantBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b3dca95e01b0a94f96fda78dbbd5a12 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Editor/LuaBehaviorEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 127d6f59b7a2d9948b6fd9e136c0d3a8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/DelegateBridge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8c4165852e3e92468656dc6efb30a28 3 | timeCreated: 1452574309 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/InternalGlobals.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bacb817c6d0b48644892c8dc3cb6cfc1 3 | timeCreated: 1496994941 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/SignatureLoader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5dfa9c69dddc18849bd3c1dfc4ac42de 3 | timeCreated: 1489222429 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/StaticLuaCallbacks.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 300ed412007935e45a1546a984b89059 3 | timeCreated: 1469175028 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/TypeExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0099a231859d6da43932d0c36714e17f 3 | timeCreated: 1489998065 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaLateUpdateAssistant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51c2c371f85118c41beacdd9f60abe2c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaUpdateAssistant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b114ec207a76b344ae25974c7864413 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/GenericDelegateBridge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bd0a3260371756449c4f642cc7ead00 3 | timeCreated: 1537950363 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaFixedUpdateAssistant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fd531dbd85fc124c93c087e4ba06eac 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaOnPointerClickAssistant.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fddc6753369db6b4a8d6ae380aa79cab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Editor/ExampleConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b852d3c62124624888d03e611f7b1fc 3 | timeCreated: 1534126175 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/LinkXmlGen/LinkXmlGen.tpl.txt: -------------------------------------------------------------------------------- 1 | <% 2 | require "TemplateCommon" 3 | %> 4 | 5 | 6 | <%ForEachCsList(assembly_infos, function(assembly_info)%> 7 | 8 | <%ForEachCsList(assembly_info.Types, function(type) 9 | %> 10 | <%end)%> 11 | 12 | <%end)%> 13 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/LinkXmlGen/LinkXmlGen.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fa8c6bd6daed854c98654418f48a830 3 | timeCreated: 1482482561 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - Template: {fileID: 4900000, guid: 384feb229d259f549bbbac9e910b782b, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/iOS/libxlua.a.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d65468f3356ca741b3fbebea91dfb6c 3 | timeCreated: 1451443249 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Any: 12 | enabled: 0 13 | settings: {} 14 | Editor: 15 | enabled: 0 16 | settings: 17 | DefaultValueInitialized: true 18 | iOS: 19 | enabled: 1 20 | settings: {} 21 | userData: 22 | assetBundleName: 23 | assetBundleVariant: 24 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/iOS/HotfixFlags.cpp.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef0ed550afe43d449b58d883fad0585c 3 | timeCreated: 1498103331 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 0 14 | settings: {} 15 | Editor: 16 | enabled: 0 17 | settings: 18 | DefaultValueInitialized: true 19 | iOS: 20 | enabled: 1 21 | settings: {} 22 | userData: 23 | assetBundleName: 24 | assetBundleVariant: 25 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/AssetBundleManagerForLua.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class AssetBundleManagerForLua 6 | { 7 | static private AssetBundle mLuaAssetBundle; 8 | static public AssetBundle LuaAssetBundle 9 | { 10 | get 11 | { 12 | if(mLuaAssetBundle == null) 13 | { 14 | mLuaAssetBundle = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/AssetBundle" + "/lua"); 15 | } 16 | return mLuaAssetBundle; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/x86/libxlua.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 038a89637b659e346a7a712ce0c9271b 3 | timeCreated: 1451443249 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Android: 12 | enabled: 1 13 | settings: 14 | CPU: x86 15 | Any: 16 | enabled: 0 17 | settings: {} 18 | Editor: 19 | enabled: 0 20 | settings: 21 | DefaultValueInitialized: true 22 | userData: 23 | assetBundleName: 24 | assetBundleVariant: 25 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/armeabi-v7a/libxlua.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e1b2e17cce240d4c8ff5457ac996e0d 3 | timeCreated: 1451443249 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Android: 12 | enabled: 1 13 | settings: 14 | CPU: ARMv7 15 | Any: 16 | enabled: 0 17 | settings: {} 18 | Editor: 19 | enabled: 0 20 | settings: 21 | DefaultValueInitialized: true 22 | userData: 23 | assetBundleName: 24 | assetBundleVariant: 25 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/ARM/xlua.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb3d94d8757d66b40b20f0386b52d01d 3 | timeCreated: 1490146878 4 | licenseType: Free 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 0 14 | settings: {} 15 | Editor: 16 | enabled: 0 17 | settings: 18 | DefaultValueInitialized: true 19 | WindowsStoreApps: 20 | enabled: 1 21 | settings: 22 | CPU: ARM 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/x64/xlua.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a73864467778862409da51f9feb60004 3 | timeCreated: 1490146878 4 | licenseType: Free 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 0 14 | settings: {} 15 | Editor: 16 | enabled: 0 17 | settings: 18 | DefaultValueInitialized: true 19 | WindowsStoreApps: 20 | enabled: 1 21 | settings: 22 | CPU: x64 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WSA/x86/xlua.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fd23a6414095674493657a67a8043a1 3 | timeCreated: 1489995544 4 | licenseType: Free 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | Any: 13 | enabled: 0 14 | settings: {} 15 | Editor: 16 | enabled: 0 17 | settings: 18 | DefaultValueInitialized: true 19 | WindowsStoreApps: 20 | enabled: 1 21 | settings: 22 | CPU: x86 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaUpdateAssistant.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using XLua; 3 | 4 | public class LuaUpdateAssistant : LuaAssistantBase 5 | { 6 | private Action updateFunc; 7 | 8 | protected override void Awake() 9 | { 10 | base.Awake(); 11 | updateFunc = luaBehaviour.LuaInstance.Get>("Update"); 12 | } 13 | 14 | void Update() 15 | { 16 | if(luaBehaviour.LuaInstance != null) 17 | { 18 | updateFunc?.Invoke(luaBehaviour.LuaInstance); 19 | } 20 | } 21 | 22 | void OnDestroy() 23 | { 24 | updateFunc = null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaLateUpdateAssistant.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using XLua; 3 | 4 | public class LuaLateUpdateAssistant : LuaAssistantBase 5 | { 6 | private Action lateUpdateFunc; 7 | 8 | protected override void Awake() 9 | { 10 | base.Awake(); 11 | lateUpdateFunc = luaBehaviour.LuaInstance.Get>("LateUpdate"); 12 | } 13 | 14 | void LateUpdate() 15 | { 16 | if (luaBehaviour.LuaInstance != null) 17 | { 18 | lateUpdateFunc?.Invoke(luaBehaviour.LuaInstance); 19 | } 20 | } 21 | 22 | void OnDestroy() 23 | { 24 | lateUpdateFunc = null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaFixedUpdateAssistant.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using XLua; 3 | using UnityEngine; 4 | 5 | public class LuaFixedUpdateAssistant : LuaAssistantBase 6 | { 7 | private Action fixedUpdateFunc; 8 | 9 | protected override void Awake() 10 | { 11 | base.Awake(); 12 | fixedUpdateFunc = luaBehaviour.LuaInstance.Get>("FixedUpdate"); 13 | } 14 | 15 | void FixedUpdate() 16 | { 17 | if (luaBehaviour.LuaInstance != null) 18 | { 19 | fixedUpdateFunc?.Invoke(luaBehaviour.LuaInstance); 20 | } 21 | } 22 | 23 | void OnDestroy() 24 | { 25 | fixedUpdateFunc = null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/TemplateRef.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | namespace XLua 4 | { 5 | public class TemplateRef : ScriptableObject 6 | { 7 | public TextAsset LuaClassWrap; 8 | public TextAsset LuaClassWrapGCM; 9 | public TextAsset LuaDelegateBridge; 10 | public TextAsset LuaDelegateWrap; 11 | public TextAsset LuaEnumWrap; 12 | public TextAsset LuaEnumWrapGCM; 13 | public TextAsset LuaInterfaceBridge; 14 | public TextAsset LuaRegister; 15 | public TextAsset LuaRegisterGCM; 16 | public TextAsset LuaWrapPusher; 17 | public TextAsset PackUnpack; 18 | public TextAsset TemplateCommon; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/Android/libs/arm64-v8a/libxlua.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c76d1cfa11c6b741ba30b24d36cbcf2 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | platformData: 13 | - first: 14 | Android: Android 15 | second: 16 | enabled: 1 17 | settings: 18 | CPU: ARM64 19 | - first: 20 | Any: 21 | second: 22 | enabled: 0 23 | settings: {} 24 | - first: 25 | Editor: Editor 26 | second: 27 | enabled: 0 28 | settings: 29 | DefaultValueInitialized: true 30 | userData: 31 | assetBundleName: 32 | assetBundleVariant: 33 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Game/LuaBehaviourTest2.lua: -------------------------------------------------------------------------------- 1 | local class = require "Core.Middleclass" 2 | local LuaBehaviour = require "Core.LuaBehaviour" 3 | 4 | local LuaBehaviourTest = class("LuaBehaviourTest", LuaBehaviour) 5 | 6 | --------------------------需要序列化的数据-------------------------- 7 | LuaBehaviourTest:AddDefineList({ 8 | {name = "Age", type = CS.System.Int32}, 9 | {name = "Name", type = CS.System.String}, 10 | }) 11 | --在编辑器下只加载DefineList,不管其他部分 12 | if ExecuteInEditorScript then return LuaBehaviourTest end 13 | --------------------------需要序列化的数据-------------------------- 14 | 15 | function LuaBehaviourTest:initialize() 16 | end 17 | 18 | function LuaBehaviourTest:Awake() 19 | 20 | end 21 | 22 | function LuaBehaviourTest:OnEnable() 23 | 24 | end 25 | 26 | function LuaBehaviourTest:OnDisable() 27 | 28 | end 29 | 30 | return LuaBehaviourTest 31 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/Assistant/LuaOnPointerClickAssistant.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using XLua; 3 | using UnityEngine.EventSystems; 4 | 5 | public class LuaOnPointerClickAssistant : LuaAssistantBase, IPointerClickHandler 6 | { 7 | private Action onPointerClickFunc; 8 | 9 | protected override void Awake() 10 | { 11 | base.Awake(); 12 | onPointerClickFunc = luaBehaviour.LuaInstance.Get>("OnPointerClick"); 13 | } 14 | 15 | public void OnPointerClick(PointerEventData eventData) 16 | { 17 | if (luaBehaviour.LuaInstance != null) 18 | { 19 | onPointerClickFunc?.Invoke(luaBehaviour.LuaInstance, eventData); 20 | } 21 | } 22 | 23 | void OnDestroy() 24 | { 25 | onPointerClickFunc = null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WebGL/xlua_webgl.cpp.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92f9773841d5ffd44b794b9b584a5c05 3 | timeCreated: 1504062948 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 2 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | data: 13 | first: 14 | Any: 15 | second: 16 | enabled: 0 17 | settings: {} 18 | data: 19 | first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | data: 26 | first: 27 | Facebook: WebGL 28 | second: 29 | enabled: 1 30 | settings: {} 31 | data: 32 | first: 33 | WebGL: WebGL 34 | second: 35 | enabled: 1 36 | settings: {} 37 | userData: 38 | assetBundleName: 39 | assetBundleVariant: 40 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | using System; 10 | 11 | namespace XLua 12 | { 13 | [Serializable] 14 | public class LuaException : Exception 15 | { 16 | public LuaException(string message) : base(message) 17 | {} 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/perf/memory.lua.txt: -------------------------------------------------------------------------------- 1 | -- Tencent is pleased to support the open source community by making xLua available. 2 | -- Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 3 | -- 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 4 | -- http://opensource.org/licenses/MIT 5 | -- 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. 6 | 7 | local function snapshot() 8 | error('use memory leak checker instead!') 9 | end 10 | 11 | --returns the total memory in use by Lua (in Kbytes). 12 | local function total() 13 | error('use memory leak checker instead!') 14 | end 15 | 16 | 17 | return { 18 | snapshot = snapshot, 19 | total = total 20 | } 21 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 blueberryzzz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/iOS/HotfixFlags.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int* xlua_hotfix_flags = NULL; 5 | int xlua_hotfix_flags_len = 0; 6 | 7 | extern "C" { 8 | 9 | int xlua_get_hotfix_flag(int idx) { 10 | if (idx >= xlua_hotfix_flags_len) { 11 | return 0; 12 | } else { 13 | return xlua_hotfix_flags[idx]; 14 | } 15 | } 16 | 17 | void xlua_set_hotfix_flag(int idx, int flag) { 18 | int i = 0; 19 | int* new_hotfix_flags = NULL; 20 | if (idx >= xlua_hotfix_flags_len) { 21 | if (xlua_hotfix_flags == NULL) { 22 | xlua_hotfix_flags = (int*)malloc((idx + 1) * sizeof(int)); 23 | } else { 24 | new_hotfix_flags = (int*)realloc(xlua_hotfix_flags, (idx + 1) * sizeof(int)); 25 | if (NULL == new_hotfix_flags) { // just skip operation 26 | return; 27 | } 28 | xlua_hotfix_flags = new_hotfix_flags; 29 | } 30 | for(i = xlua_hotfix_flags_len; i < (idx + 1); i++) { 31 | xlua_hotfix_flags[i] = 0; 32 | } 33 | xlua_hotfix_flags_len = idx + 1; 34 | } 35 | xlua_hotfix_flags[idx] = flag; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Core/LuaBehaviour.lua: -------------------------------------------------------------------------------- 1 | local class = require "Core.middleClass" 2 | local LuaBehaviour = class("LuaBehaviour") 3 | 4 | local typeDict = {} 5 | setmetatable(typeDict, { __index = function(t, k) 6 | t[k] = typeof(k) 7 | return t[k] 8 | end}) 9 | function LuaBehaviour:AddDefineList(defineList) 10 | self._DefineList = self._DefineList or {} 11 | for key, value in pairs(defineList) do 12 | table.insert(self._DefineList, {name = value.name, type = typeDict[value.type]}) 13 | end 14 | end 15 | --在编辑器下只加载DefineList,不管其他部分 16 | if ExecuteInEditorScript then return LuaBehaviour end 17 | 18 | local AssistantDict = { 19 | ["Update"] = typeof(CS.LuaUpdateAssistant), 20 | ["FixedUpdate"] = typeof(CS.LuaFixedUpdateAssistant), 21 | ["LateUpdate"] = typeof(CS.LuaLateUpdateAssistant), 22 | ["OnPointerClick"] = typeof(CS.LuaOnPointerClickAssistant) 23 | } 24 | function LuaBehaviour:initialize() 25 | for funcName, assistant in pairs(AssistantDict) do 26 | if self[funcName] then 27 | self.gameObject:AddComponent(assistant) 28 | end 29 | end 30 | end 31 | 32 | return LuaBehaviour 33 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Hidden Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 1 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/LinkXmlGen/LinkXmlGen.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using XLua; 4 | using System.IO; 5 | using System.Text; 6 | using System.Linq; 7 | using CSObjectWrapEditor; 8 | 9 | public class LinkXmlGen : ScriptableObject 10 | { 11 | public TextAsset Template; 12 | 13 | public static IEnumerable GetTasks(LuaEnv lua_env, UserConfig user_cfg) 14 | { 15 | LuaTable data = lua_env.NewTable(); 16 | var assembly_infos = (from type in (user_cfg.ReflectionUse.Concat(user_cfg.LuaCallCSharp)) 17 | group type by type.Assembly.GetName().Name into assembly_info 18 | select new { FullName = assembly_info.Key, Types = assembly_info.ToList()}).ToList(); 19 | data.Set("assembly_infos", assembly_infos); 20 | 21 | yield return new CustomGenTask 22 | { 23 | Data = data, 24 | Output = new StreamWriter(GeneratorConfig.common_path + "/link.xml", 25 | false, Encoding.UTF8) 26 | }; 27 | } 28 | 29 | [GenCodeMenu]//加到Generate Code菜单里头 30 | public static void GenLinkXml() 31 | { 32 | Generator.CustomGen(ScriptableObject.CreateInstance().Template.text, GetTasks); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/TemplateRef.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4898604144dd928468ddca1af81d58ae 3 | timeCreated: 1501232546 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - LuaClassWrap: {fileID: 4900000, guid: 8503038eabbabe44dac0f5f749d4411a, type: 3} 9 | - LuaClassWrapGCM: {fileID: 4900000, guid: 2bd79d95fd859724283926ad8fa4df30, type: 3} 10 | - LuaDelegateBridge: {fileID: 4900000, guid: 3d992756e2469044484be75f78e4e556, type: 3} 11 | - LuaDelegateWrap: {fileID: 4900000, guid: 33b33e1cd617f794b8c801a32f3b2539, type: 3} 12 | - LuaEnumWrap: {fileID: 4900000, guid: ae16c73aad9a21a44aef65decb7e4928, type: 3} 13 | - LuaEnumWrapGCM: {fileID: 4900000, guid: ea84a5ee7abf8e347a810eb7848add46, type: 3} 14 | - LuaInterfaceBridge: {fileID: 4900000, guid: 7165d08e91378494dadeb10e5338accb, 15 | type: 3} 16 | - LuaRegister: {fileID: 4900000, guid: e416b82ec9fe340458f97cf1e3468ef7, type: 3} 17 | - LuaRegisterGCM: {fileID: 4900000, guid: 46c7366d55afbf1459674448d92c44c8, type: 3} 18 | - LuaWrapPusher: {fileID: 4900000, guid: d1a916469d261d447972d287b6c5b7a0, type: 3} 19 | - PackUnpack: {fileID: 4900000, guid: c9ef7e8f2a3b37744aad49b99370c16b, type: 3} 20 | - TemplateCommon: {fileID: 4900000, guid: cb41d53afe75a9443b182e284298feeb, type: 3} 21 | executionOrder: 0 22 | icon: {instanceID: 0} 23 | userData: 24 | assetBundleName: 25 | assetBundleVariant: 26 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 15G31 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | xlua 11 | CFBundleIdentifier 12 | com.xlua 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | xlua 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleSupportedPlatforms 24 | 25 | MacOSX 26 | 27 | CFBundleVersion 28 | 1 29 | DTCompiler 30 | com.apple.compilers.llvm.clang.1_0 31 | DTPlatformBuild 32 | 7D1014 33 | DTPlatformVersion 34 | GM 35 | DTSDKBuild 36 | 15E60 37 | DTSDKName 38 | macosx10.11 39 | DTXcode 40 | 0731 41 | DTXcodeBuild 42 | 7D1014 43 | NSHumanReadableCopyright 44 | Copyright @2017 THL A29 Limited, a Tencent company. All rights reserved. 45 | 46 | 47 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86/xlua.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79f5c811b2e4e444ab2d97cad5cfd934 3 | PluginImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | isPreloaded: 0 8 | platformData: 9 | Android: 10 | enabled: 0 11 | settings: 12 | CPU: AnyCPU 13 | Any: 14 | enabled: 0 15 | settings: {} 16 | Editor: 17 | enabled: 1 18 | settings: 19 | CPU: x86 20 | DefaultValueInitialized: true 21 | OS: Windows 22 | Linux: 23 | enabled: 1 24 | settings: 25 | CPU: x86 26 | Linux64: 27 | enabled: 0 28 | settings: 29 | CPU: None 30 | LinuxUniversal: 31 | enabled: 0 32 | settings: 33 | CPU: x86 34 | OSXIntel: 35 | enabled: 1 36 | settings: 37 | CPU: AnyCPU 38 | OSXIntel64: 39 | enabled: 0 40 | settings: 41 | CPU: None 42 | OSXUniversal: 43 | enabled: 0 44 | settings: 45 | CPU: x86 46 | WP8: 47 | enabled: 0 48 | settings: 49 | CPU: AnyCPU 50 | DontProcess: False 51 | PlaceholderPath: 52 | Win: 53 | enabled: 1 54 | settings: 55 | CPU: AnyCPU 56 | Win64: 57 | enabled: 0 58 | settings: 59 | CPU: None 60 | WindowsStoreApps: 61 | enabled: 0 62 | settings: 63 | CPU: AnyCPU 64 | DontProcess: False 65 | PlaceholderPath: 66 | SDK: AnySDK 67 | iOS: 68 | enabled: 0 69 | settings: 70 | CompileFlags: 71 | FrameworkDependencies: 72 | userData: 73 | assetBundleName: 74 | assetBundleVariant: 75 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/WebGL/xlua_webgl.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | #include "../../../WebGLPlugins/lapi.c" 3 | #include "../../../WebGLPlugins/lauxlib.c" 4 | #include "../../../WebGLPlugins/lbaselib.c" 5 | #include "../../../WebGLPlugins/lbitlib.c" 6 | #include "../../../WebGLPlugins/lcode.c" 7 | #include "../../../WebGLPlugins/lcorolib.c" 8 | #include "../../../WebGLPlugins/lctype.c" 9 | #include "../../../WebGLPlugins/ldblib.c" 10 | #include "../../../WebGLPlugins/ldebug.c" 11 | #include "../../../WebGLPlugins/ldo.c" 12 | #include "../../../WebGLPlugins/ldump.c" 13 | #include "../../../WebGLPlugins/lfunc.c" 14 | #include "../../../WebGLPlugins/lgc.c" 15 | #include "../../../WebGLPlugins/linit.c" 16 | #include "../../../WebGLPlugins/liolib.c" 17 | #include "../../../WebGLPlugins/llex.c" 18 | #include "../../../WebGLPlugins/lmathlib.c" 19 | #include "../../../WebGLPlugins/lmem.c" 20 | #include "../../../WebGLPlugins/loadlib.c" 21 | #include "../../../WebGLPlugins/lobject.c" 22 | #include "../../../WebGLPlugins/lopcodes.c" 23 | #include "../../../WebGLPlugins/loslib.c" 24 | #include "../../../WebGLPlugins/lparser.c" 25 | #include "../../../WebGLPlugins/lstate.c" 26 | #include "../../../WebGLPlugins/lstring.c" 27 | #include "../../../WebGLPlugins/lstrlib.c" 28 | #include "../../../WebGLPlugins/ltable.c" 29 | #include "../../../WebGLPlugins/ltablib.c" 30 | #include "../../../WebGLPlugins/ltm.c" 31 | #include "../../../WebGLPlugins/lundump.c" 32 | #include "../../../WebGLPlugins/lutf8lib.c" 33 | #include "../../../WebGLPlugins/lvm.c" 34 | #include "../../../WebGLPlugins/lzio.c" 35 | #include "../../../WebGLPlugins/i64lib.c" 36 | #include "../../../WebGLPlugins/perflib.c" 37 | #include "../../../WebGLPlugins/xlua.c" 38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | using System.IO; 6 | using XLua; 7 | 8 | public class LuaManager 9 | { 10 | public const string LuaPath = "Assets/Lua/"; 11 | //通过路径加载lua文件 12 | public static byte[] BaseLoader(ref string fileName) 13 | { 14 | if (!fileName.EndsWith(".lua", StringComparison.Ordinal)) 15 | { 16 | fileName = fileName.Replace('.', '/'); 17 | fileName += ".lua"; 18 | } 19 | else 20 | { 21 | fileName = fileName.Replace('.', '/').Replace("/lua", ".lua"); 22 | } 23 | #if UNITY_EDITOR 24 | var path = Path.Combine(LuaPath, fileName); 25 | if (!File.Exists(path)) 26 | { 27 | Debug.LogErrorFormat("Load lua file failed: {0}, file is not existed.", path); 28 | return null; 29 | } 30 | return File.ReadAllBytes(path); 31 | #else 32 | var path = Path.Combine("Assets/LuaBundle/", fileName); 33 | path += ".bytes"; 34 | var assetBundle = AssetBundleManagerForLua.LuaAssetBundle; 35 | var luaAsset = assetBundle.LoadAsset(path); 36 | return luaAsset.bytes; 37 | #endif 38 | } 39 | 40 | private static LuaEnv mLuaEnvInstance; 41 | public static LuaEnv LuaEnvInstance 42 | { 43 | get 44 | { 45 | if(mLuaEnvInstance != null) 46 | { 47 | return mLuaEnvInstance; 48 | } 49 | mLuaEnvInstance = new LuaEnv(); 50 | mLuaEnvInstance.AddLoader(BaseLoader); 51 | return mLuaEnvInstance; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86/libxlua.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f19d785ae44ddc478a08a87ccd9dbb2 3 | timeCreated: 1488352111 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Android: 12 | enabled: 0 13 | settings: 14 | CPU: AnyCPU 15 | Any: 16 | enabled: 0 17 | settings: {} 18 | Editor: 19 | enabled: 1 20 | settings: 21 | CPU: x86 22 | DefaultValueInitialized: true 23 | OS: AnyOS 24 | Linux: 25 | enabled: 1 26 | settings: 27 | CPU: x86 28 | Linux64: 29 | enabled: 0 30 | settings: 31 | CPU: None 32 | LinuxUniversal: 33 | enabled: 1 34 | settings: 35 | CPU: x86 36 | OSXIntel: 37 | enabled: 0 38 | settings: 39 | CPU: None 40 | OSXIntel64: 41 | enabled: 0 42 | settings: 43 | CPU: None 44 | OSXUniversal: 45 | enabled: 0 46 | settings: 47 | CPU: None 48 | WP8: 49 | enabled: 0 50 | settings: 51 | CPU: AnyCPU 52 | DontProcess: False 53 | PlaceholderPath: 54 | Win: 55 | enabled: 1 56 | settings: 57 | CPU: AnyCPU 58 | Win64: 59 | enabled: 0 60 | settings: 61 | CPU: None 62 | WindowsStoreApps: 63 | enabled: 0 64 | settings: 65 | CPU: AnyCPU 66 | DontProcess: False 67 | PlaceholderPath: 68 | SDK: AnySDK 69 | iOS: 70 | enabled: 0 71 | settings: 72 | CompileFlags: 73 | FrameworkDependencies: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Editor/AssetBundleManagerForLua.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | using System.IO; 6 | 7 | public class AssetBundleManagerForLua 8 | { 9 | const string luaBundlePath = "Assets/LuaBundle"; 10 | static public string assetBundlePath 11 | { 12 | get 13 | { 14 | return Application.streamingAssetsPath + "/AssetBundle"; 15 | } 16 | } 17 | [MenuItem("AssetBundles/Build AssetBundle For Lua")] 18 | static public void BuildAssetBundleForLua() 19 | { 20 | //复制到LuaBundle目录下,准备打Bundle 21 | if (Directory.Exists(luaBundlePath)) 22 | { 23 | FileUtil.DeleteFileOrDirectory(luaBundlePath); 24 | } 25 | FileUtil.CopyFileOrDirectory(LuaManager.LuaPath, luaBundlePath); 26 | string[] filePaths = Directory.GetFiles(luaBundlePath, "*", SearchOption.AllDirectories); 27 | foreach(var filePath in filePaths) 28 | { 29 | if (filePath.IndexOf(".meta") == -1) 30 | { 31 | File.Move(filePath, filePath + ".bytes"); 32 | } 33 | } 34 | AssetDatabase.Refresh(); 35 | //设置bundle名 36 | var importer = AssetImporter.GetAtPath(luaBundlePath); 37 | importer.assetBundleName = "lua"; 38 | AssetBundleBuild build = new AssetBundleBuild(); 39 | build.assetBundleName = importer.assetBundleName; 40 | build.assetNames = AssetDatabase.GetAssetPathsFromAssetBundle(importer.assetBundleName); 41 | //Build AssetBundle 42 | if (Directory.Exists(assetBundlePath)) 43 | { 44 | FileUtil.DeleteFileOrDirectory(assetBundlePath); 45 | } 46 | Directory.CreateDirectory(assetBundlePath); 47 | BuildPipeline.BuildAssetBundles( 48 | assetBundlePath, 49 | new AssetBundleBuild[] { build}, 50 | BuildAssetBundleOptions.None, 51 | EditorUserBuildSettings.activeBuildTarget 52 | ); 53 | AssetDatabase.Refresh(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/xlua.bundle.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6a34038df77e48438826b6ff94aa69e 3 | folderAsset: yes 4 | PluginImporter: 5 | externalObjects: {} 6 | serializedVersion: 2 7 | iconMap: {} 8 | executionOrder: {} 9 | defineConstraints: [] 10 | isPreloaded: 0 11 | isOverridable: 0 12 | isExplicitlyReferenced: 0 13 | validateReferences: 1 14 | platformData: 15 | - first: 16 | '': Linux 17 | second: 18 | enabled: 0 19 | settings: 20 | CPU: x86 21 | - first: 22 | '': OSXIntel 23 | second: 24 | enabled: 1 25 | settings: 26 | CPU: AnyCPU 27 | - first: 28 | '': OSXIntel64 29 | second: 30 | enabled: 1 31 | settings: 32 | CPU: AnyCPU 33 | - first: 34 | Android: Android 35 | second: 36 | enabled: 0 37 | settings: 38 | CPU: AnyCPU 39 | - first: 40 | Any: 41 | second: 42 | enabled: 0 43 | settings: {} 44 | - first: 45 | Editor: Editor 46 | second: 47 | enabled: 1 48 | settings: 49 | CPU: AnyCPU 50 | DefaultValueInitialized: true 51 | OS: OSX 52 | - first: 53 | Facebook: Win 54 | second: 55 | enabled: 0 56 | settings: 57 | CPU: AnyCPU 58 | - first: 59 | Facebook: Win64 60 | second: 61 | enabled: 0 62 | settings: 63 | CPU: AnyCPU 64 | - first: 65 | Standalone: Linux64 66 | second: 67 | enabled: 0 68 | settings: 69 | CPU: AnyCPU 70 | - first: 71 | Standalone: OSXUniversal 72 | second: 73 | enabled: 1 74 | settings: 75 | CPU: AnyCPU 76 | - first: 77 | Standalone: Win 78 | second: 79 | enabled: 0 80 | settings: 81 | CPU: AnyCPU 82 | - first: 83 | Standalone: Win64 84 | second: 85 | enabled: 0 86 | settings: 87 | CPU: AnyCPU 88 | - first: 89 | iPhone: iOS 90 | second: 91 | enabled: 0 92 | settings: 93 | CompileFlags: 94 | FrameworkDependencies: 95 | userData: 96 | assetBundleName: 97 | assetBundleVariant: 98 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_AutoSyncTransforms: 1 46 | m_AlwaysShowColliders: 0 47 | m_ShowColliderSleep: 1 48 | m_ShowColliderContacts: 0 49 | m_ShowColliderAABB: 0 50 | m_ContactArrowScale: 0.2 51 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 52 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 53 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 54 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 55 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 56 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Game/LuaBehaviourTest.lua: -------------------------------------------------------------------------------- 1 | local class = require "Core.Middleclass" 2 | local LuaBehaviour = require "Core.LuaBehaviour" 3 | 4 | local LuaBehaviourTest = class("LuaBehaviourTest", LuaBehaviour) 5 | 6 | --------------------------需要序列化的数据-------------------------- 7 | LuaBehaviourTest:AddDefineList({ 8 | {name = "colorValue", type = CS.UnityEngine.Color}, 9 | {name = "textCmp", type = CS.UnityEngine.UI.Text}, 10 | {name = "rectCmp", type = CS.UnityEngine.RectTransform}, 11 | {name = "stringColorList", type = CS.System.Collections.Generic.List(typeof(CS.StringAndColor))}, 12 | {name = "int32Value", type = CS.System.Int32}, 13 | {name = "DoubleValue", type = CS.System.Double}, 14 | {name = "boolValue", type = CS.System.Boolean}, 15 | {name = "vector3Value", type = CS.UnityEngine.Vector3}, 16 | {name = "season", type = CS.Season}, 17 | }) 18 | --在编辑器下只加载DefineList,不管其他部分 19 | if ExecuteInEditorScript then return LuaBehaviourTest end 20 | --------------------------需要序列化的数据-------------------------- 21 | 22 | function LuaBehaviourTest:initialize() 23 | --LuaBehaviour的构造函数 24 | LuaBehaviour.initialize(self) 25 | --输出注入的对象 26 | for key, value in pairs(self) do 27 | print("key : "..key..", value : "..tostring(value)) 28 | end 29 | 30 | self.updateTextTime = CS.UnityEngine.Time.time 31 | self.stringIndex = 0 32 | self.textCmp.text = self.stringColorList[0].s 33 | self.textCmp.color = self.stringColorList[0].c 34 | end 35 | 36 | function LuaBehaviourTest:OnEnable() 37 | print("OnEnable") 38 | end 39 | 40 | function LuaBehaviourTest:Update() 41 | if CS.UnityEngine.Time.time - self.updateTextTime > 3 then 42 | self.updateTextTime = CS.UnityEngine.Time.time 43 | self.stringIndex = (self.stringIndex + 1) % self.stringColorList.Count 44 | self.textCmp.text = self.stringColorList[self.stringIndex].s 45 | self.textCmp.color = self.stringColorList[self.stringIndex].c 46 | end 47 | end 48 | --[[ 49 | function LuaBehaviourTest:FixedUpdate() 50 | print("FixedUpdate") 51 | end 52 | 53 | function LuaBehaviourTest:LateUpdate() 54 | print("LateUpdate") 55 | end 56 | ]]-- 57 | 58 | function LuaBehaviourTest:OnPointerClick(eventData) 59 | print("click pos : "..tostring(eventData.position)) 60 | end 61 | 62 | function LuaBehaviourTest:OnDisable() 63 | print("OnDisable") 64 | end 65 | 66 | function LuaBehaviourTest:OnDestroy() 67 | print("OnDestroy") 68 | end 69 | 70 | return LuaBehaviourTest 71 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/SignatureLoader.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_WSA || UNITY_EDITOR 2 | using System.Security.Cryptography; 3 | #else 4 | using Windows.Security.Cryptography; 5 | using Windows.Security.Cryptography.Core; 6 | #endif 7 | using System; 8 | 9 | namespace XLua 10 | { 11 | public class SignatureLoader 12 | { 13 | private LuaEnv.CustomLoader userLoader; 14 | #if !UNITY_WSA || UNITY_EDITOR 15 | RSACryptoServiceProvider rsa; 16 | SHA1 sha; 17 | #else 18 | AsymmetricKeyAlgorithmProvider rsa; 19 | CryptographicKey key; 20 | #endif 21 | 22 | public SignatureLoader(string publicKey, LuaEnv.CustomLoader loader) 23 | { 24 | #if !UNITY_WSA || UNITY_EDITOR 25 | rsa = new RSACryptoServiceProvider(); 26 | rsa.ImportCspBlob(Convert.FromBase64String(publicKey)); 27 | sha = new SHA1CryptoServiceProvider(); 28 | #else 29 | rsa = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaSignPkcs1Sha1); 30 | key = rsa.ImportPublicKey(CryptographicBuffer.DecodeFromBase64String(publicKey), CryptographicPublicKeyBlobType.Capi1PublicKey); 31 | #endif 32 | userLoader = loader; 33 | } 34 | 35 | 36 | byte[] load_and_verify(ref string filepath) 37 | { 38 | byte[] data = userLoader(ref filepath); 39 | if (data == null) 40 | { 41 | return null; 42 | } 43 | if (data.Length < 128) 44 | { 45 | throw new InvalidProgramException(filepath + " length less than 128!"); 46 | } 47 | 48 | byte[] sig = new byte[128]; 49 | byte[] filecontent = new byte[data.Length - 128]; 50 | Array.Copy(data, sig, 128); 51 | Array.Copy(data, 128, filecontent, 0, filecontent.Length); 52 | 53 | #if !UNITY_WSA || UNITY_EDITOR 54 | if (!rsa.VerifyData(filecontent, sha, sig)) 55 | { 56 | throw new InvalidProgramException(filepath + " has invalid signature!"); 57 | } 58 | #else 59 | if (!CryptographicEngine.VerifySignature(key, CryptographicBuffer.CreateFromByteArray(filecontent), CryptographicBuffer.CreateFromByteArray(sig))) 60 | { 61 | throw new InvalidProgramException(filepath + " has invalid signature!"); 62 | } 63 | #endif 64 | return filecontent; 65 | } 66 | 67 | 68 | public static implicit operator LuaEnv.CustomLoader(SignatureLoader signatureLoader) 69 | { 70 | return signatureLoader.load_and_verify; 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/RawObject.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | namespace XLua 10 | { 11 | public interface RawObject 12 | { 13 | object Target { get; } 14 | } 15 | } 16 | 17 | namespace XLua.Cast 18 | { 19 | public class Any : RawObject 20 | { 21 | T mTarget; 22 | 23 | public Any(T i) 24 | { 25 | mTarget = i; 26 | } 27 | 28 | public object Target 29 | { 30 | get 31 | { 32 | return mTarget; 33 | } 34 | } 35 | } 36 | 37 | public class Byte : Any 38 | { 39 | public Byte(byte i) : base(i) 40 | { 41 | } 42 | } 43 | 44 | public class SByte : Any 45 | { 46 | public SByte(sbyte i) : base(i) 47 | { 48 | } 49 | } 50 | 51 | public class Char : Any 52 | { 53 | public Char(char i) : base(i) 54 | { 55 | } 56 | } 57 | 58 | public class Int16 : Any 59 | { 60 | public Int16(short i) : base(i) 61 | { 62 | } 63 | } 64 | 65 | public class UInt16 : Any 66 | { 67 | public UInt16(ushort i) : base(i) 68 | { 69 | } 70 | } 71 | 72 | public class Int32 : Any 73 | { 74 | public Int32(int i) : base(i) 75 | { 76 | } 77 | } 78 | 79 | public class UInt32 : Any 80 | { 81 | public UInt32(uint i) : base(i) 82 | { 83 | } 84 | } 85 | 86 | public class Int64 : Any 87 | { 88 | public Int64(long i) : base(i) 89 | { 90 | } 91 | } 92 | 93 | public class UInt64 : Any 94 | { 95 | public UInt64(ulong i) : base(i) 96 | { 97 | } 98 | } 99 | 100 | public class Float : Any 101 | { 102 | public Float(float i) : base(i) 103 | { 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LuaBehaviourInXLua 2 | XLua下支持多种注入类型的LuaBehaviour 3 | # 简介 4 |   在基于lua进行热更新的项目中,我们通常会通过luaBehaviour来让lua文件模拟MonoBehaviour,可以让lua文件拥有一些MonoBehaviour的生命周期,如Enable、Disable、Update。 5 |   同时可以注入一些UnityEngine.Object。在lua中方便的调用Unity中的对象。方便开发者进行开发。 6 |   本文进行介绍的luaBehaviour就是基于这个思路设计的,上面提到的特性之外还通过Json支持了更多类型的注入,Editor界面更人性化的展示,整个开发过程更接近MonoBehaviour的开发体验。 7 | # 使用 8 | 1.新建继承LuaBehaviour的lua文件,通过AddDefineList添加需要序列化的信息。 9 | ![](Doc/DefineList.png) 10 | 2.直接把这个lua文件拖到CS中的LuaBehaviour上即可。 11 | ![](Doc/DragToLuaBehaviour.png) 12 | ![](Doc/DragOK.png) 13 |   接下来可以像MonoBehaviour一样对数据进行编辑了。 14 | ![](Doc/SetLuaBehaviour.png) 15 | # 实现 16 | ## 脚本的序列化 17 |   luaBehaviour在使用的时候一般是通过记录名字或路径的方式来序列化lua文件的的。打包后通过这个路径从AssetBundle中进行lua文件的加载(这个是lua脚本热更新常用的策略,在这边就不多说了)。 18 |   这里还是通过路径来记录lua文件,但是不需要手动输入,而是通过直接拖动的方式间接记录lua文件路径。 19 | ## 注入的方式 20 |   不通过C#侧定义注册信息,而是通过在Lua中先定义好要注册的类型和名称(更符合MonoBehaviour的开发姿势)。开发时,Editor读取lua中定义的类型和名称信息,展示在Inspector中,供开发者编辑。 21 |   在运行时再将序列化的数据注入到lua实例中。 22 | ### 序列化的实现 23 | #### UnityEngine.Object类型对象的序列化 24 |   这种类型没啥特别的,在LuaBehaviour脚本中定义一个记录key和UnityEngine.Object的List即可。 25 | #### 其他类型的序列化 26 |   非UnityEngine.Object类型就没有一个统一的格式,无法通过一个列表简单的进行记录。但是我们查看Prefab的实例可以发现,Prefab序列化的数据其实和Json很像。对在MonoBehaviour中定义的各个字段的序列化姿势也和Json很像。 27 | ![](Doc/ObjSerialize.png) 28 |   所以这里考虑使用Json来序列化非UnityEngine.Object类型的对象。刚好Unity由提供了一套简单高效的Json工具JsonUtility。JsonUtility内部就是通过Unity serializer实现的,所以稳定性很有保证。 29 |   但是JsonUtility有个缺点,只能序列化一部分类型,不能序列化如Int、List这种类型。 30 |   为了解决这个问题。这里在序列化的时候通过泛型为每个类型生成一个Wrap类型。即可通用的实现各种类型的序列化。 31 | ![](Doc/JsonSerialize.png) 32 | ### 注入的实现 33 | #### UnityEngine.Object类型对象的注入 34 |   也没啥好说的,直接根据key向Lua实例中Set即可。 35 | #### 其他类型的注入 36 |   先实例化为Wrap对象,然后再取出其中的需要注入的对象,Set到Lua对象中即可。 37 | ### Inspector界面中的展示 38 | #### UnityEngine.Object类型对象的展示 39 |   UnityEngine.Object类型统一使用EditorGUILayout.ObjectField绘制即可。 40 | #### 其他类型的展示 41 |   因为没有找到一个通用的可以表现所有对象的绘制方式,所以这里也做了一个转换。先通过Emit生成一个继承自ScriptableObject的类(因为ScriptableObject是UntiyEngine.Object,所以可以使用SerializedObject来绘制。同时可以直接通过ScriptableObject.CreateInstance进行实例的创建)。把需要绘制的对象放到这个类里面,然后通过EditorGUILayout.PropertyField绘制即可。 42 | ## Enable、Update等函数的调用 43 |   这里把Update、FixedUpdate等高频或者很少使用的函数拆分出去,只有在Lua中定义了这些函数,才添加对应的Assistant脚本对这些函数进行调用。 44 | ![](Doc/AssistantScript.png) 45 |   Enable、Disable、Destroy这三个常用函数,就直接放在LuaBehaviour脚本中进行调用。 46 | # Tips 47 | 1. 这篇文章只起到大致思路和关键点的说明,具体细节可以直接看代码,代码比较少也比较清晰。 48 | 2. 通过Wrap的方式序列化各种对象的方式其实也可以考虑用到一些用户数据在客户端的持久化。 49 | 3. 因为这边主要展示LuaBehanviour的功能,所以AssetBundle的生成和从AssetBundle中加载lua文件都写得很临时,仅作展示用。 50 | 4. 打包测试之前要用AssetBundles->Build AssetBundle For Lua生成一下bundle。 51 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86_64/libxlua.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1055830ddb882704fa71275ed9b2a78d 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | '': Linux 16 | second: 17 | enabled: 0 18 | settings: 19 | CPU: None 20 | - first: 21 | '': LinuxUniversal 22 | second: 23 | enabled: 1 24 | settings: 25 | CPU: x86_64 26 | - first: 27 | '': OSXIntel 28 | second: 29 | enabled: 0 30 | settings: 31 | CPU: None 32 | - first: 33 | '': OSXIntel64 34 | second: 35 | enabled: 0 36 | settings: 37 | CPU: None 38 | - first: 39 | '': WP8 40 | second: 41 | enabled: 0 42 | settings: 43 | CPU: AnyCPU 44 | DontProcess: False 45 | PlaceholderPath: 46 | - first: 47 | Android: Android 48 | second: 49 | enabled: 0 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Any: 54 | second: 55 | enabled: 0 56 | settings: {} 57 | - first: 58 | Editor: Editor 59 | second: 60 | enabled: 1 61 | settings: 62 | CPU: x86_64 63 | DefaultValueInitialized: true 64 | OS: AnyOS 65 | - first: 66 | Facebook: Win 67 | second: 68 | enabled: 0 69 | settings: 70 | CPU: None 71 | - first: 72 | Facebook: Win64 73 | second: 74 | enabled: 1 75 | settings: 76 | CPU: AnyCPU 77 | - first: 78 | Standalone: Linux64 79 | second: 80 | enabled: 1 81 | settings: 82 | CPU: AnyCPU 83 | - first: 84 | Standalone: OSXUniversal 85 | second: 86 | enabled: 0 87 | settings: 88 | CPU: None 89 | - first: 90 | Standalone: Win 91 | second: 92 | enabled: 0 93 | settings: 94 | CPU: None 95 | - first: 96 | Standalone: Win64 97 | second: 98 | enabled: 1 99 | settings: 100 | CPU: AnyCPU 101 | - first: 102 | Windows Store Apps: WindowsStoreApps 103 | second: 104 | enabled: 0 105 | settings: 106 | CPU: AnyCPU 107 | DontProcess: False 108 | PlaceholderPath: 109 | SDK: AnySDK 110 | - first: 111 | iPhone: iOS 112 | second: 113 | enabled: 0 114 | settings: 115 | CompileFlags: 116 | FrameworkDependencies: 117 | userData: 118 | assetBundleName: 119 | assetBundleVariant: 120 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Plugins/x86_64/xlua.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: abe4c5ca91772ea4fae0ae15603c10e4 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | '': Linux 16 | second: 17 | enabled: 0 18 | settings: 19 | CPU: None 20 | - first: 21 | '': LinuxUniversal 22 | second: 23 | enabled: 0 24 | settings: 25 | CPU: x86_64 26 | - first: 27 | '': OSXIntel 28 | second: 29 | enabled: 0 30 | settings: 31 | CPU: None 32 | - first: 33 | '': OSXIntel64 34 | second: 35 | enabled: 1 36 | settings: 37 | CPU: AnyCPU 38 | - first: 39 | '': WP8 40 | second: 41 | enabled: 0 42 | settings: 43 | CPU: AnyCPU 44 | DontProcess: False 45 | PlaceholderPath: 46 | - first: 47 | Android: Android 48 | second: 49 | enabled: 0 50 | settings: 51 | CPU: AnyCPU 52 | - first: 53 | Any: 54 | second: 55 | enabled: 0 56 | settings: {} 57 | - first: 58 | Editor: Editor 59 | second: 60 | enabled: 1 61 | settings: 62 | CPU: x86_64 63 | DefaultValueInitialized: true 64 | OS: Windows 65 | - first: 66 | Facebook: Win 67 | second: 68 | enabled: 0 69 | settings: 70 | CPU: None 71 | - first: 72 | Facebook: Win64 73 | second: 74 | enabled: 1 75 | settings: 76 | CPU: AnyCPU 77 | - first: 78 | Standalone: Linux64 79 | second: 80 | enabled: 1 81 | settings: 82 | CPU: AnyCPU 83 | - first: 84 | Standalone: OSXUniversal 85 | second: 86 | enabled: 0 87 | settings: 88 | CPU: x86_64 89 | - first: 90 | Standalone: Win 91 | second: 92 | enabled: 0 93 | settings: 94 | CPU: None 95 | - first: 96 | Standalone: Win64 97 | second: 98 | enabled: 1 99 | settings: 100 | CPU: AnyCPU 101 | - first: 102 | Windows Store Apps: WindowsStoreApps 103 | second: 104 | enabled: 0 105 | settings: 106 | CPU: AnyCPU 107 | DontProcess: False 108 | PlaceholderPath: 109 | SDK: AnySDK 110 | - first: 111 | iPhone: iOS 112 | second: 113 | enabled: 0 114 | settings: 115 | CompileFlags: 116 | FrameworkDependencies: 117 | userData: 118 | assetBundleName: 119 | assetBundleVariant: 120 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} 40 | - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} 41 | - {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0} 42 | m_PreloadedShaders: [] 43 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 44 | type: 0} 45 | m_CustomRenderPipeline: {fileID: 0} 46 | m_TransparencySortMode: 0 47 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 48 | m_DefaultRenderingPath: 1 49 | m_DefaultMobileRenderingPath: 1 50 | m_TierSettings: [] 51 | m_LightmapStripping: 0 52 | m_FogStripping: 0 53 | m_InstancingStripping: 0 54 | m_LightmapKeepPlain: 1 55 | m_LightmapKeepDirCombined: 1 56 | m_LightmapKeepDynamicPlain: 1 57 | m_LightmapKeepDynamicDirCombined: 1 58 | m_LightmapKeepShadowMask: 1 59 | m_LightmapKeepSubtractive: 1 60 | m_FogKeepLinear: 1 61 | m_FogKeepExp: 1 62 | m_FogKeepExp2: 1 63 | m_AlbedoSwatchInfos: [] 64 | m_LightsUseLinearIntensity: 0 65 | m_LightsUseColorTemperature: 0 66 | m_LogWhenShaderIsCompiled: 0 67 | m_AllowEnlightenSupportForUpgradedProject: 1 68 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/InternalGlobals.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | #if USE_UNI_LUA 10 | using LuaAPI = UniLua.Lua; 11 | using RealStatePtr = UniLua.ILuaState; 12 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 13 | #else 14 | using LuaAPI = XLua.LuaDLL.Lua; 15 | using RealStatePtr = System.IntPtr; 16 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 17 | #endif 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Reflection; 22 | 23 | namespace XLua 24 | { 25 | internal partial class InternalGlobals 26 | { 27 | #if !THREAD_SAFE && !HOTFIX_ENABLE 28 | internal static byte[] strBuff = new byte[256]; 29 | #endif 30 | 31 | internal delegate bool TryArrayGet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int index); 32 | internal delegate bool TryArraySet(Type type, RealStatePtr L, ObjectTranslator translator, object obj, int array_idx, int obj_idx); 33 | internal static volatile TryArrayGet genTryArrayGetPtr = null; 34 | internal static volatile TryArraySet genTryArraySetPtr = null; 35 | 36 | internal static volatile ObjectTranslatorPool objectTranslatorPool = new ObjectTranslatorPool(); 37 | 38 | internal static volatile int LUA_REGISTRYINDEX = -10000; 39 | 40 | internal static volatile Dictionary supportOp = new Dictionary() 41 | { 42 | { "op_Addition", "__add" }, 43 | { "op_Subtraction", "__sub" }, 44 | { "op_Multiply", "__mul" }, 45 | { "op_Division", "__div" }, 46 | { "op_Equality", "__eq" }, 47 | { "op_UnaryNegation", "__unm" }, 48 | { "op_LessThan", "__lt" }, 49 | { "op_LessThanOrEqual", "__le" }, 50 | { "op_Modulus", "__mod" }, 51 | { "op_BitwiseAnd", "__band" }, 52 | { "op_BitwiseOr", "__bor" }, 53 | { "op_ExclusiveOr", "__bxor" }, 54 | { "op_OnesComplement", "__bnot" }, 55 | { "op_LeftShift", "__shl" }, 56 | { "op_RightShift", "__shr" }, 57 | }; 58 | 59 | internal static volatile Dictionary> extensionMethodMap = null; 60 | 61 | #if GEN_CODE_MINIMIZE 62 | internal static volatile LuaDLL.CSharpWrapperCaller CSharpWrapperCallerPtr = new LuaDLL.CSharpWrapperCaller(StaticLuaCallbacks.CSharpWrapperCallerImpl); 63 | #endif 64 | 65 | internal static volatile LuaCSFunction LazyReflectionWrap = new LuaCSFunction(Utils.LazyReflectionCall); 66 | } 67 | 68 | } 69 | 70 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/tdr/tdr.lua.txt: -------------------------------------------------------------------------------- 1 | -- Tencent is pleased to support the open source community by making xLua available. 2 | -- Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 3 | -- 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 4 | -- http://opensource.org/licenses/MIT 5 | -- 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. 6 | 7 | require "libtdrlua" 8 | local m = {} 9 | for k, v in pairs(libtdrlua) do m[k] = v end 10 | local load_metalib, load_metalib_buf, free_metalib, get_meta, table2buf, buf2table, str2table, metamaxbufsize, bufalloc, buffree, buf2str 11 | load_metalib, m.load_metalib = m.load_metalib, nil 12 | load_metalib_buf, m.load_metalib_buf = m.load_metalib_buf, nil 13 | free_metalib, m.free_metalib = m.free_metalib, nil 14 | get_meta, m.get_meta = m.get_meta, nil 15 | table2buf, m.table2buf = m.table2buf, nil 16 | buf2table, m.buf2table = m.buf2table, nil 17 | str2table, m.str2table = m.str2table, nil 18 | buf2str, m.buf2str = m.buf2str, nil 19 | 20 | metamaxbufsize, m.metamaxbufsize = m.metamaxbufsize, nil 21 | bufalloc, m.bufalloc = m.bufalloc, nil 22 | buffree, m.buffree = m.buffree, nil 23 | 24 | local function create_msg_pk(meta, buf, buf_size) 25 | return { 26 | buff = buf, 27 | pack = function(obj) 28 | local ret_code, used_size = table2buf(meta, obj, buf, buf_size, 0) 29 | if ret_code ~= 0 then 30 | return ret_code, used_size 31 | end 32 | return buf2str(buf, used_size) 33 | end, 34 | unpack = function(str) 35 | return libtdrlua.str2table(meta, str, 0) 36 | end 37 | } 38 | end 39 | 40 | local function create_lib(metalib) 41 | return setmetatable({}, { 42 | __index = function(obj, k) 43 | local ret_code, meta = libtdrlua.get_meta(metalib, k) 44 | if ret_code ~= 0 then 45 | error("libtdrlua.get_meta() failed: errno=".. ret_code .. ",msg=" .. meta) 46 | end 47 | local ret_code, buf_size = libtdrlua.metamaxbufsize(metalib, k) 48 | if ret_code ~= 0 then 49 | error("libtdrlua.metamaxbufsize() failed: errno=".. ret_code .. ",msg=" .. buf_size) 50 | end 51 | 52 | local ret_code, buf = libtdrlua.bufalloc(buf_size) 53 | if ret_code ~= 0 then 54 | error("libtdrlua.bufalloc() failed: errno=".. ret_code .. ",msg=" .. buf) 55 | end 56 | 57 | local pk = create_msg_pk(meta, buf, buf_size) 58 | rawset(obj, k, pk) 59 | return pk 60 | end 61 | }) 62 | end 63 | 64 | function m.from_file(file) 65 | local ret_code, metalib = libtdrlua.load_metalib(file) 66 | if ret_code ~= 0 then 67 | error("libtdrlua.load_metalib() failed: " .. metalib) 68 | end 69 | return create_lib(metalib) 70 | end 71 | 72 | function m.from_memory(str) 73 | local ret_code, metalib = libtdrlua.load_metalib_buf(str) 74 | if ret_code ~= 0 then 75 | error("libtdrlua.load_metalib_buf() failed: errno=".. ret_code .. ",msg=" .. metalib) 76 | end 77 | return create_lib(metalib) 78 | end 79 | 80 | return m -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/ObjectTranslatorPool.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | #if USE_UNI_LUA 10 | using LuaAPI = UniLua.Lua; 11 | using RealStatePtr = UniLua.ILuaState; 12 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 13 | #else 14 | using LuaAPI = XLua.LuaDLL.Lua; 15 | using RealStatePtr = System.IntPtr; 16 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 17 | #endif 18 | 19 | using System.Collections.Generic; 20 | using System; 21 | 22 | namespace XLua 23 | { 24 | public class ObjectTranslatorPool 25 | { 26 | #if !SINGLE_ENV 27 | private Dictionary translators = new Dictionary(); 28 | RealStatePtr lastPtr = default(RealStatePtr); 29 | #endif 30 | ObjectTranslator lastTranslator = default(ObjectTranslator); 31 | 32 | public static ObjectTranslatorPool Instance 33 | { 34 | get 35 | { 36 | return InternalGlobals.objectTranslatorPool; 37 | } 38 | } 39 | 40 | #if UNITY_EDITOR || XLUA_GENERAL 41 | public static ObjectTranslator FindTranslator(RealStatePtr L) 42 | { 43 | return InternalGlobals.objectTranslatorPool.Find(L); 44 | } 45 | #endif 46 | 47 | public ObjectTranslatorPool () 48 | { 49 | } 50 | 51 | public void Add (RealStatePtr L, ObjectTranslator translator) 52 | { 53 | #if THREAD_SAFE || HOTFIX_ENABLE 54 | lock (this) 55 | #endif 56 | { 57 | lastTranslator = translator; 58 | #if !SINGLE_ENV 59 | var ptr = LuaAPI.xlua_gl(L); 60 | lastPtr = ptr; 61 | translators.Add(ptr , new WeakReference(translator)); 62 | #endif 63 | } 64 | } 65 | 66 | public ObjectTranslator Find (RealStatePtr L) 67 | { 68 | #if THREAD_SAFE || HOTFIX_ENABLE 69 | lock (this) 70 | #endif 71 | { 72 | #if SINGLE_ENV 73 | return lastTranslator; 74 | #else 75 | var ptr = LuaAPI.xlua_gl(L); 76 | if (lastPtr == ptr) return lastTranslator; 77 | if (translators.ContainsKey(ptr)) 78 | { 79 | lastPtr = ptr; 80 | lastTranslator = translators[ptr].Target as ObjectTranslator; 81 | return lastTranslator; 82 | } 83 | 84 | return null; 85 | #endif 86 | } 87 | } 88 | 89 | public void Remove (RealStatePtr L) 90 | { 91 | #if THREAD_SAFE || HOTFIX_ENABLE 92 | lock (this) 93 | #endif 94 | { 95 | #if SINGLE_ENV 96 | lastTranslator = default(ObjectTranslator); 97 | #else 98 | var ptr = LuaAPI.xlua_gl(L); 99 | if (!translators.ContainsKey (ptr)) 100 | return; 101 | 102 | if (lastPtr == ptr) 103 | { 104 | lastPtr = default(RealStatePtr); 105 | lastTranslator = default(ObjectTranslator); 106 | } 107 | 108 | translators.Remove(ptr); 109 | #endif 110 | } 111 | } 112 | } 113 | } 114 | 115 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaEnumWrapGCM.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using XLua; 12 | using System.Collections.Generic; 13 | <% 14 | require "TemplateCommon" 15 | local enum_or_op = debug.getmetatable(CS.System.Reflection.BindingFlags.Public).__bor 16 | %> 17 | 18 | namespace XLua 19 | { 20 | public partial class ObjectTranslator 21 | { 22 | <%ForEachCsList(types, function(type) 23 | local fields = type2fields and type2fields[type] or type:GetFields(enum_or_op(CS.System.Reflection.BindingFlags.Public, CS.System.Reflection.BindingFlags.Static)) 24 | local fields_to_gen = {} 25 | ForEachCsList(fields, function(field) 26 | if field.Name ~= "value__" and not IsObsolute(field) then 27 | table.insert(fields_to_gen, field) 28 | end 29 | end) 30 | local v_type_name = CSVariableName(type) 31 | %> 32 | public void __Register<%=v_type_name%>(RealStatePtr L) 33 | { 34 | Utils.BeginObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, this, 0, 0, 0, 0); 35 | Utils.EndObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, this, null, null, null, null, null); 36 | 37 | Utils.BeginClassRegister(typeof(<%=CsFullTypeName(type)%>), L, null, <%=fields.Length + 1%>, 0, 0); 38 | <%if #fields_to_gen <= 20 then%> 39 | <% ForEachCsList(fields, function(field) 40 | if field.Name == "value__" or IsObsolute(field) then return end 41 | %> 42 | Utils.RegisterObject(L, this, Utils.CLS_IDX, "<%=field.Name%>", <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>); 43 | <%end)%> 44 | <%else%> 45 | foreach(var e in System.Enum.GetValues(typeof(<%=CsFullTypeName(type)%>))) 46 | { 47 | Utils.RegisterObject(L, translator, Utils.CLS_IDX, e.ToString(), e); 48 | } 49 | <%end%> 50 | Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom<%=v_type_name%>); 51 | 52 | Utils.EndClassRegister(typeof(<%=CsFullTypeName(type)%>), L, this); 53 | } 54 | 55 | int __CastFrom<%=v_type_name%>(RealStatePtr L, int __gen_top) 56 | { 57 | LuaTypes lua_type = LuaAPI.lua_type(L, 1); 58 | if (lua_type == LuaTypes.LUA_TNUMBER) 59 | { 60 | Push<%=v_type_name%>(L, (<%=CsFullTypeName(type)%>)LuaAPI.xlua_tointeger(L, 1)); 61 | } 62 | <%if #fields_to_gen > 0 then%> 63 | else if(lua_type == LuaTypes.LUA_TSTRING) 64 | { 65 | <%if #fields_to_gen <= 20 then%> 66 | <% 67 | local is_first = true 68 | ForEachCsList(fields, function(field, i) 69 | if field.Name == "value__" or IsObsolute(field) then return end 70 | %><%=(is_first and "" or "else ")%>if (LuaAPI.xlua_is_eq_str(L, 1, "<%=field.Name%>")) 71 | { 72 | Push<%=v_type_name%>(L, <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>); 73 | } 74 | <% 75 | is_first = false 76 | end) 77 | %>else 78 | { 79 | return LuaAPI.luaL_error(L, "invalid string for <%=CsFullTypeName(type)%>!"); 80 | } 81 | <%else%> 82 | try 83 | { 84 | translator.TranslateToEnumToTop(L, typeof(<%=CsFullTypeName(type)%>), 1); 85 | } 86 | catch (System.Exception e) 87 | { 88 | return LuaAPI.luaL_error(L, "cast to " + typeof(<%=CsFullTypeName(type)%>) + " exception:" + e); 89 | } 90 | <%end%> 91 | } 92 | <%end%> 93 | else 94 | { 95 | return LuaAPI.luaL_error(L, "invalid lua type for <%=CsFullTypeName(type)%>! Expect number or string, got + " + lua_type); 96 | } 97 | 98 | return 1; 99 | } 100 | <%end)%> 101 | } 102 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaDelegateBridge.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using System; 12 | <% 13 | require "TemplateCommon" 14 | %> 15 | 16 | namespace XLua 17 | { 18 | public partial class DelegateBridge : DelegateBridgeBase 19 | { 20 | <% 21 | ForEachCsList(delegates_groups, function(delegates_group, group_idx) 22 | local delegate = delegates_group.Key 23 | local parameters = delegate:GetParameters() 24 | local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end) 25 | local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end) 26 | local in_pos = 0 27 | local has_return = (delegate.ReturnType.FullName ~= "System.Void") 28 | local return_type_name = has_return and CsFullTypeName(delegate.ReturnType) or "void" 29 | local out_idx = has_return and 2 or 1 30 | if has_return then out_num = out_num + 1 end 31 | %> 32 | public <%=return_type_name%> __Gen_Delegate_Imp<%=group_idx%>(<%ForEachCsList(parameters, function(parameter, pi) 33 | if pi ~= 0 then 34 | %>, <% 35 | end 36 | if parameter.IsOut and parameter.ParameterType.IsByRef then 37 | %>out <% 38 | elseif parameter.ParameterType.IsByRef then 39 | %>ref <% 40 | end 41 | %><%=CsFullTypeName(parameter.ParameterType)%> p<%=pi%><% 42 | end) %>) 43 | { 44 | #if THREAD_SAFE || HOTFIX_ENABLE 45 | lock (luaEnv.luaEnvLock) 46 | { 47 | #endif 48 | RealStatePtr L = luaEnv.rawL; 49 | int errFunc = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference); 50 | <%if CallNeedTranslator(delegate, "") then %>ObjectTranslator translator = luaEnv.translator;<%end%> 51 | <% 52 | local param_count = parameters.Length 53 | local has_v_params = param_count > 0 and parameters[param_count - 1].IsParamArray 54 | ForEachCsList(parameters, function(parameter, pi) 55 | if not (parameter.IsOut and parameter.ParameterType.IsByRef) then 56 | %><%=GetPushStatement(parameter.ParameterType, 'p' .. pi, has_v_params and pi == param_count - 1)%>; 57 | <% 58 | end 59 | end) %> 60 | PCall(L, <%=has_v_params and ((in_num - 1) .. " + (p".. (param_count - 1) .. " == null ? 0 : p" .. (param_count - 1) .. ".Length)" ) or in_num%>, <%=out_num%>, errFunc); 61 | 62 | <%ForEachCsList(parameters, function(parameter, pi) 63 | if parameter.IsOut or parameter.ParameterType.IsByRef then 64 | %><%=GetCasterStatement(parameter.ParameterType, "errFunc" .. (" + "..out_idx), 'p' .. pi)%>; 65 | <% 66 | out_idx = out_idx + 1 67 | end 68 | end) %> 69 | <%if has_return then %><%=GetCasterStatement(delegate.ReturnType, "errFunc + 1", "__gen_ret", true)%>;<% end%> 70 | LuaAPI.lua_settop(L, errFunc - 1); 71 | <%if has_return then %>return __gen_ret;<% end%> 72 | #if THREAD_SAFE || HOTFIX_ENABLE 73 | } 74 | #endif 75 | } 76 | <%end)%> 77 | 78 | static DelegateBridge() 79 | { 80 | Gen_Flag = true; 81 | } 82 | 83 | public override Delegate GetDelegateByType(Type type) 84 | { 85 | <% 86 | ForEachCsList(delegates_groups, function(delegates_group, group_idx) 87 | ForEachCsList(delegates_group.Value, function(delegate) 88 | if delegate.DeclaringType then 89 | local delegate_type_name = CsFullTypeName(delegate.DeclaringType) 90 | %> 91 | if (type == typeof(<%=delegate_type_name%>)) 92 | { 93 | return new <%=delegate_type_name%>(__Gen_Delegate_Imp<%=group_idx%>); 94 | } 95 | <% 96 | end 97 | end) 98 | end) 99 | %> 100 | return null; 101 | } 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaEnumWrap.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using XLua; 12 | using System.Collections.Generic; 13 | <% 14 | require "TemplateCommon" 15 | local enum_or_op = debug.getmetatable(CS.System.Reflection.BindingFlags.Public).__bor 16 | %> 17 | 18 | namespace XLua.CSObjectWrap 19 | { 20 | using Utils = XLua.Utils; 21 | <%ForEachCsList(types, function(type) 22 | local fields = type2fields and type2fields[type] or type:GetFields(enum_or_op(CS.System.Reflection.BindingFlags.Public, CS.System.Reflection.BindingFlags.Static)) 23 | local fields_to_gen = {} 24 | ForEachCsList(fields, function(field) 25 | if field.Name ~= "value__" and not IsObsolute(field) then 26 | table.insert(fields_to_gen, field) 27 | end 28 | end) 29 | %> 30 | public class <%=CSVariableName(type)%>Wrap 31 | { 32 | public static void __Register(RealStatePtr L) 33 | { 34 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); 35 | Utils.BeginObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, 0, 0, 0, 0); 36 | Utils.EndObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, null, null, null, null, null); 37 | 38 | Utils.BeginClassRegister(typeof(<%=CsFullTypeName(type)%>), L, null, <%=fields.Length + 1%>, 0, 0); 39 | <%if #fields_to_gen <= 20 then%> 40 | <% ForEachCsList(fields, function(field) 41 | if field.Name == "value__" or IsObsolute(field) then return end 42 | %> 43 | Utils.RegisterObject(L, translator, Utils.CLS_IDX, "<%=field.Name%>", <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>); 44 | <%end)%> 45 | <%else%> 46 | foreach(var e in System.Enum.GetValues(typeof(<%=CsFullTypeName(type)%>))) 47 | { 48 | Utils.RegisterObject(L, translator, Utils.CLS_IDX, e.ToString(), e); 49 | } 50 | <%end%> 51 | Utils.RegisterFunc(L, Utils.CLS_IDX, "__CastFrom", __CastFrom); 52 | 53 | Utils.EndClassRegister(typeof(<%=CsFullTypeName(type)%>), L, translator); 54 | } 55 | 56 | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] 57 | static int __CastFrom(RealStatePtr L) 58 | { 59 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); 60 | LuaTypes lua_type = LuaAPI.lua_type(L, 1); 61 | if (lua_type == LuaTypes.LUA_TNUMBER) 62 | { 63 | translator.Push<%=CSVariableName(type)%>(L, (<%=CsFullTypeName(type)%>)LuaAPI.xlua_tointeger(L, 1)); 64 | } 65 | <%if #fields_to_gen > 0 then%> 66 | else if(lua_type == LuaTypes.LUA_TSTRING) 67 | { 68 | <%if #fields_to_gen <= 20 then%> 69 | <% 70 | local is_first = true 71 | ForEachCsList(fields, function(field, i) 72 | if field.Name == "value__" or IsObsolute(field) then return end 73 | %><%=(is_first and "" or "else ")%>if (LuaAPI.xlua_is_eq_str(L, 1, "<%=field.Name%>")) 74 | { 75 | translator.Push<%=CSVariableName(type)%>(L, <%=CsFullTypeName(type)%>.<%=UnK(field.Name)%>); 76 | } 77 | <% 78 | is_first = false 79 | end) 80 | %>else 81 | { 82 | return LuaAPI.luaL_error(L, "invalid string for <%=CsFullTypeName(type)%>!"); 83 | } 84 | <%else%> 85 | try 86 | { 87 | translator.TranslateToEnumToTop(L, typeof(<%=CsFullTypeName(type)%>), 1); 88 | } 89 | catch (System.Exception e) 90 | { 91 | return LuaAPI.luaL_error(L, "cast to " + typeof(<%=CsFullTypeName(type)%>) + " exception:" + e); 92 | } 93 | <%end%> 94 | } 95 | <%end%> 96 | else 97 | { 98 | return LuaAPI.luaL_error(L, "invalid lua type for <%=CsFullTypeName(type)%>! Expect number or string, got + " + lua_type); 99 | } 100 | 101 | return 1; 102 | } 103 | } 104 | <%end)%> 105 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/LuaBase.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | #if USE_UNI_LUA 10 | using LuaAPI = UniLua.Lua; 11 | using RealStatePtr = UniLua.ILuaState; 12 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 13 | #else 14 | using LuaAPI = XLua.LuaDLL.Lua; 15 | using RealStatePtr = System.IntPtr; 16 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 17 | #endif 18 | 19 | using System; 20 | 21 | namespace XLua 22 | { 23 | public abstract class LuaBase : IDisposable 24 | { 25 | protected bool disposed; 26 | protected readonly int luaReference; 27 | protected readonly LuaEnv luaEnv; 28 | 29 | #if UNITY_EDITOR || XLUA_GENERAL 30 | protected int _errorFuncRef { get { return luaEnv.errorFuncRef; } } 31 | protected RealStatePtr _L { get { return luaEnv.L; } } 32 | protected ObjectTranslator _translator { get { return luaEnv.translator; } } 33 | #endif 34 | 35 | public LuaBase(int reference, LuaEnv luaenv) 36 | { 37 | luaReference = reference; 38 | luaEnv = luaenv; 39 | } 40 | 41 | ~LuaBase() 42 | { 43 | Dispose(false); 44 | } 45 | 46 | public void Dispose() 47 | { 48 | Dispose(true); 49 | GC.SuppressFinalize(this); 50 | } 51 | 52 | public virtual void Dispose(bool disposeManagedResources) 53 | { 54 | if (!disposed) 55 | { 56 | if (luaReference != 0) 57 | { 58 | #if THREAD_SAFE || HOTFIX_ENABLE 59 | lock (luaEnv.luaEnvLock) 60 | { 61 | #endif 62 | bool is_delegate = this is DelegateBridgeBase; 63 | if (disposeManagedResources) 64 | { 65 | luaEnv.translator.ReleaseLuaBase(luaEnv.L, luaReference, is_delegate); 66 | } 67 | else //will dispse by LuaEnv.GC 68 | { 69 | luaEnv.equeueGCAction(new LuaEnv.GCAction { Reference = luaReference, IsDelegate = is_delegate }); 70 | } 71 | #if THREAD_SAFE || HOTFIX_ENABLE 72 | } 73 | #endif 74 | } 75 | disposed = true; 76 | } 77 | } 78 | 79 | public override bool Equals(object o) 80 | { 81 | if (o != null && this.GetType() == o.GetType()) 82 | { 83 | #if THREAD_SAFE || HOTFIX_ENABLE 84 | lock (luaEnv.luaEnvLock) 85 | { 86 | #endif 87 | LuaBase rhs = (LuaBase)o; 88 | var L = luaEnv.L; 89 | if (L != rhs.luaEnv.L) 90 | return false; 91 | int top = LuaAPI.lua_gettop(L); 92 | LuaAPI.lua_getref(L, rhs.luaReference); 93 | LuaAPI.lua_getref(L, luaReference); 94 | int equal = LuaAPI.lua_rawequal(L, -1, -2); 95 | LuaAPI.lua_settop(L, top); 96 | return (equal != 0); 97 | #if THREAD_SAFE || HOTFIX_ENABLE 98 | } 99 | #endif 100 | } 101 | else return false; 102 | } 103 | 104 | public override int GetHashCode() 105 | { 106 | LuaAPI.lua_getref(luaEnv.L, luaReference); 107 | var pointer = LuaAPI.lua_topointer(luaEnv.L, -1); 108 | LuaAPI.lua_pop(luaEnv.L, 1); 109 | return pointer.ToInt32(); 110 | } 111 | 112 | internal virtual void push(RealStatePtr L) 113 | { 114 | LuaAPI.lua_getref(L, luaReference); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/perf/profiler.lua.txt: -------------------------------------------------------------------------------- 1 | -- Tencent is pleased to support the open source community by making xLua available. 2 | -- Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 3 | -- 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 4 | -- http://opensource.org/licenses/MIT 5 | -- 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. 6 | 7 | local get_time = os.clock 8 | local sethook = xlua.sethook or debug.sethook 9 | local func_info_map = nil 10 | 11 | local start_time 12 | 13 | local function create_func_info(db_info) 14 | return { 15 | db_info = db_info, 16 | count = 0, 17 | total_time = 0 18 | } 19 | end 20 | 21 | local function on_hook(event, func_info_id, source) 22 | local func_info = func_info_map[func_info_id] 23 | if not func_info then 24 | func_info = create_func_info(debug.getinfo( 2, 'nS' )) 25 | func_info_map[func_info_id] = func_info 26 | end 27 | if event == "call" then 28 | func_info.call_time = get_time() 29 | func_info.count = func_info.count + 1 30 | func_info.return_time = nil 31 | elseif event == "return" or event == 'tail return' then 32 | local now = get_time() 33 | if func_info.call_time then 34 | func_info.total_time = func_info.total_time + (now - func_info.call_time) 35 | func_info.call_time = nil 36 | else 37 | func_info.total_time = func_info.total_time + (now - (func_info.return_time or now)) 38 | func_info.count = func_info.count + 1 39 | end 40 | func_info.return_time = now 41 | if source and func_info.count == 1 then 42 | func_info.db_info.short_src = source 43 | end 44 | end 45 | end 46 | 47 | local function start() 48 | func_info_map = {} 49 | start_time = get_time() 50 | sethook(on_hook, 'cr') 51 | end 52 | 53 | local function pause() 54 | sethook() 55 | end 56 | 57 | local function resume() 58 | sethook(on_hook, 'cr') 59 | end 60 | 61 | local function stop() 62 | sethook() 63 | func_info_map = nil 64 | start_time = nil 65 | end 66 | 67 | local function report_output_line(rp, stat_interval) 68 | local source = rp.db_info.short_src or '[NA]' 69 | local linedefined = (rp.db_info.linedefined and rp.db_info.linedefined >= 0) and string.format(":%i", rp.db_info.linedefined) or '' 70 | source = source .. linedefined 71 | local name = rp.db_info.name or '[anonymous]' 72 | local total_time = string.format("%04.3f", rp.total_time * 1000) 73 | local average_time = string.format("%04.3f", rp.total_time / rp.count * 1000) 74 | local relative_time = string.format("%03.2f%%", (rp.total_time / stat_interval) * 100 ) 75 | local count = string.format("%7i", rp.count) 76 | 77 | return string.format("|%-40.40s: %-50.50s: %-12s: %-12s: %-12s: %-12s|\n", name, source, total_time, average_time, relative_time, count) 78 | end 79 | 80 | local sort_funcs = { 81 | TOTAL = function(a, b) return a.total_time > b.total_time end, 82 | AVERAGE = function(a, b) return a.average > b.average end, 83 | CALLED = function(a, b) return a.count > b.count end 84 | } 85 | 86 | local function report(sort_by) 87 | sethook() 88 | local sort_func = type(sort_by) == 'function' and sort_by or sort_funcs[sort_by] 89 | 90 | local FORMAT_HEADER_LINE = "|%-40s: %-50s: %-12s: %-12s: %-12s: %-12s|\n" 91 | local header = string.format( FORMAT_HEADER_LINE, "FUNCTION", "SOURCE", "TOTAL(MS)", "AVERAGE(MS)", "RELATIVE", "CALLED" ) 92 | local stat_interval = get_time() - (start_time or get_time()) 93 | 94 | local report_list = {} 95 | for _, rp in pairs(func_info_map) do 96 | table.insert(report_list, { 97 | total_time = rp.total_time, 98 | count = rp.count, 99 | average = rp.total_time / rp.count, 100 | output = report_output_line(rp, stat_interval) 101 | }) 102 | end 103 | 104 | table.sort(report_list, sort_func or sort_funcs.TOTAL) 105 | 106 | local output = header 107 | 108 | for i, rp in ipairs(report_list) do 109 | output = output .. rp.output 110 | end 111 | 112 | sethook(on_hook, 'cr') 113 | 114 | return output 115 | end 116 | 117 | return { 118 | --开始统计 119 | start = start, 120 | --获取报告,start和stop之间可以多次调用,参数sort_by类型是string,可以是'TOTAL','AVERAGE', 'CALLED' 121 | report = report, 122 | --停止统计 123 | stop = stop 124 | } 125 | 126 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/PackUnpack.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using System; 12 | <% 13 | require "TemplateCommon" 14 | %> 15 | 16 | namespace XLua 17 | { 18 | public static partial class CopyByValue 19 | { 20 | <%ForEachCsList(type_infos, function(type_info) 21 | local full_type_name = CsFullTypeName(type_info.Type) 22 | %> 23 | <%if type_info.IsRoot then 24 | ForEachCsList(type_info.FieldInfos, function(fieldInfo) fieldInfo.Name = UnK(fieldInfo.Name) end) 25 | %> 26 | public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out <%=full_type_name%> val) 27 | { 28 | val = new <%=full_type_name%>(); 29 | int top = LuaAPI.lua_gettop(L); 30 | <%ForEachCsList(type_info.FieldInfos, function(fieldInfo)%> 31 | if (Utils.LoadField(L, idx, "<%=fieldInfo.Name%>")) 32 | { 33 | <%if fieldInfo.IsField then%> 34 | translator.Get(L, top + 1, out val.<%=fieldInfo.Name%>); 35 | <%else%> 36 | var <%=fieldInfo.Name%> = val.<%=fieldInfo.Name%>; 37 | translator.Get(L, top + 1, out <%=fieldInfo.Name%>); 38 | val.<%=fieldInfo.Name%> = <%=fieldInfo.Name%>; 39 | <%end%> 40 | } 41 | LuaAPI.lua_pop(L, 1); 42 | <%end)%> 43 | } 44 | <%end%> 45 | public static bool Pack(IntPtr buff, int offset, <%=full_type_name%> field) 46 | { 47 | <% 48 | local offset_inner = 0 49 | if not type_info.FieldGroup then 50 | ForEachCsList(type_info.FieldInfos, function(fieldInfo) 51 | %> 52 | if(!Pack(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%>, field.<%=fieldInfo.Name%>)) 53 | { 54 | return false; 55 | } 56 | <% 57 | offset_inner = offset_inner + fieldInfo.Size 58 | end) 59 | else 60 | ForEachCsList(type_info.FieldGroup, function(group) 61 | %> 62 | if(!LuaAPI.xlua_pack_float<%=(group.Count == 1 and "" or group.Count)%>(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%><% 63 | ForEachCsList(group, function(fieldInfo, i) 64 | %>, field.<%=fieldInfo.Name%><% 65 | end) 66 | %>)) 67 | { 68 | return false; 69 | } 70 | <% 71 | offset_inner = offset_inner + group.Count * 4 72 | end) 73 | end%> 74 | return true; 75 | } 76 | public static bool UnPack(IntPtr buff, int offset, out <%=full_type_name%> field) 77 | { 78 | field = default(<%=full_type_name%>); 79 | <% 80 | local offset_inner = 0 81 | if not type_info.FieldGroup then 82 | ForEachCsList(type_info.FieldInfos, function(fieldInfo) 83 | if fieldInfo.IsField then 84 | %> 85 | if(!UnPack(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%>, out field.<%=fieldInfo.Name%>)) 86 | { 87 | return false; 88 | } 89 | <%else%> 90 | var <%=fieldInfo.Name%> = field.<%=fieldInfo.Name%>; 91 | if(!UnPack(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%>, out <%=fieldInfo.Name%>)) 92 | { 93 | return false; 94 | } 95 | field.<%=fieldInfo.Name%> = <%=fieldInfo.Name%>; 96 | <% 97 | end 98 | offset_inner = offset_inner + fieldInfo.Size 99 | end) 100 | else 101 | ForEachCsList(type_info.FieldGroup, function(group) 102 | %> 103 | <%ForEachCsList(group, function(fieldInfo)%>float <%=fieldInfo.Name%> = default(float); 104 | <%end)%> 105 | if(!LuaAPI.xlua_unpack_float<%=(group.Count == 1 and "" or group.Count)%>(buff, offset<%=(offset_inner == 0 and "" or (" + " .. offset_inner))%><% 106 | ForEachCsList(group, function(fieldInfo) 107 | %>, out <%=fieldInfo.Name%><% 108 | end) 109 | %>)) 110 | { 111 | return false; 112 | } 113 | <%ForEachCsList(group, function(fieldInfo)%>field.<%=fieldInfo.Name%> = <%=fieldInfo.Name%>; 114 | <%end)%> 115 | <% 116 | offset_inner = offset_inner + group.Count * 4 117 | end) 118 | end%> 119 | return true; 120 | } 121 | <%end)%> 122 | } 123 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/TypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace XLua 6 | { 7 | 8 | internal static class TypeExtensions 9 | { 10 | public static bool IsValueType(this Type type) 11 | { 12 | #if !UNITY_WSA || UNITY_EDITOR 13 | return type.IsValueType; 14 | #else 15 | return type.GetTypeInfo().IsValueType; 16 | #endif 17 | } 18 | 19 | public static bool IsEnum(this Type type) 20 | { 21 | #if !UNITY_WSA || UNITY_EDITOR 22 | return type.IsEnum; 23 | #else 24 | return type.GetTypeInfo().IsEnum; 25 | #endif 26 | } 27 | 28 | public static bool IsPrimitive(this Type type) 29 | { 30 | #if !UNITY_WSA || UNITY_EDITOR 31 | return type.IsPrimitive; 32 | #else 33 | return type.GetTypeInfo().IsPrimitive; 34 | #endif 35 | } 36 | 37 | public static bool IsAbstract(this Type type) 38 | { 39 | #if !UNITY_WSA || UNITY_EDITOR 40 | return type.IsAbstract; 41 | #else 42 | return type.GetTypeInfo().IsAbstract; 43 | #endif 44 | } 45 | 46 | public static bool IsSealed(this Type type) 47 | { 48 | #if !UNITY_WSA || UNITY_EDITOR 49 | return type.IsSealed; 50 | #else 51 | return type.GetTypeInfo().IsSealed; 52 | #endif 53 | } 54 | 55 | public static bool IsInterface(this Type type) 56 | { 57 | #if !UNITY_WSA || UNITY_EDITOR 58 | return type.IsInterface; 59 | #else 60 | return type.GetTypeInfo().IsInterface; 61 | #endif 62 | } 63 | 64 | public static bool IsClass(this Type type) 65 | { 66 | #if !UNITY_WSA || UNITY_EDITOR 67 | return type.IsClass; 68 | #else 69 | return type.GetTypeInfo().IsClass; 70 | #endif 71 | } 72 | 73 | public static Type BaseType(this Type type) 74 | { 75 | #if !UNITY_WSA || UNITY_EDITOR 76 | return type.BaseType; 77 | #else 78 | return type.GetTypeInfo().BaseType; 79 | #endif 80 | } 81 | 82 | public static bool IsGenericType(this Type type) 83 | { 84 | #if !UNITY_WSA || UNITY_EDITOR 85 | return type.IsGenericType; 86 | #else 87 | return type.GetTypeInfo().IsGenericType; 88 | #endif 89 | } 90 | 91 | public static bool IsGenericTypeDefinition(this Type type) 92 | { 93 | #if !UNITY_WSA || UNITY_EDITOR 94 | return type.IsGenericTypeDefinition; 95 | #else 96 | return type.GetTypeInfo().IsGenericTypeDefinition; 97 | #endif 98 | } 99 | 100 | #if UNITY_WSA && !UNITY_EDITOR 101 | public static bool IsSubclassOf(this Type type, Type c) 102 | { 103 | return type.GetTypeInfo().IsSubclassOf(c); 104 | } 105 | 106 | public static bool IsDefined(this Type type, Type attributeType, bool inherit) 107 | { 108 | return type.GetTypeInfo().IsDefined(attributeType, inherit); 109 | } 110 | 111 | public static Type[] GetGenericParameterConstraints(this Type type) 112 | { 113 | return type.GetTypeInfo().GetGenericParameterConstraints(); 114 | } 115 | #endif 116 | 117 | public static bool IsNestedPublic(this Type type) 118 | { 119 | #if !UNITY_WSA || UNITY_EDITOR 120 | return type.IsNestedPublic; 121 | #else 122 | return type.GetTypeInfo().IsNestedPublic; 123 | #endif 124 | } 125 | 126 | public static bool IsPublic(this Type type) 127 | { 128 | #if !UNITY_WSA || UNITY_EDITOR 129 | return type.IsPublic; 130 | #else 131 | return type.GetTypeInfo().IsPublic; 132 | #endif 133 | } 134 | 135 | public static string GetFriendlyName(this Type type) 136 | { 137 | if (type == typeof(int)) 138 | return "int"; 139 | else if (type == typeof(short)) 140 | return "short"; 141 | else if (type == typeof(byte)) 142 | return "byte"; 143 | else if (type == typeof(bool)) 144 | return "bool"; 145 | else if (type == typeof(long)) 146 | return "long"; 147 | else if (type == typeof(float)) 148 | return "float"; 149 | else if (type == typeof(double)) 150 | return "double"; 151 | else if (type == typeof(decimal)) 152 | return "decimal"; 153 | else if (type == typeof(string)) 154 | return "string"; 155 | else if (type.IsGenericType()) 156 | return type.FullName.Split('`')[0] + "<" + string.Join(", ", type.GetGenericArguments() 157 | .Select(x => GetFriendlyName(x)).ToArray()) + ">"; 158 | else 159 | return type.FullName; 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/GenAttributes.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | 12 | namespace XLua 13 | { 14 | public enum GenFlag 15 | { 16 | No = 0, 17 | [Obsolete("use GCOptimizeAttribute instead")] 18 | GCOptimize = 1 19 | } 20 | 21 | //如果你要生成Lua调用CSharp的代码,加这个标签 22 | public class LuaCallCSharpAttribute : Attribute 23 | { 24 | GenFlag flag; 25 | public GenFlag Flag { 26 | get 27 | { 28 | return flag; 29 | } 30 | } 31 | 32 | public LuaCallCSharpAttribute(GenFlag flag = GenFlag.No) 33 | { 34 | this.flag = flag; 35 | } 36 | } 37 | 38 | //生成CSharp调用Lua,加这标签 39 | //[AttributeUsage(AttributeTargets.Delegate | AttributeTargets.Interface)] 40 | public class CSharpCallLuaAttribute : Attribute 41 | { 42 | } 43 | 44 | //如果某属性、方法不需要生成,加这个标签 45 | public class BlackListAttribute : Attribute 46 | { 47 | 48 | } 49 | 50 | [Flags] 51 | public enum OptimizeFlag 52 | { 53 | Default = 0, 54 | PackAsTable = 1 55 | } 56 | 57 | //如果想对struct生成免GC代码,加这个标签 58 | public class GCOptimizeAttribute : Attribute 59 | { 60 | OptimizeFlag flag; 61 | public OptimizeFlag Flag 62 | { 63 | get 64 | { 65 | return flag; 66 | } 67 | } 68 | 69 | public GCOptimizeAttribute(OptimizeFlag flag = OptimizeFlag.Default) 70 | { 71 | this.flag = flag; 72 | } 73 | } 74 | 75 | //如果想在反射下使用,加这个标签 76 | public class ReflectionUseAttribute : Attribute 77 | { 78 | 79 | } 80 | 81 | //只能标注Dictionary>的field或者property 82 | public class DoNotGenAttribute : Attribute 83 | { 84 | 85 | } 86 | 87 | public class AdditionalPropertiesAttribute : Attribute 88 | { 89 | 90 | } 91 | 92 | [Flags] 93 | public enum HotfixFlag 94 | { 95 | Stateless = 0, 96 | [Obsolete("use xlua.util.state instead!", true)] 97 | Stateful = 1, 98 | ValueTypeBoxing = 2, 99 | IgnoreProperty = 4, 100 | IgnoreNotPublic = 8, 101 | Inline = 16, 102 | IntKey = 32, 103 | AdaptByDelegate = 64, 104 | IgnoreCompilerGenerated = 128, 105 | NoBaseProxy = 256, 106 | } 107 | 108 | public class HotfixAttribute : Attribute 109 | { 110 | HotfixFlag flag; 111 | public HotfixFlag Flag 112 | { 113 | get 114 | { 115 | return flag; 116 | } 117 | } 118 | 119 | public HotfixAttribute(HotfixFlag e = HotfixFlag.Stateless) 120 | { 121 | flag = e; 122 | } 123 | } 124 | 125 | [AttributeUsage(AttributeTargets.Delegate)] 126 | internal class HotfixDelegateAttribute : Attribute 127 | { 128 | } 129 | 130 | #if !XLUA_GENERAL 131 | public static class SysGenConfig 132 | { 133 | [GCOptimize] 134 | static List GCOptimize 135 | { 136 | get 137 | { 138 | return new List() { 139 | typeof(UnityEngine.Vector2), 140 | typeof(UnityEngine.Vector3), 141 | typeof(UnityEngine.Vector4), 142 | typeof(UnityEngine.Color), 143 | typeof(UnityEngine.Quaternion), 144 | typeof(UnityEngine.Ray), 145 | typeof(UnityEngine.Bounds), 146 | typeof(UnityEngine.Ray2D), 147 | }; 148 | } 149 | } 150 | 151 | [AdditionalProperties] 152 | static Dictionary> AdditionalProperties 153 | { 154 | get 155 | { 156 | return new Dictionary>() 157 | { 158 | { typeof(UnityEngine.Ray), new List() { "origin", "direction" } }, 159 | { typeof(UnityEngine.Ray2D), new List() { "origin", "direction" } }, 160 | { typeof(UnityEngine.Bounds), new List() { "center", "extents" } }, 161 | }; 162 | } 163 | } 164 | } 165 | #endif 166 | } 167 | 168 | 169 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/ObjectPool.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | using System; 10 | using System.Collections; 11 | using System.Collections.Generic; 12 | 13 | namespace XLua 14 | { 15 | public class ObjectPool 16 | { 17 | const int LIST_END = -1; 18 | const int ALLOCED = -2; 19 | struct Slot 20 | { 21 | public int next; 22 | public object obj; 23 | 24 | public Slot(int next, object obj) 25 | { 26 | this.next = next; 27 | this.obj = obj; 28 | } 29 | } 30 | 31 | private Slot[] list = new Slot[512]; 32 | private int freelist = LIST_END; 33 | private int count = 0; 34 | 35 | public object this[int i] 36 | { 37 | get 38 | { 39 | if (i >= 0 && i < count) 40 | { 41 | return list[i].obj; 42 | } 43 | 44 | return null; 45 | } 46 | } 47 | 48 | public void Clear() 49 | { 50 | freelist = LIST_END; 51 | count = 0; 52 | list = new Slot[512]; 53 | } 54 | 55 | void extend_capacity() 56 | { 57 | Slot[] new_list = new Slot[list.Length * 2]; 58 | for (int i = 0; i < list.Length; i++) 59 | { 60 | new_list[i] = list[i]; 61 | } 62 | list = new_list; 63 | } 64 | 65 | public int Add(object obj) 66 | { 67 | int index = LIST_END; 68 | 69 | if (freelist != LIST_END) 70 | { 71 | index = freelist; 72 | list[index].obj = obj; 73 | freelist = list[index].next; 74 | list[index].next = ALLOCED; 75 | } 76 | else 77 | { 78 | if (count == list.Length) 79 | { 80 | extend_capacity(); 81 | } 82 | index = count; 83 | list[index] = new Slot(ALLOCED, obj); 84 | count = index + 1; 85 | } 86 | 87 | return index; 88 | } 89 | 90 | public bool TryGetValue(int index, out object obj) 91 | { 92 | if (index >= 0 && index < count && list[index].next == ALLOCED) 93 | { 94 | obj = list[index].obj; 95 | return true; 96 | } 97 | 98 | obj = null; 99 | return false; 100 | } 101 | 102 | public object Get(int index) 103 | { 104 | if (index >= 0 && index < count) 105 | { 106 | return list[index].obj; 107 | } 108 | return null; 109 | } 110 | 111 | public object Remove(int index) 112 | { 113 | if (index >= 0 && index < count && list[index].next == ALLOCED) 114 | { 115 | object o = list[index].obj; 116 | list[index].obj = null; 117 | list[index].next = freelist; 118 | freelist = index; 119 | return o; 120 | } 121 | 122 | return null; 123 | } 124 | 125 | public object Replace(int index, object o) 126 | { 127 | if (index >= 0 && index < count) 128 | { 129 | object obj = list[index].obj; 130 | list[index].obj = o; 131 | return obj; 132 | } 133 | 134 | return null; 135 | } 136 | 137 | public int Check(int check_pos, int max_check, Func checker, Dictionary reverse_map) 138 | { 139 | if (count == 0) 140 | { 141 | return 0; 142 | } 143 | for (int i = 0; i < Math.Min(max_check, count); ++i) 144 | { 145 | check_pos %= count; 146 | if (list[check_pos].next == ALLOCED && !Object.ReferenceEquals(list[check_pos].obj, null)) 147 | { 148 | if (!checker(list[check_pos].obj)) 149 | { 150 | object obj = Replace(check_pos, null); 151 | int obj_index; 152 | if (reverse_map.TryGetValue(obj, out obj_index) && obj_index == check_pos) 153 | { 154 | reverse_map.Remove(obj); 155 | } 156 | } 157 | } 158 | ++check_pos; 159 | } 160 | 161 | return check_pos %= count; 162 | } 163 | } 164 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaRegister.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Reflection; 14 | <% 15 | require "TemplateCommon" 16 | %> 17 | 18 | namespace XLua.CSObjectWrap 19 | { 20 | public class XLua_Gen_Initer_Register__ 21 | { 22 | <% 23 | local split_method_perfix = 'wrapInit' 24 | local split_method_count = 0 25 | local wrap_in_split_method = 0 26 | local max_wrap_in_split_method = 50 27 | %> 28 | <%ForEachCsList(wraps, function(wrap)%> 29 | <%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator) 30 | { 31 | <%end%> 32 | translator.DelayWrapLoader(typeof(<%=CsFullTypeName(wrap)%>), <%=CSVariableName(wrap)%>Wrap.__Register); 33 | <%if wrap_in_split_method == max_wrap_in_split_method then 34 | wrap_in_split_method = 0 35 | split_method_count = split_method_count + 1 36 | %> 37 | } 38 | <%else 39 | wrap_in_split_method = wrap_in_split_method + 1 40 | end 41 | end)%> 42 | <% if generic_wraps then 43 | for generic_def, instances in pairs(generic_wraps) do 44 | for _, args in ipairs(instances) do 45 | local generic_arg_list = "<" 46 | ForEachCsList(args, function(generic_arg, gai) 47 | if gai ~= 0 then generic_arg_list = generic_arg_list .. ", " end 48 | generic_arg_list = generic_arg_list .. CsFullTypeName(generic_arg) 49 | end) 50 | generic_arg_list = generic_arg_list .. ">" 51 | 52 | %> 53 | <%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator) 54 | { 55 | <%end%> 56 | translator.DelayWrapLoader(typeof(<%=generic_def.Name:gsub("`%d+", "") .. generic_arg_list%>), <%=CSVariableName(generic_def)%>Wrap<%=generic_arg_list%>.__Register); 57 | <%if wrap_in_split_method == max_wrap_in_split_method then 58 | wrap_in_split_method = 0 59 | split_method_count = split_method_count + 1 60 | %> 61 | } 62 | <%else 63 | wrap_in_split_method = wrap_in_split_method + 1 64 | end 65 | end 66 | end 67 | end%> 68 | 69 | <%if wrap_in_split_method ~= 0 then 70 | split_method_count = split_method_count + 1 71 | %>}<%end%> 72 | 73 | static void Init(LuaEnv luaenv, ObjectTranslator translator) 74 | { 75 | <%for i = 1, split_method_count do%> 76 | <%=split_method_perfix%><%=(i - 1)%>(luaenv, translator); 77 | <%end%> 78 | <%ForEachCsList(itf_bridges, function(itf_bridge)%> 79 | translator.AddInterfaceBridgeCreator(typeof(<%=CsFullTypeName(itf_bridge)%>), <%=CSVariableName(itf_bridge)%>Bridge.__Create); 80 | <%end)%> 81 | } 82 | 83 | static XLua_Gen_Initer_Register__() 84 | { 85 | XLua.LuaEnv.AddIniter(Init); 86 | } 87 | 88 | 89 | } 90 | 91 | } 92 | namespace XLua 93 | { 94 | public partial class ObjectTranslator 95 | { 96 | static XLua.CSObjectWrap.XLua_Gen_Initer_Register__ s_gen_reg_dumb_obj = new XLua.CSObjectWrap.XLua_Gen_Initer_Register__(); 97 | static XLua.CSObjectWrap.XLua_Gen_Initer_Register__ gen_reg_dumb_obj {get{return s_gen_reg_dumb_obj;}} 98 | } 99 | 100 | internal partial class InternalGlobals 101 | { 102 | <% 103 | local type_to_methods = {} 104 | local seq_tbl = {} 105 | ForEachCsList(extension_methods, function(extension_method, idx) 106 | local parameters = extension_method:GetParameters() 107 | local type = parameters[0].ParameterType 108 | if not type_to_methods[type] then 109 | type_to_methods[type] = {type = type} 110 | table.insert(seq_tbl, type_to_methods[type]) 111 | end 112 | table.insert(type_to_methods[type], {method = extension_method, index = idx}) 113 | %> 114 | delegate <%=CsFullTypeName(extension_method.ReturnType)%> __GEN_DELEGATE<%=idx%>(<%ForEachCsList(parameters, function(parameter, pi) 115 | %><%if pi ~= 0 then%>, <%end%><%if parameter.IsOut then %>out <% elseif parameter.ParameterType.IsByRef then %>ref <% end %> <%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><% 116 | end)%>); 117 | <%end)%> 118 | static InternalGlobals() 119 | { 120 | extensionMethodMap = new Dictionary>() 121 | { 122 | <%for _, methods_info in ipairs(seq_tbl) do%> 123 | {typeof(<%=CsFullTypeName(methods_info.type)%>), new List(){ 124 | <% for _, method_info in ipairs(methods_info) do%> 125 | new __GEN_DELEGATE<%=method_info.index%>(<%=CsFullTypeName(method_info.method.DeclaringType)%>.<%=method_info.method.Name%>) 126 | #if UNITY_WSA && !UNITY_EDITOR 127 | .GetMethodInfo(), 128 | #else 129 | .Method, 130 | #endif 131 | <% end%> 132 | }}, 133 | <%end%> 134 | }; 135 | 136 | genTryArrayGetPtr = StaticLuaCallbacks.__tryArrayGet; 137 | genTryArraySetPtr = StaticLuaCallbacks.__tryArraySet; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaRegisterGCM.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Reflection; 14 | <% 15 | require "TemplateCommon" 16 | %> 17 | 18 | namespace XLua.CSObjectWrap 19 | { 20 | public class XLua_Gen_Initer_Register__ 21 | { 22 | <% 23 | local split_method_perfix = 'wrapInit' 24 | local split_method_count = 0 25 | local wrap_in_split_method = 0 26 | local max_wrap_in_split_method = 50 27 | %> 28 | <%ForEachCsList(wraps, function(wrap)%> 29 | <%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator) 30 | { 31 | <%end%> 32 | translator.DelayWrapLoader(typeof(<%=CsFullTypeName(wrap)%>), translator.__Register<%=CSVariableName(wrap)%>); 33 | <%if wrap_in_split_method == max_wrap_in_split_method then 34 | wrap_in_split_method = 0 35 | split_method_count = split_method_count + 1 36 | %> 37 | } 38 | <%else 39 | wrap_in_split_method = wrap_in_split_method + 1 40 | end 41 | end)%> 42 | <% if generic_wraps then 43 | for generic_def, instances in pairs(generic_wraps) do 44 | for _, args in ipairs(instances) do 45 | local generic_arg_list = "<" 46 | ForEachCsList(args, function(generic_arg, gai) 47 | if gai ~= 0 then generic_arg_list = generic_arg_list .. ", " end 48 | generic_arg_list = generic_arg_list .. CsFullTypeName(generic_arg) 49 | end) 50 | generic_arg_list = generic_arg_list .. ">" 51 | 52 | %> 53 | <%if wrap_in_split_method == 0 then%>static void <%=split_method_perfix%><%=split_method_count%>(LuaEnv luaenv, ObjectTranslator translator) 54 | { 55 | <%end%> 56 | translator.DelayWrapLoader(typeof(<%=generic_def.Name:gsub("`%d+", "") .. generic_arg_list%>), translator.__Register<%=CSVariableName(generic_def)%><%=generic_arg_list%>); 57 | <%if wrap_in_split_method == max_wrap_in_split_method then 58 | wrap_in_split_method = 0 59 | split_method_count = split_method_count + 1 60 | %> 61 | } 62 | <%else 63 | wrap_in_split_method = wrap_in_split_method + 1 64 | end 65 | end 66 | end 67 | end%> 68 | 69 | <%if wrap_in_split_method ~= 0 then 70 | split_method_count = split_method_count + 1 71 | %>}<%end%> 72 | 73 | static void Init(LuaEnv luaenv, ObjectTranslator translator) 74 | { 75 | <%for i = 1, split_method_count do%> 76 | <%=split_method_perfix%><%=(i - 1)%>(luaenv, translator); 77 | <%end%> 78 | <%ForEachCsList(itf_bridges, function(itf_bridge)%> 79 | translator.AddInterfaceBridgeCreator(typeof(<%=CsFullTypeName(itf_bridge)%>), <%=CSVariableName(itf_bridge)%>Bridge.__Create); 80 | <%end)%> 81 | } 82 | 83 | static XLua_Gen_Initer_Register__() 84 | { 85 | XLua.LuaEnv.AddIniter(Init); 86 | } 87 | 88 | 89 | } 90 | 91 | } 92 | namespace XLua 93 | { 94 | public partial class ObjectTranslator 95 | { 96 | static XLua.CSObjectWrap.XLua_Gen_Initer_Register__ s_gen_reg_dumb_obj = new XLua.CSObjectWrap.XLua_Gen_Initer_Register__(); 97 | static XLua.CSObjectWrap.XLua_Gen_Initer_Register__ gen_reg_dumb_obj {get{return s_gen_reg_dumb_obj;}} 98 | } 99 | 100 | internal partial class InternalGlobals 101 | { 102 | <% 103 | local type_to_methods = {} 104 | local seq_tbl = {} 105 | ForEachCsList(extension_methods, function(extension_method, idx) 106 | local parameters = extension_method:GetParameters() 107 | local type = parameters[0].ParameterType 108 | if not type_to_methods[type] then 109 | type_to_methods[type] = {type = type} 110 | table.insert(seq_tbl, type_to_methods[type]) 111 | end 112 | table.insert(type_to_methods[type], {method = extension_method, index = idx}) 113 | %> 114 | delegate <%=CsFullTypeName(extension_method.ReturnType)%> __GEN_DELEGATE<%=idx%>(<%ForEachCsList(parameters, function(parameter, pi) 115 | %><%if pi ~= 0 then%>, <%end%><%if parameter.IsOut then %>out <% elseif parameter.ParameterType.IsByRef then %>ref <% end %> <%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><% 116 | end)%>); 117 | <%end)%> 118 | static InternalGlobals() 119 | { 120 | extensionMethodMap = new Dictionary>() 121 | { 122 | <%for _, methods_info in ipairs(seq_tbl) do%> 123 | {typeof(<%=CsFullTypeName(methods_info.type)%>), new List(){ 124 | <% for _, method_info in ipairs(methods_info) do%> 125 | new __GEN_DELEGATE<%=method_info.index%>(<%=CsFullTypeName(method_info.method.DeclaringType)%>.<%=method_info.method.Name%>) 126 | #if UNITY_WSA && !UNITY_EDITOR 127 | .GetMethodInfo(), 128 | #else 129 | .Method, 130 | #endif 131 | <% end%> 132 | }}, 133 | <%end%> 134 | }; 135 | 136 | genTryArrayGetPtr = StaticLuaCallbacks.__tryArrayGet; 137 | genTryArraySetPtr = StaticLuaCallbacks.__tryArraySet; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/Editor/Template/LuaDelegateWrap.tpl.txt: -------------------------------------------------------------------------------- 1 | #if USE_UNI_LUA 2 | using LuaAPI = UniLua.Lua; 3 | using RealStatePtr = UniLua.ILuaState; 4 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 5 | #else 6 | using LuaAPI = XLua.LuaDLL.Lua; 7 | using RealStatePtr = System.IntPtr; 8 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 9 | #endif 10 | 11 | using XLua; 12 | using System.Collections.Generic; 13 | <% 14 | require "TemplateCommon" 15 | 16 | local parameters = delegate:GetParameters() 17 | local in_num = CalcCsList(parameters, function(p) return not (p.IsOut and p.ParameterType.IsByRef) end) 18 | local out_num = CalcCsList(parameters, function(p) return p.IsOut or p.ParameterType.IsByRef end) 19 | local in_pos = 0 20 | local has_return = (delegate.ReturnType.Name ~= "Void") 21 | %> 22 | 23 | namespace XLua.CSObjectWrap 24 | { 25 | using Utils = XLua.Utils; 26 | public class <%=CSVariableName(type)%>Wrap 27 | { 28 | public static void __Register(RealStatePtr L) 29 | { 30 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); 31 | Utils.BeginObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, 0, 0, 0, 0); 32 | Utils.EndObjectRegister(typeof(<%=CsFullTypeName(type)%>), L, translator, null, null, null, null, null); 33 | 34 | Utils.BeginClassRegister(typeof(<%=CsFullTypeName(type)%>), L, null, 1, 0, 0); 35 | Utils.EndClassRegister(typeof(<%=CsFullTypeName(type)%>), L, translator); 36 | } 37 | 38 | static Dictionary __MetaFucntions_Dic = new Dictionary(){ 39 | {"__call", __CallMeta}, 40 | {"__add", __AddMeta}, 41 | {"__sub", __SubMeta}, 42 | }; 43 | 44 | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] 45 | static int __CallMeta(RealStatePtr L) 46 | { 47 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); 48 | try { 49 | if(LuaAPI.lua_gettop(L) == <%=in_num+1%> && <%=GetCheckStatement(type, 1)%><% 50 | ForEachCsList(parameters, function(parameter) 51 | if not (parameter.IsOut and parameter.ParameterType.IsByRef) then in_pos = in_pos + 1; 52 | %>&& <%=GetCheckStatement(parameter.ParameterType, in_pos+1)%><% 53 | end 54 | end)%>) 55 | { 56 | <% 57 | in_pos = 0; 58 | ForEachCsList(parameters, function(parameter) 59 | %><% 60 | if not (parameter.IsOut and parameter.ParameterType.IsByRef) then 61 | in_pos = in_pos + 1 62 | %><%=GetCasterStatement(parameter.ParameterType, in_pos+1, parameter.Name, true)%><% 63 | else%><%=CsFullTypeName(parameter.ParameterType)%> <%=parameter.Name%><%end%>; 64 | <%end)%> 65 | <%=GetSelfStatement(type)%>; 66 | 67 | <% 68 | if has_return then 69 | %> <%=CsFullTypeName(delegate.ReturnType)%> __cl_gen_ret = <% 70 | end 71 | %> __cl_gen_to_be_invoked( <%ForEachCsList(parameters, function(parameter, pi) if pi ~= 0 then %>, <% end; if parameter.IsOut then %>out <% elseif parameter.ParameterType.IsByRef then %>ref <% end %><%=parameter.Name%><% end) %> ); 72 | <% 73 | if has_return then 74 | %> <%=GetPushStatement(delegate.ReturnType, "__cl_gen_ret")%>; 75 | <% 76 | end 77 | local in_pos = 0 78 | ForEachCsList(parameters, function(parameter) 79 | if not (parameter.IsOut and parameter.ParameterType.IsByRef) then 80 | in_pos = in_pos + 1 81 | end 82 | if parameter.IsOut or parameter.ParameterType.IsByRef then 83 | %><%=GetPushStatement(parameter.ParameterType:GetElementType(), parameter.Name)%>; 84 | <%if not parameter.IsOut and parameter.ParameterType.IsByRef and NeedUpdate(parameter.ParameterType) then 85 | %><%=GetUpdateStatement(parameter.ParameterType:GetElementType(), in_pos+param_offset, parameter.Name)%>; 86 | <%end%> 87 | <% 88 | end 89 | end) 90 | %> 91 | 92 | return <%=out_num+(has_return and 1 or 0)%>; 93 | } 94 | } catch(System.Exception __gen_e) { 95 | return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); 96 | } 97 | return LuaAPI.luaL_error(L, "invalid arguments to Delegate <%=CsFullTypeName(type)%>!"); 98 | } 99 | 100 | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] 101 | static int __AddMeta(RealStatePtr L) 102 | { 103 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); 104 | try { 105 | <%=GetCasterStatement(type, 1, "leftside", true)%>; 106 | <%=GetCasterStatement(type, 2, "rightside", true)%>; 107 | <%=GetPushStatement(type, "leftside + rightside")%>; 108 | return 1; 109 | } catch(System.Exception __gen_e) { 110 | return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); 111 | } 112 | } 113 | 114 | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] 115 | static int __SubMeta(RealStatePtr L) 116 | { 117 | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); 118 | try { 119 | <%=GetCasterStatement(type, 1, "leftside", true)%>; 120 | <%=GetCasterStatement(type, 2, "rightside", true)%>; 121 | <%=GetPushStatement(type, "leftside - rightside")%>; 122 | return 1; 123 | } catch(System.Exception __gen_e) { 124 | return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); 125 | } 126 | } 127 | } 128 | } -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Src/CopyByValue.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making xLua available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * 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 5 | * http://opensource.org/licenses/MIT 6 | * 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. 7 | */ 8 | 9 | #if USE_UNI_LUA 10 | using LuaAPI = UniLua.Lua; 11 | using RealStatePtr = UniLua.ILuaState; 12 | using LuaCSFunction = UniLua.CSharpFunctionDelegate; 13 | #else 14 | using LuaAPI = XLua.LuaDLL.Lua; 15 | using RealStatePtr = System.IntPtr; 16 | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; 17 | #endif 18 | 19 | using System; 20 | 21 | namespace XLua 22 | { 23 | public static partial class CopyByValue 24 | { 25 | // for int 8 26 | public static bool Pack(IntPtr buff, int offset, byte field) 27 | { 28 | return LuaAPI.xlua_pack_int8_t(buff, offset, field); 29 | } 30 | public static bool UnPack(IntPtr buff, int offset, out byte field) 31 | { 32 | return LuaAPI.xlua_unpack_int8_t(buff, offset, out field); 33 | } 34 | public static bool Pack(IntPtr buff, int offset, sbyte field) 35 | { 36 | return LuaAPI.xlua_pack_int8_t(buff, offset, (byte)field); 37 | } 38 | public static bool UnPack(IntPtr buff, int offset, out sbyte field) 39 | { 40 | byte tfield; 41 | bool ret = LuaAPI.xlua_unpack_int8_t(buff, offset, out tfield); 42 | field = (sbyte)tfield; 43 | return ret; 44 | } 45 | // for int16 46 | public static bool Pack(IntPtr buff, int offset, short field) 47 | { 48 | return LuaAPI.xlua_pack_int16_t(buff, offset, field); 49 | } 50 | public static bool UnPack(IntPtr buff, int offset, out short field) 51 | { 52 | return LuaAPI.xlua_unpack_int16_t(buff, offset, out field); 53 | } 54 | public static bool Pack(IntPtr buff, int offset, ushort field) 55 | { 56 | return LuaAPI.xlua_pack_int16_t(buff, offset, (short)field); 57 | } 58 | public static bool UnPack(IntPtr buff, int offset, out ushort field) 59 | { 60 | short tfield; 61 | bool ret = LuaAPI.xlua_unpack_int16_t(buff, offset, out tfield); 62 | field = (ushort)tfield; 63 | return ret; 64 | } 65 | // for int32 66 | public static bool Pack(IntPtr buff, int offset, int field) 67 | { 68 | return LuaAPI.xlua_pack_int32_t(buff, offset, field); 69 | } 70 | public static bool UnPack(IntPtr buff, int offset, out int field) 71 | { 72 | return LuaAPI.xlua_unpack_int32_t(buff, offset, out field); 73 | } 74 | public static bool Pack(IntPtr buff, int offset, uint field) 75 | { 76 | return LuaAPI.xlua_pack_int32_t(buff, offset, (int)field); 77 | } 78 | public static bool UnPack(IntPtr buff, int offset, out uint field) 79 | { 80 | int tfield; 81 | bool ret = LuaAPI.xlua_unpack_int32_t(buff, offset, out tfield); 82 | field = (uint)tfield; 83 | return ret; 84 | } 85 | // for int64 86 | public static bool Pack(IntPtr buff, int offset, long field) 87 | { 88 | return LuaAPI.xlua_pack_int64_t(buff, offset, field); 89 | } 90 | public static bool UnPack(IntPtr buff, int offset, out long field) 91 | { 92 | return LuaAPI.xlua_unpack_int64_t(buff, offset, out field); 93 | } 94 | public static bool Pack(IntPtr buff, int offset, ulong field) 95 | { 96 | return LuaAPI.xlua_pack_int64_t(buff, offset, (long)field); 97 | } 98 | public static bool UnPack(IntPtr buff, int offset, out ulong field) 99 | { 100 | long tfield; 101 | bool ret = LuaAPI.xlua_unpack_int64_t(buff, offset, out tfield); 102 | field = (ulong)tfield; 103 | return ret; 104 | } 105 | // for float 106 | public static bool Pack(IntPtr buff, int offset, float field) 107 | { 108 | return LuaAPI.xlua_pack_float(buff, offset, field); 109 | } 110 | public static bool UnPack(IntPtr buff, int offset, out float field) 111 | { 112 | return LuaAPI.xlua_unpack_float(buff, offset, out field); 113 | } 114 | // for double 115 | public static bool Pack(IntPtr buff, int offset, double field) 116 | { 117 | return LuaAPI.xlua_pack_double(buff, offset, field); 118 | } 119 | public static bool UnPack(IntPtr buff, int offset, out double field) 120 | { 121 | return LuaAPI.xlua_unpack_double(buff, offset, out field); 122 | } 123 | // for decimal 124 | public static bool Pack(IntPtr buff, int offset, decimal field) 125 | { 126 | return LuaAPI.xlua_pack_decimal(buff, offset, ref field); 127 | } 128 | public static bool UnPack(IntPtr buff, int offset, out decimal field) 129 | { 130 | byte scale; 131 | byte sign; 132 | int hi32; 133 | ulong lo64; 134 | if (!LuaAPI.xlua_unpack_decimal(buff, offset, out scale, out sign, out hi32, out lo64)) 135 | { 136 | field = default(decimal); 137 | return false; 138 | } 139 | 140 | field = new Decimal((int)(lo64 & 0xFFFFFFFF), (int)(lo64 >> 32), hi32, (sign & 0x80) != 0, scale); 141 | return true; 142 | } 143 | 144 | public static bool IsStruct(Type type) 145 | { 146 | return type.IsValueType() && !type.IsEnum() && !type.IsPrimitive(); 147 | } 148 | 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/XLua/Resources/xlua/util.lua.txt: -------------------------------------------------------------------------------- 1 | -- Tencent is pleased to support the open source community by making xLua available. 2 | -- Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 3 | -- 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 4 | -- http://opensource.org/licenses/MIT 5 | -- 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. 6 | 7 | local unpack = unpack or table.unpack 8 | 9 | local function async_to_sync(async_func, callback_pos) 10 | return function(...) 11 | local _co = coroutine.running() or error ('this function must be run in coroutine') 12 | local rets 13 | local waiting = false 14 | local function cb_func(...) 15 | if waiting then 16 | assert(coroutine.resume(_co, ...)) 17 | else 18 | rets = {...} 19 | end 20 | end 21 | local params = {...} 22 | table.insert(params, callback_pos or (#params + 1), cb_func) 23 | async_func(unpack(params)) 24 | if rets == nil then 25 | waiting = true 26 | rets = {coroutine.yield()} 27 | end 28 | 29 | return unpack(rets) 30 | end 31 | end 32 | 33 | local function coroutine_call(func) 34 | return function(...) 35 | local co = coroutine.create(func) 36 | assert(coroutine.resume(co, ...)) 37 | end 38 | end 39 | 40 | local move_end = {} 41 | 42 | local generator_mt = { 43 | __index = { 44 | MoveNext = function(self) 45 | self.Current = self.co() 46 | if self.Current == move_end then 47 | self.Current = nil 48 | return false 49 | else 50 | return true 51 | end 52 | end; 53 | Reset = function(self) 54 | self.co = coroutine.wrap(self.w_func) 55 | end 56 | } 57 | } 58 | 59 | local function cs_generator(func, ...) 60 | local params = {...} 61 | local generator = setmetatable({ 62 | w_func = function() 63 | func(unpack(params)) 64 | return move_end 65 | end 66 | }, generator_mt) 67 | generator:Reset() 68 | return generator 69 | end 70 | 71 | local function loadpackage(...) 72 | for _, loader in ipairs(package.searchers) do 73 | local func = loader(...) 74 | if type(func) == 'function' then 75 | return func 76 | end 77 | end 78 | end 79 | 80 | local function auto_id_map() 81 | local hotfix_id_map = require 'hotfix_id_map' 82 | local org_hotfix = xlua.hotfix 83 | xlua.hotfix = function(cs, field, func) 84 | local map_info_of_type = hotfix_id_map[typeof(cs):ToString()] 85 | if map_info_of_type then 86 | if func == nil then func = false end 87 | local tbl = (type(field) == 'table') and field or {[field] = func} 88 | for k, v in pairs(tbl) do 89 | local map_info_of_methods = map_info_of_type[k] 90 | local f = type(v) == 'function' and v or nil 91 | for _, id in ipairs(map_info_of_methods or {}) do 92 | CS.XLua.HotfixDelegateBridge.Set(id, f) 93 | end 94 | --CS.XLua.HotfixDelegateBridge.Set( 95 | end 96 | xlua.private_accessible(cs) 97 | else 98 | return org_hotfix(cs, field, func) 99 | end 100 | end 101 | end 102 | 103 | --和xlua.hotfix的区别是:这个可以调用原来的函数 104 | local function hotfix_ex(cs, field, func) 105 | assert(type(field) == 'string' and type(func) == 'function', 'invalid argument: #2 string needed, #3 function needed!') 106 | local function func_after(...) 107 | xlua.hotfix(cs, field, nil) 108 | local ret = {func(...)} 109 | xlua.hotfix(cs, field, func_after) 110 | return unpack(ret) 111 | end 112 | xlua.hotfix(cs, field, func_after) 113 | end 114 | 115 | local function bind(func, obj) 116 | return function(...) 117 | return func(obj, ...) 118 | end 119 | end 120 | 121 | --为了兼容luajit,lua53版本直接用|操作符即可 122 | local enum_or_op = debug.getmetatable(CS.System.Reflection.BindingFlags.Public).__bor 123 | local enum_or_op_ex = function(first, ...) 124 | for _, e in ipairs({...}) do 125 | first = enum_or_op(first, e) 126 | end 127 | return first 128 | end 129 | 130 | -- description: 直接用C#函数创建delegate 131 | local function createdelegate(delegate_cls, obj, impl_cls, method_name, parameter_type_list) 132 | local flag = enum_or_op_ex(CS.System.Reflection.BindingFlags.Public, CS.System.Reflection.BindingFlags.NonPublic, 133 | CS.System.Reflection.BindingFlags.Instance, CS.System.Reflection.BindingFlags.Static) 134 | local m = parameter_type_list and typeof(impl_cls):GetMethod(method_name, flag, nil, parameter_type_list, nil) 135 | or typeof(impl_cls):GetMethod(method_name, flag) 136 | return CS.System.Delegate.CreateDelegate(typeof(delegate_cls), obj, m) 137 | end 138 | 139 | local function state(csobj, state) 140 | local csobj_mt = getmetatable(csobj) 141 | for k, v in pairs(csobj_mt) do rawset(state, k, v) end 142 | local csobj_index, csobj_newindex = state.__index, state.__newindex 143 | state.__index = function(obj, k) 144 | return rawget(state, k) or csobj_index(obj, k) 145 | end 146 | state.__newindex = function(obj, k, v) 147 | if rawget(state, k) ~= nil then 148 | rawset(state, k, v) 149 | else 150 | csobj_newindex(obj, k, v) 151 | end 152 | end 153 | debug.setmetatable(csobj, state) 154 | return state 155 | end 156 | 157 | local function print_func_ref_by_csharp() 158 | local registry = debug.getregistry() 159 | for k, v in pairs(registry) do 160 | if type(k) == 'number' and type(v) == 'function' and registry[v] == k then 161 | local info = debug.getinfo(v) 162 | print(string.format('%s:%d', info.short_src, info.linedefined)) 163 | end 164 | end 165 | end 166 | 167 | return { 168 | async_to_sync = async_to_sync, 169 | coroutine_call = coroutine_call, 170 | cs_generator = cs_generator, 171 | loadpackage = loadpackage, 172 | auto_id_map = auto_id_map, 173 | hotfix_ex = hotfix_ex, 174 | bind = bind, 175 | createdelegate = createdelegate, 176 | state = state, 177 | print_func_ref_by_csharp = print_func_ref_by_csharp, 178 | } 179 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Lua/Core/middleClass.lua: -------------------------------------------------------------------------------- 1 | local middleclass = { 2 | _VERSION = 'middleclass v4.1.1', 3 | _DESCRIPTION = 'Object Orientation for Lua', 4 | _URL = 'https://github.com/kikito/middleclass', 5 | _LICENSE = [[ 6 | MIT LICENSE 7 | Copyright (c) 2011 Enrique García Cota 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the 10 | "Software"), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | ]] 25 | } 26 | 27 | local function _createIndexWrapper(aClass, f) 28 | if f == nil then 29 | return aClass.__instanceDict 30 | else 31 | return function(self, name) 32 | local value = aClass.__instanceDict[name] 33 | 34 | if value ~= nil then 35 | return value 36 | elseif type(f) == "function" then 37 | return (f(self, name)) 38 | else 39 | return f[name] 40 | end 41 | end 42 | end 43 | end 44 | 45 | local function _propagateInstanceMethod(aClass, name, f) 46 | f = name == "__index" and _createIndexWrapper(aClass, f) or f 47 | aClass.__instanceDict[name] = f 48 | 49 | for subclass in pairs(aClass.subclasses) do 50 | if rawget(subclass.__declaredMethods, name) == nil then 51 | _propagateInstanceMethod(subclass, name, f) 52 | end 53 | end 54 | end 55 | 56 | local function _declareInstanceMethod(aClass, name, f) 57 | aClass.__declaredMethods[name] = f 58 | 59 | if f == nil and aClass.super then 60 | f = aClass.super.__instanceDict[name] 61 | end 62 | 63 | _propagateInstanceMethod(aClass, name, f) 64 | end 65 | 66 | local function _tostring(self) return "class " .. self.name end 67 | local function _call(self, ...) return self:new(...) end 68 | 69 | local function _createClass(name, super) 70 | local dict = {} 71 | dict.__index = dict 72 | 73 | local aClass = { name = name, super = super, static = {}, 74 | __instanceDict = dict, __declaredMethods = {}, 75 | subclasses = setmetatable({}, {__mode='k'}) } 76 | 77 | if super then 78 | setmetatable(aClass.static, { 79 | __index = function(_,k) 80 | local result = rawget(dict,k) 81 | if result == nil then 82 | return super.static[k] 83 | end 84 | return result 85 | end 86 | }) 87 | else 88 | setmetatable(aClass.static, { __index = function(_,k) return rawget(dict,k) end }) 89 | end 90 | 91 | setmetatable(aClass, { __index = aClass.static, __tostring = _tostring, 92 | __call = _call, __newindex = _declareInstanceMethod }) 93 | 94 | return aClass 95 | end 96 | 97 | local function _includeMixin(aClass, mixin) 98 | assert(type(mixin) == 'table', "mixin must be a table") 99 | 100 | for name,method in pairs(mixin) do 101 | if name ~= "included" and name ~= "static" then aClass[name] = method end 102 | end 103 | 104 | for name,method in pairs(mixin.static or {}) do 105 | aClass.static[name] = method 106 | end 107 | 108 | if type(mixin.included)=="function" then mixin:included(aClass) end 109 | return aClass 110 | end 111 | 112 | local DefaultMixin = { 113 | __tostring = function(self) return "instance of " .. tostring(self.class) end, 114 | 115 | initialize = function(self, ...) end, 116 | 117 | isInstanceOf = function(self, aClass) 118 | return type(aClass) == 'table' 119 | and type(self) == 'table' 120 | and (self.class == aClass 121 | or type(self.class) == 'table' 122 | and type(self.class.isSubclassOf) == 'function' 123 | and self.class:isSubclassOf(aClass)) 124 | end, 125 | 126 | static = { 127 | allocate = function(self) 128 | assert(type(self) == 'table', "Make sure that you are using 'Class:allocate' instead of 'Class.allocate'") 129 | return setmetatable({ class = self }, self.__instanceDict) 130 | end, 131 | 132 | new = function(self, ...) 133 | assert(type(self) == 'table', "Make sure that you are using 'Class:new' instead of 'Class.new'") 134 | local instance = self:allocate() 135 | instance:initialize(...) 136 | return instance 137 | end, 138 | 139 | newWith = function(self, instance, ...) 140 | assert(type(self) == 'table', "Make sure that you are using 'Class:new' instead of 'Class.new'") 141 | assert(type(instance) == 'table', "Make sure instance is table") 142 | instance.class = self 143 | setmetatable(instance, self.__instanceDict) 144 | instance:initialize(...) 145 | return instance 146 | end, 147 | 148 | subclass = function(self, name) 149 | assert(type(self) == 'table', "Make sure that you are using 'Class:subclass' instead of 'Class.subclass'") 150 | assert(type(name) == "string", "You must provide a name(string) for your class") 151 | 152 | local subclass = _createClass(name, self) 153 | 154 | for methodName, f in pairs(self.__instanceDict) do 155 | _propagateInstanceMethod(subclass, methodName, f) 156 | end 157 | subclass.initialize = function(instance, ...) return self.initialize(instance, ...) end 158 | 159 | self.subclasses[subclass] = true 160 | self:subclassed(subclass) 161 | 162 | return subclass 163 | end, 164 | 165 | subclassed = function(self, other) end, 166 | 167 | isSubclassOf = function(self, other) 168 | return type(other) == 'table' and 169 | type(self.super) == 'table' and 170 | ( self.super == other or self.super:isSubclassOf(other) ) 171 | end, 172 | 173 | include = function(self, ...) 174 | assert(type(self) == 'table', "Make sure you that you are using 'Class:include' instead of 'Class.include'") 175 | for _,mixin in ipairs({...}) do _includeMixin(self, mixin) end 176 | return self 177 | end 178 | } 179 | } 180 | 181 | function middleclass.class(name, super) 182 | assert(type(name) == 'string', "A name (string) is needed for the new class") 183 | return super and super:subclass(name) or _includeMixin(_createClass(name), DefaultMixin) 184 | end 185 | 186 | setmetatable(middleclass, { __call = function(_, ...) return middleclass.class(...) end }) 187 | 188 | 189 | 190 | return middleclass 191 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 4 41 | resolutionScalingFixedDPIFactor: 1 42 | excludedTargetPlatforms: [] 43 | - serializedVersion: 2 44 | name: Low 45 | pixelLightCount: 0 46 | shadows: 0 47 | shadowResolution: 0 48 | shadowProjection: 1 49 | shadowCascades: 1 50 | shadowDistance: 20 51 | shadowNearPlaneOffset: 3 52 | shadowCascade2Split: 0.33333334 53 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 54 | shadowmaskMode: 0 55 | blendWeights: 2 56 | textureQuality: 0 57 | anisotropicTextures: 0 58 | antiAliasing: 0 59 | softParticles: 0 60 | softVegetation: 0 61 | realtimeReflectionProbes: 0 62 | billboardsFaceCameraPosition: 0 63 | vSyncCount: 0 64 | lodBias: 0.4 65 | maximumLODLevel: 0 66 | streamingMipmapsActive: 0 67 | streamingMipmapsAddAllCameras: 1 68 | streamingMipmapsMemoryBudget: 512 69 | streamingMipmapsRenderersPerFrame: 512 70 | streamingMipmapsMaxLevelReduction: 2 71 | streamingMipmapsMaxFileIORequests: 1024 72 | particleRaycastBudget: 16 73 | asyncUploadTimeSlice: 2 74 | asyncUploadBufferSize: 4 75 | resolutionScalingFixedDPIFactor: 1 76 | excludedTargetPlatforms: [] 77 | - serializedVersion: 2 78 | name: Medium 79 | pixelLightCount: 1 80 | shadows: 1 81 | shadowResolution: 0 82 | shadowProjection: 1 83 | shadowCascades: 1 84 | shadowDistance: 20 85 | shadowNearPlaneOffset: 3 86 | shadowCascade2Split: 0.33333334 87 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 88 | shadowmaskMode: 0 89 | blendWeights: 2 90 | textureQuality: 0 91 | anisotropicTextures: 1 92 | antiAliasing: 0 93 | softParticles: 0 94 | softVegetation: 0 95 | realtimeReflectionProbes: 0 96 | billboardsFaceCameraPosition: 0 97 | vSyncCount: 1 98 | lodBias: 0.7 99 | maximumLODLevel: 0 100 | streamingMipmapsActive: 0 101 | streamingMipmapsAddAllCameras: 1 102 | streamingMipmapsMemoryBudget: 512 103 | streamingMipmapsRenderersPerFrame: 512 104 | streamingMipmapsMaxLevelReduction: 2 105 | streamingMipmapsMaxFileIORequests: 1024 106 | particleRaycastBudget: 64 107 | asyncUploadTimeSlice: 2 108 | asyncUploadBufferSize: 4 109 | resolutionScalingFixedDPIFactor: 1 110 | excludedTargetPlatforms: [] 111 | - serializedVersion: 2 112 | name: High 113 | pixelLightCount: 2 114 | shadows: 2 115 | shadowResolution: 1 116 | shadowProjection: 1 117 | shadowCascades: 2 118 | shadowDistance: 40 119 | shadowNearPlaneOffset: 3 120 | shadowCascade2Split: 0.33333334 121 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 122 | shadowmaskMode: 1 123 | blendWeights: 2 124 | textureQuality: 0 125 | anisotropicTextures: 1 126 | antiAliasing: 0 127 | softParticles: 0 128 | softVegetation: 1 129 | realtimeReflectionProbes: 1 130 | billboardsFaceCameraPosition: 1 131 | vSyncCount: 1 132 | lodBias: 1 133 | maximumLODLevel: 0 134 | streamingMipmapsActive: 0 135 | streamingMipmapsAddAllCameras: 1 136 | streamingMipmapsMemoryBudget: 512 137 | streamingMipmapsRenderersPerFrame: 512 138 | streamingMipmapsMaxLevelReduction: 2 139 | streamingMipmapsMaxFileIORequests: 1024 140 | particleRaycastBudget: 256 141 | asyncUploadTimeSlice: 2 142 | asyncUploadBufferSize: 4 143 | resolutionScalingFixedDPIFactor: 1 144 | excludedTargetPlatforms: [] 145 | - serializedVersion: 2 146 | name: Very High 147 | pixelLightCount: 3 148 | shadows: 2 149 | shadowResolution: 2 150 | shadowProjection: 1 151 | shadowCascades: 2 152 | shadowDistance: 70 153 | shadowNearPlaneOffset: 3 154 | shadowCascade2Split: 0.33333334 155 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 156 | shadowmaskMode: 1 157 | blendWeights: 4 158 | textureQuality: 0 159 | anisotropicTextures: 2 160 | antiAliasing: 2 161 | softParticles: 1 162 | softVegetation: 1 163 | realtimeReflectionProbes: 1 164 | billboardsFaceCameraPosition: 1 165 | vSyncCount: 1 166 | lodBias: 1.5 167 | maximumLODLevel: 0 168 | streamingMipmapsActive: 0 169 | streamingMipmapsAddAllCameras: 1 170 | streamingMipmapsMemoryBudget: 512 171 | streamingMipmapsRenderersPerFrame: 512 172 | streamingMipmapsMaxLevelReduction: 2 173 | streamingMipmapsMaxFileIORequests: 1024 174 | particleRaycastBudget: 1024 175 | asyncUploadTimeSlice: 2 176 | asyncUploadBufferSize: 4 177 | resolutionScalingFixedDPIFactor: 1 178 | excludedTargetPlatforms: [] 179 | - serializedVersion: 2 180 | name: Ultra 181 | pixelLightCount: 4 182 | shadows: 2 183 | shadowResolution: 2 184 | shadowProjection: 1 185 | shadowCascades: 4 186 | shadowDistance: 150 187 | shadowNearPlaneOffset: 3 188 | shadowCascade2Split: 0.33333334 189 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 190 | shadowmaskMode: 1 191 | blendWeights: 4 192 | textureQuality: 0 193 | anisotropicTextures: 2 194 | antiAliasing: 2 195 | softParticles: 1 196 | softVegetation: 1 197 | realtimeReflectionProbes: 1 198 | billboardsFaceCameraPosition: 1 199 | vSyncCount: 1 200 | lodBias: 2 201 | maximumLODLevel: 0 202 | streamingMipmapsActive: 0 203 | streamingMipmapsAddAllCameras: 1 204 | streamingMipmapsMemoryBudget: 512 205 | streamingMipmapsRenderersPerFrame: 512 206 | streamingMipmapsMaxLevelReduction: 2 207 | streamingMipmapsMaxFileIORequests: 1024 208 | particleRaycastBudget: 4096 209 | asyncUploadTimeSlice: 2 210 | asyncUploadBufferSize: 4 211 | resolutionScalingFixedDPIFactor: 1 212 | excludedTargetPlatforms: [] 213 | m_PerPlatformDefaultQuality: 214 | Android: 2 215 | Nintendo 3DS: 5 216 | Nintendo Switch: 5 217 | PS4: 5 218 | PSP2: 2 219 | Standalone: 5 220 | WebGL: 3 221 | Windows Store Apps: 5 222 | XboxOne: 5 223 | iPhone: 2 224 | tvOS: 2 225 | -------------------------------------------------------------------------------- /LuaBehaviour/Assets/Script/Lua/LuaBehaviour/LuaBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEditor; 6 | using System.IO; 7 | using XLua; 8 | 9 | //---------------测试类型--------------- 10 | public enum Season 11 | { 12 | spring = 0, 13 | summer = 1, 14 | autumn = 2, 15 | winter= 3, 16 | } 17 | [Serializable] 18 | public class StringAndColor 19 | { 20 | public string s; 21 | public Color c; 22 | } 23 | //---------------测试类型--------------- 24 | 25 | public class LuaBehaviour : MonoBehaviour 26 | { 27 | public interface IObjWrap 28 | { 29 | object GetObj(); 30 | void SetObj(object obj); 31 | } 32 | 33 | public class ObjWrap : IObjWrap 34 | { 35 | public T obj; 36 | 37 | public object GetObj() 38 | { 39 | return obj; 40 | } 41 | 42 | public void SetObj(object obj) 43 | { 44 | this.obj = (T)obj; 45 | } 46 | } 47 | 48 | [Serializable] 49 | public class SerializedObjValue 50 | { 51 | public string key; 52 | public UnityEngine.Object value; 53 | } 54 | 55 | [Serializable] 56 | public class SerializedValue 57 | { 58 | public string key; 59 | public string jsonStr; 60 | } 61 | 62 | [HideInInspector] 63 | public string LuaScriptPath; 64 | [SerializeField] 65 | [HideInInspector] 66 | public List SerializedObjValues; 67 | [SerializeField] 68 | [HideInInspector] 69 | public List SerializedValues; 70 | 71 | public LuaTable luaInstance; 72 | public LuaTable LuaInstance 73 | { 74 | get 75 | { 76 | if(luaInstance == null) 77 | { 78 | InitLua(); 79 | } 80 | return luaInstance; 81 | } 82 | } 83 | 84 | private Action onEnableFunc; 85 | private Action onDisableFunc; 86 | 87 | void InitLua() 88 | { 89 | luaInstance = LuaManager.LuaEnvInstance.NewTable(); 90 | //注入自己 91 | luaInstance.Set("gameObject", gameObject); 92 | var rets = LuaManager.LuaEnvInstance.DoString($"return require \"{LuaScriptPath}\""); 93 | var luaClass = (LuaTable)rets[0]; 94 | LuaTable defineTable; 95 | luaClass.Get("_DefineList", out defineTable); 96 | if (defineTable != null) 97 | { 98 | Dictionary infoDict = new Dictionary(); 99 | string infoName; 100 | Type infoType; 101 | defineTable.ForEach((index, infoTable) => 102 | { 103 | infoTable.Get("name", out infoName); 104 | infoTable.Get("type", out infoType); 105 | infoDict.Add(infoName, infoType); 106 | }); 107 | //注入object类型对象 108 | foreach (var serializedValue in SerializedObjValues) 109 | { 110 | //看了下set的代码,没有注册任何object类型的pushfunc,所以最后调用的都是pushany, 111 | //不用担心类型错误问题 112 | if (infoDict.ContainsKey(serializedValue.key) && serializedValue.value != null) 113 | { 114 | luaInstance.Set(serializedValue.key, serializedValue.value); 115 | } 116 | } 117 | //注入其他类型 118 | foreach (var serializedValue in SerializedValues) 119 | { 120 | if (infoDict.ContainsKey(serializedValue.key)) 121 | { 122 | luaInstance.Set(serializedValue.key, JsonToValue(serializedValue.jsonStr, infoDict[serializedValue.key])); 123 | } 124 | } 125 | } 126 | var newWith = luaClass.Get>("newWith"); 127 | newWith(luaClass, luaInstance); 128 | this.onEnableFunc = luaClass.Get>("OnEnable"); 129 | this.onDisableFunc = luaClass.Get>("OnDisable"); 130 | } 131 | 132 | void Awake() 133 | { 134 | if(luaInstance == null) 135 | { 136 | InitLua(); 137 | } 138 | } 139 | 140 | void OnEnable() 141 | { 142 | onEnableFunc?.Invoke(LuaInstance); 143 | } 144 | 145 | void OnDisable() 146 | { 147 | onDisableFunc?.Invoke(LuaInstance); 148 | } 149 | 150 | void OnDestroy() 151 | { 152 | onEnableFunc = null; 153 | onDisableFunc = null; 154 | var onDestroyFunc = LuaInstance.Get>("OnDestroy"); 155 | onDestroyFunc?.Invoke(LuaInstance); 156 | luaInstance = null; 157 | } 158 | 159 | public static string ValueToJson(object value) 160 | { 161 | Type type = value.GetType(); 162 | Type wrapType = typeof(ObjWrap<>).MakeGenericType(type); 163 | var target = Activator.CreateInstance(wrapType); 164 | ((IObjWrap)target).SetObj(value); 165 | return JsonUtility.ToJson(target); 166 | } 167 | 168 | public static object JsonToValue(string json, Type type) 169 | { 170 | if(wrapTypeDict.ContainsKey(type)) 171 | { 172 | Type wrapType = wrapTypeDict[type]; 173 | var target = JsonUtility.FromJson(json, wrapType); 174 | return ((IObjWrap)target).GetObj(); 175 | } 176 | else if(type.IsValueType()) 177 | { 178 | //Debug.LogError($"msut register {type.FullName} in wrapTypeDict!"); 179 | Debug.LogError($"msut register {type.FullName} in wrapTypeDict, because it is value type!"); 180 | return null; 181 | } 182 | else 183 | { 184 | Type wrapType = typeof(ObjWrap<>).MakeGenericType(type); 185 | wrapTypeDict.Add(type, wrapType); 186 | var target = JsonUtility.FromJson(json, wrapType); 187 | return ((IObjWrap)target).GetObj(); 188 | } 189 | } 190 | 191 | //因为值类型泛型的生成在IL2CPP下会有JIT异常,所以值类型必须要注册 192 | private static Dictionary wrapTypeDict = new Dictionary() 193 | { 194 | {typeof(Int32), typeof(ObjWrap)}, 195 | {typeof(Int64), typeof(ObjWrap)}, 196 | {typeof(Single), typeof(ObjWrap)}, 197 | {typeof(Double), typeof(ObjWrap)}, 198 | {typeof(Boolean), typeof(ObjWrap)}, 199 | {typeof(String), typeof(ObjWrap)}, 200 | {typeof(Vector2), typeof(ObjWrap)}, 201 | {typeof(Vector3), typeof(ObjWrap)}, 202 | {typeof(Vector4), typeof(ObjWrap)}, 203 | {typeof(Color), typeof(ObjWrap)}, 204 | {typeof(Rect), typeof(ObjWrap)}, 205 | {typeof(Bounds), typeof(ObjWrap)}, 206 | 207 | {typeof(List), typeof(ObjWrap>)}, 208 | {typeof(List), typeof(ObjWrap>)}, 209 | {typeof(List), typeof(ObjWrap>)}, 210 | {typeof(List), typeof(ObjWrap>)}, 211 | 212 | //测试类型 213 | //{typeof(List), typeof(ObjWrap>)}, 214 | {typeof(Season), typeof(ObjWrap)}, 215 | }; 216 | } 217 | -------------------------------------------------------------------------------- /LuaBehaviour/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | --------------------------------------------------------------------------------