Skip to content

Commit

Permalink
修改LuaUIHelper使其支持新的url格式
Browse files Browse the repository at this point in the history
  • Loading branch information
ytom committed Mar 7, 2017
1 parent f4922b5 commit 9427052
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions LuaSupport/ToLua/LuaUIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@ namespace FairyGUI
/// </summary>
public sealed class LuaUIHelper
{
static Dictionary<string, LuaFunction> packageItemExtensions = new Dictionary<string, LuaFunction>();

/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="luaClass"></param>
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();
Expand Down

0 comments on commit 9427052

Please sign in to comment.