From 9427052ad5d3e43b71fdde1ce542b126b34556cc Mon Sep 17 00:00:00 2001 From: ytom Date: Tue, 7 Mar 2017 09:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9LuaUIHelper=E4=BD=BF=E5=85=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=96=B0=E7=9A=84url=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaSupport/ToLua/LuaUIHelper.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/LuaSupport/ToLua/LuaUIHelper.cs b/LuaSupport/ToLua/LuaUIHelper.cs index 3b5fafe1..f2b89c82 100644 --- a/LuaSupport/ToLua/LuaUIHelper.cs +++ b/LuaSupport/ToLua/LuaUIHelper.cs @@ -10,8 +10,6 @@ namespace FairyGUI /// public sealed class LuaUIHelper { - static Dictionary packageItemExtensions = new Dictionary(); - /// /// /// @@ -19,17 +17,22 @@ public sealed class LuaUIHelper /// public static void SetExtension(string url, System.Type baseType, LuaFunction extendFunction) { - UIObjectFactory.SetPackageItemExtension(url, baseType); - packageItemExtensions[url] = extendFunction; + UIObjectFactory.SetPackageItemExtension(url, () => { + GComponent gcom = (GComponent)Activator.CreateInstance(baseType); + gcom.data = extendFunction; + return gcom; + }); } [NoToLuaAttribute] public static LuaTable ConnectLua(GComponent gcom) { LuaTable _peerTable = null; - LuaFunction extendFunction; - if (LuaUIHelper.packageItemExtensions.TryGetValue(gcom.resourceURL, out extendFunction)) + LuaFunction extendFunction = gcom.data as LuaFunction; + if (extendFunction!=null) { + gcom.data = null; + extendFunction.BeginPCall(); extendFunction.Push(gcom); extendFunction.PCall();