更新lua脚本,添加luawindow的创建方法。
7个文件已修改
1个文件已删除
2 文件已复制
7个文件已添加
1 文件已重命名
New file |
| | |
| | | -- -------------------------------------------------------- |
| | | -- [Author]: 第二世界 |
| | | -- [ Date ]: #DateTime# |
| | | -- -------------------------------------------------------- |
| | | |
| | | |
| | | function BindController() |
| | | |
| | | end |
| | | |
| | | function AddListeners() |
| | | |
| | | end |
| | | |
| | | function OnPreOpen() |
| | | |
| | | end |
| | | |
| | | function OnAfterOpen() |
| | | |
| | | end |
| | | |
| | | function OnPreClose() |
| | | |
| | | end |
| | | |
| | | function OnAfterClose() |
| | | |
| | | end |
| | | |
| | | function OnActived() |
| | | |
| | | end |
| | | |
| | | function LateUpdate() |
| | | |
| | | end |
| | | |
| | | function OnDestory() |
| | | |
| | | end |
| | | |
| | | |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: b599cad95be21124987ab773096a0bb6 |
| | | timeCreated: 1505271081 |
| | | licenseType: Pro |
| | | TextScriptImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEditor.ProjectWindowCallback; |
| | | using UnityEngine; |
| | | using UnityEditor; |
| | | using System; |
| | | using System.IO; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | |
| | | public class CreateLuaClassFile |
| | | { |
| | | static string templatePath = "Assets/Editor/ScriptTemplate/LuaWindowTemplate.txt"; |
| | | |
| | | [MenuItem("Assets/Create/Lua/LuaWindow", false, 4)] |
| | | public static void CreateLuaClass() |
| | | { |
| | | var path = GetSelectedPathOrFallback() + "/NewLuaWindow.lua"; |
| | | AssetDatabase.DeleteAsset(path); |
| | | ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<LuaWindowTemplate>(), path, null, templatePath); |
| | | } |
| | | |
| | | public static string GetSelectedPathOrFallback() |
| | | { |
| | | string path = "Assets"; |
| | | foreach (UnityEngine.Object obj in Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets)) |
| | | { |
| | | path = AssetDatabase.GetAssetPath(obj); |
| | | if (!string.IsNullOrEmpty(path) && File.Exists(path)) |
| | | { |
| | | path = Path.GetDirectoryName(path); |
| | | break; |
| | | } |
| | | } |
| | | return path; |
| | | } |
| | | |
| | | } |
| | | |
| | | class LuaWindowTemplate : EndNameEditAction |
| | | { |
| | | |
| | | public override void Action(int instanceId, string pathName, string resourceFile) |
| | | { |
| | | UnityEngine.Object o = CreateScriptAssetFromTemplate(pathName, resourceFile); |
| | | ProjectWindowUtil.ShowCreatedAsset(o); |
| | | } |
| | | |
| | | internal static UnityEngine.Object CreateScriptAssetFromTemplate(string pathName, string resourceFile) |
| | | { |
| | | string fullPath = Path.GetFullPath(pathName); |
| | | |
| | | StreamReader streamReader = new StreamReader(resourceFile); |
| | | string text = streamReader.ReadToEnd(); |
| | | streamReader.Close(); |
| | | string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(pathName); |
| | | text = Regex.Replace(text, "#DateTime#", System.DateTime.Now.ToLongDateString()); |
| | | |
| | | bool encoderShouldEmitUTF8Identifier = true; |
| | | bool throwOnInvalidBytes = false; |
| | | UTF8Encoding encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier, throwOnInvalidBytes); |
| | | bool append = false; |
| | | StreamWriter streamWriter = new StreamWriter(fullPath, append, encoding); |
| | | streamWriter.Write(text); |
| | | streamWriter.Close(); |
| | | AssetDatabase.ImportAsset(pathName); |
| | | return AssetDatabase.LoadAssetAtPath(pathName, typeof(UnityEngine.Object)); |
| | | } |
| | | |
| | | } |
copy from Assets/Editor/Tool/GenerateClass.cs.meta
copy to Assets/Editor/Tool/CreateLuaClassFile.cs.meta
File was copied from Assets/Editor/Tool/GenerateClass.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 09e90c049827e7c47bd5e7933618748f |
| | | timeCreated: 1504661855 |
| | | guid: 2aaaa063ecdf5c44da386b9e217cb493 |
| | | timeCreated: 1534325353 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | |
| | | string path = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID));
|
| | | string name = Application.dataPath + "/" + path.Replace("Assets/", "");
|
| | |
|
| | | if (name.EndsWith(".Shader") || name.EndsWith(".cginc") || name.EndsWith(".shader"))
|
| | | if (name.EndsWith(".Shader") || name.EndsWith(".cginc") || name.EndsWith(".shader") || name.EndsWith(".lua.txt") || name.EndsWith(".lua"))
|
| | | {
|
| | | System.Diagnostics.Process process = new System.Diagnostics.Process();
|
| | | System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
|
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 597870007d8164f47ad635130c494e62 |
| | | folderAsset: yes |
| | | timeCreated: 1534312509 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 06566e187a83c07479d6589d4394a404 |
| | | folderAsset: yes |
| | | timeCreated: 1534312509 |
| | | licenseType: Pro |
| | | DefaultImporter: |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | /* |
| | | * Tencent is pleased to support the open source community by making xLua available. |
| | | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. |
| | | * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at |
| | | * http://opensource.org/licenses/MIT |
| | | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
| | | */ |
| | | |
| | | using UnityEngine; |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using XLua; |
| | |
| | | [LuaCallCSharp] |
| | | public class LuaBehaviour : MonoBehaviour |
| | | { |
| | | public TextAsset luaScript; |
| | | public string fileName; |
| | | public Injection[] injections; |
| | | |
| | | internal static float lastGCTime = 0; |
| | | internal const float GCInterval = 1;//1 second |
| | | |
| | | private Action luaStart; |
| | | private Action luaUpdate; |
| | |
| | | scriptEnv.Set(injection.name, injection.value); |
| | | } |
| | | |
| | | LuaUtility.env.DoString(luaScript.text, "LuaBehaviour", scriptEnv); |
| | | LuaUtility.Do(fileName, "LuaBehaviour", scriptEnv); |
| | | |
| | | Action luaAwake = scriptEnv.Get<Action>("awake"); |
| | | scriptEnv.Get("start", out luaStart); |
| | | scriptEnv.Get("update", out luaUpdate); |
| | | scriptEnv.Get("ondestroy", out luaOnDestroy); |
| | | Action luaAwake = scriptEnv.Get<Action>("Awake"); |
| | | scriptEnv.Get("Start", out luaStart); |
| | | scriptEnv.Get("Update", out luaUpdate); |
| | | scriptEnv.Get("OnDestroy", out luaOnDestroy); |
| | | |
| | | if (luaAwake != null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | // Use this for initialization |
| | | void Start() |
| | | { |
| | | if (luaStart != null) |
| | |
| | | } |
| | | } |
| | | |
| | | // Update is called once per frame |
| | | void Update() |
| | | { |
| | | if (luaUpdate != null) |
| | | { |
| | | luaUpdate(); |
| | | } |
| | | if (Time.time - LuaBehaviour.lastGCTime > GCInterval) |
| | | { |
| | | LuaUtility.env.Tick(); |
| | | LuaBehaviour.lastGCTime = Time.time; |
| | | } |
| | | } |
| | | |
File was renamed from Assets/Editor/Tool/GenerateClass.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 09e90c049827e7c47bd5e7933618748f |
| | | timeCreated: 1504661855 |
| | | guid: 8cbe69e9bafd844418a6d146c677d315 |
| | | timeCreated: 1534325202 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp7() |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | | { |
| | | #endif |
| | | RealStatePtr L = luaEnv.rawL; |
| | | int err_func =LuaAPI.load_error_func(L, errorFuncRef); |
| | | |
| | | |
| | | LuaAPI.lua_getref(L, luaReference); |
| | | |
| | | |
| | | int __gen_error = LuaAPI.lua_pcall(L, 0, 0, err_func); |
| | | if (__gen_error != 0) |
| | | luaEnv.ThrowExceptionFromError(err_func - 1); |
| | | |
| | | |
| | | |
| | | LuaAPI.lua_settop(L, err_func - 1); |
| | | |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp8(bool p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | | { |
| | | #endif |
| | | RealStatePtr L = luaEnv.rawL; |
| | | int err_func =LuaAPI.load_error_func(L, errorFuncRef); |
| | | |
| | | |
| | | LuaAPI.lua_getref(L, luaReference); |
| | | |
| | | LuaAPI.lua_pushboolean(L, p0); |
| | | |
| | | int __gen_error = LuaAPI.lua_pcall(L, 1, 0, err_func); |
| | | if (__gen_error != 0) |
| | | luaEnv.ThrowExceptionFromError(err_func - 1); |
| | | |
| | | |
| | | |
| | | LuaAPI.lua_settop(L, err_func - 1); |
| | | |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp9(HotfixCalc p0, int p1, out double p2, ref string p3) |
| | | public int __Gen_Delegate_Imp7(HotfixCalc p0, int p1, out double p2, ref string p3) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public double __Gen_Delegate_Imp10(double p0, double p1) |
| | | public void __Gen_Delegate_Imp8() |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | | { |
| | | #endif |
| | | RealStatePtr L = luaEnv.rawL; |
| | | int err_func =LuaAPI.load_error_func(L, errorFuncRef); |
| | | |
| | | |
| | | LuaAPI.lua_getref(L, luaReference); |
| | | |
| | | |
| | | int __gen_error = LuaAPI.lua_pcall(L, 0, 0, err_func); |
| | | if (__gen_error != 0) |
| | | luaEnv.ThrowExceptionFromError(err_func - 1); |
| | | |
| | | |
| | | |
| | | LuaAPI.lua_settop(L, err_func - 1); |
| | | |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | public double __Gen_Delegate_Imp9(double p0, double p1) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp11(string p0) |
| | | public void __Gen_Delegate_Imp10(string p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp12(double p0) |
| | | public void __Gen_Delegate_Imp11(double p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp13(int p0, string p1, out CSCallLua.DClass p2) |
| | | public int __Gen_Delegate_Imp12(int p0, string p1, out CSCallLua.DClass p2) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public System.Action __Gen_Delegate_Imp14() |
| | | public System.Action __Gen_Delegate_Imp13() |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp15(object p0) |
| | | public void __Gen_Delegate_Imp14(object p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp16(object p0, int p1, int p2) |
| | | public int __Gen_Delegate_Imp15(object p0, int p1, int p2) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public UnityEngine.Vector3 __Gen_Delegate_Imp17(object p0, UnityEngine.Vector3 p1, UnityEngine.Vector3 p2) |
| | | public UnityEngine.Vector3 __Gen_Delegate_Imp16(object p0, UnityEngine.Vector3 p1, UnityEngine.Vector3 p2) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp18(object p0, int p1, out double p2, ref string p3) |
| | | public int __Gen_Delegate_Imp17(object p0, int p1, out double p2, ref string p3) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp19(object p0, int p1, out double p2, ref string p3, object p4) |
| | | public int __Gen_Delegate_Imp18(object p0, int p1, out double p2, ref string p3, object p4) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp20(object p0, int p1) |
| | | public void __Gen_Delegate_Imp19(object p0, int p1) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public string __Gen_Delegate_Imp21(object p0) |
| | | public string __Gen_Delegate_Imp20(object p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public UnityEngine.GameObject __Gen_Delegate_Imp22(StructTest p0, int p1, object p2) |
| | | public UnityEngine.GameObject __Gen_Delegate_Imp21(StructTest p0, int p1, object p2) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public string __Gen_Delegate_Imp23(StructTest p0) |
| | | public string __Gen_Delegate_Imp22(StructTest p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp24(StructTest p0, object p1) |
| | | public void __Gen_Delegate_Imp23(StructTest p0, object p1) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp25(object p0) |
| | | public int __Gen_Delegate_Imp24(object p0) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp26(object p0, object p1) |
| | | public void __Gen_Delegate_Imp25(object p0, object p1) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public int __Gen_Delegate_Imp27(object p0, object p1) |
| | | public int __Gen_Delegate_Imp26(object p0, object p1) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp28(object p0, object p1, int p2) |
| | | public void __Gen_Delegate_Imp27(object p0, object p1, int p2) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp29(int p0, int p1) |
| | | public void __Gen_Delegate_Imp28(int p0, int p1) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | #endif |
| | | } |
| | | |
| | | public void __Gen_Delegate_Imp30(object p0, int p1, int p2) |
| | | public void __Gen_Delegate_Imp29(object p0, int p1, int p2) |
| | | { |
| | | #if THREAD_SAFE || HOTFIX_ENABLE |
| | | lock (luaEnv.luaEnvLock) |
| | |
| | | return new XLuaTest.ArrayAccess(__Gen_Delegate_Imp6); |
| | | } |
| | | |
| | | if (type == typeof(TestOutDelegate)) |
| | | { |
| | | return new TestOutDelegate(__Gen_Delegate_Imp7); |
| | | } |
| | | |
| | | if (type == typeof(System.Action)) |
| | | { |
| | | return new System.Action(__Gen_Delegate_Imp7); |
| | | return new System.Action(__Gen_Delegate_Imp8); |
| | | } |
| | | |
| | | if (type == typeof(UnityEngine.Events.UnityAction)) |
| | | { |
| | | return new UnityEngine.Events.UnityAction(__Gen_Delegate_Imp7); |
| | | } |
| | | |
| | | if (type == typeof(System.Action<bool>)) |
| | | { |
| | | return new System.Action<bool>(__Gen_Delegate_Imp8); |
| | | } |
| | | |
| | | if (type == typeof(TestOutDelegate)) |
| | | { |
| | | return new TestOutDelegate(__Gen_Delegate_Imp9); |
| | | return new UnityEngine.Events.UnityAction(__Gen_Delegate_Imp8); |
| | | } |
| | | |
| | | if (type == typeof(System.Func<double, double, double>)) |
| | | { |
| | | return new System.Func<double, double, double>(__Gen_Delegate_Imp10); |
| | | return new System.Func<double, double, double>(__Gen_Delegate_Imp9); |
| | | } |
| | | |
| | | if (type == typeof(System.Action<string>)) |
| | | { |
| | | return new System.Action<string>(__Gen_Delegate_Imp11); |
| | | return new System.Action<string>(__Gen_Delegate_Imp10); |
| | | } |
| | | |
| | | if (type == typeof(System.Action<double>)) |
| | | { |
| | | return new System.Action<double>(__Gen_Delegate_Imp12); |
| | | return new System.Action<double>(__Gen_Delegate_Imp11); |
| | | } |
| | | |
| | | if (type == typeof(CSCallLua.FDelegate)) |
| | | { |
| | | return new CSCallLua.FDelegate(__Gen_Delegate_Imp13); |
| | | return new CSCallLua.FDelegate(__Gen_Delegate_Imp12); |
| | | } |
| | | |
| | | if (type == typeof(CSCallLua.GetE)) |
| | | { |
| | | return new CSCallLua.GetE(__Gen_Delegate_Imp14); |
| | | return new CSCallLua.GetE(__Gen_Delegate_Imp13); |
| | | } |
| | | |
| | | return null; |
| | |
| | | |
| | | |
| | | |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "luaScript", _g_get_luaScript); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "fileName", _g_get_fileName); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "injections", _g_get_injections); |
| | | |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "luaScript", _s_set_luaScript); |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "fileName", _s_set_fileName); |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "injections", _s_set_injections); |
| | | |
| | | |
| | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_luaScript(RealStatePtr L) |
| | | static int _g_get_fileName(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | LuaBehaviour gen_to_be_invoked = (LuaBehaviour)translator.FastGetCSObj(L, 1); |
| | | translator.Push(L, gen_to_be_invoked.luaScript); |
| | | LuaAPI.lua_pushstring(L, gen_to_be_invoked.fileName); |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _s_set_luaScript(RealStatePtr L) |
| | | static int _s_set_fileName(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | LuaBehaviour gen_to_be_invoked = (LuaBehaviour)translator.FastGetCSObj(L, 1); |
| | | gen_to_be_invoked.luaScript = (UnityEngine.TextAsset)translator.GetObject(L, 2, typeof(UnityEngine.TextAsset)); |
| | | gen_to_be_invoked.fileName = LuaAPI.lua_tostring(L, 2); |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 8ca74f47db9d1d44e8c094d697f8571d |
| | | timeCreated: 1533280632 |
| | | timeCreated: 1534325202 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
New file |
| | |
| | | #if USE_UNI_LUA |
| | | using LuaAPI = UniLua.Lua; |
| | | using RealStatePtr = UniLua.ILuaState; |
| | | using LuaCSFunction = UniLua.CSharpFunctionDelegate; |
| | | #else |
| | | using LuaAPI = XLua.LuaDLL.Lua; |
| | | using RealStatePtr = System.IntPtr; |
| | | using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; |
| | | #endif |
| | | |
| | | using XLua; |
| | | using System.Collections.Generic; |
| | | |
| | | |
| | | namespace XLua.CSObjectWrap |
| | | { |
| | | using Utils = XLua.Utils; |
| | | public class LuaWindowWrap |
| | | { |
| | | public static void __Register(RealStatePtr L) |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | System.Type type = typeof(LuaWindow); |
| | | Utils.BeginObjectRegister(type, L, translator, 0, 0, 2, 2); |
| | | |
| | | |
| | | |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "fileName", _g_get_fileName); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "injections", _g_get_injections); |
| | | |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "fileName", _s_set_fileName); |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "injections", _s_set_injections); |
| | | |
| | | |
| | | Utils.EndObjectRegister(type, L, translator, null, null, |
| | | null, null, null); |
| | | |
| | | Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | Utils.EndClassRegister(type, L, translator); |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int __CreateInstance(RealStatePtr L) |
| | | { |
| | | |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | if(LuaAPI.lua_gettop(L) == 1) |
| | | { |
| | | |
| | | LuaWindow gen_ret = new LuaWindow(); |
| | | translator.Push(L, gen_ret); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | } |
| | | catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return LuaAPI.luaL_error(L, "invalid arguments to LuaWindow constructor!"); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_fileName(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | LuaWindow gen_to_be_invoked = (LuaWindow)translator.FastGetCSObj(L, 1); |
| | | LuaAPI.lua_pushstring(L, gen_to_be_invoked.fileName); |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_injections(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | LuaWindow gen_to_be_invoked = (LuaWindow)translator.FastGetCSObj(L, 1); |
| | | translator.Push(L, gen_to_be_invoked.injections); |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _s_set_fileName(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | LuaWindow gen_to_be_invoked = (LuaWindow)translator.FastGetCSObj(L, 1); |
| | | gen_to_be_invoked.fileName = LuaAPI.lua_tostring(L, 2); |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _s_set_injections(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | LuaWindow gen_to_be_invoked = (LuaWindow)translator.FastGetCSObj(L, 1); |
| | | gen_to_be_invoked.injections = (Injection[])translator.GetObject(L, 2, typeof(Injection[])); |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
copy from Assets/Editor/Tool/GenerateClass.cs.meta
copy to Assets/XLua/Gen/LuaWindowWrap.cs.meta
File was copied from Assets/Editor/Tool/GenerateClass.cs.meta |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 09e90c049827e7c47bd5e7933618748f |
| | | timeCreated: 1504661855 |
| | | guid: 947b31a3c6a69914a93291c07a8bba91 |
| | | timeCreated: 1534325202 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | |
| | | { |
| | | XLua.LuaEnv.AddIniter((luaenv, translator) => { |
| | | |
| | | translator.DelayWrapLoader(typeof(ConfigUtil), ConfigUtilWrap.__Register); |
| | | |
| | | translator.DelayWrapLoader(typeof(LuaWindow), LuaWindowWrap.__Register); |
| | | |
| | | translator.DelayWrapLoader(typeof(LuaBehaviour), LuaBehaviourWrap.__Register); |
| | | |
| | | translator.DelayWrapLoader(typeof(XLuaTest.Pedding), XLuaTestPeddingWrap.__Register); |
| | |
| | | |
| | | translator.DelayWrapLoader(typeof(Tutorial.DrivenClassExtensions), TutorialDrivenClassExtensionsWrap.__Register); |
| | | |
| | | |
| | | |
| | | translator.AddInterfaceBridgeCreator(typeof(InvokeLua.ICalc), InvokeLuaICalcBridge.__Create); |
| | | |
| | | translator.AddInterfaceBridgeCreator(typeof(XLuaTest.IExchanger), XLuaTestIExchangerBridge.__Create); |
| | |
| | | <linker> |
| | | |
| | | <assembly fullname="Assembly-CSharp"> |
| | | <type fullname="LuaBehaviour" preserve="all"/> |
| | | <type fullname="ConfigUtil" preserve="all"/> |
| | | <type fullname="LuaWindow" preserve="all"/> |
| | | <type fullname="LuaBehaviour" preserve="all"/> |
| | | <type fullname="XLuaTest.Pedding" preserve="all"/> |
| | | <type fullname="XLuaTest.MyStruct" preserve="all"/> |
| | | <type fullname="XLuaTest.MyEnum" preserve="all"/> |
| | |
| | | <type fullname="Tutorial.DrivenClass+TestEnumInner" preserve="all"/> |
| | | <type fullname="Tutorial.ICalc" preserve="all"/> |
| | | <type fullname="Tutorial.DrivenClassExtensions" preserve="all"/> |
| | | <type fullname="luaCallCSharpTest" preserve="all"/> |
| | | |
| | | </assembly> |
| | | |