Skip to content

Commit

Permalink
add IgnoreBaseAttribute to skip auto gen event base
Browse files Browse the repository at this point in the history
  • Loading branch information
pangweiwei committed Nov 26, 2015
1 parent 1655e36 commit 7020492
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Assets/Plugins/Slua_Managed/LuaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public StaticExportAttribute()

public class LuaOut { }

[AttributeUsage(AttributeTargets.Class)]
public class IgnoreBaseAttribute : System.Attribute
{
public IgnoreBaseAttribute()
{
//
}
}

public partial class LuaObject
{

Expand Down
2 changes: 1 addition & 1 deletion Assets/Slua/Editor/LuaCodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ public bool Generate(Type t)
RegFunction(t, file);
End(file);

if (t.BaseType != null && t.BaseType.Name == "UnityEvent`1")
if (t.BaseType != null && t.BaseType.Name == "UnityEvent`1" && !t.IsDefined(typeof(IgnoreBaseAttribute),false))
{
string f = path + "LuaUnityEvent_" + _Name(GenericName(t.BaseType)) + ".cs";
file = new StreamWriter(f, false, Encoding.UTF8);
Expand Down
11 changes: 10 additions & 1 deletion Assets/Slua/example/HelloWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ public struct foostruct
}

[CustomLuaClass]
public class SLuaTest : MonoBehaviour { }
[IgnoreBase] // skip auto gen "UnityEngine.Events.UnityEvent<int>" to avoid conflict
public class IntEvent : UnityEngine.Events.UnityEvent<int>
{
public IntEvent() { }
}

[CustomLuaClass]
public class SLuaTest : MonoBehaviour {
public IntEvent intevent;
}

[CustomLuaClass]
public class XXList : List<int> { }
Expand Down

0 comments on commit 7020492

Please sign in to comment.