-
Notifications
You must be signed in to change notification settings - Fork 115
API文档_Unity3D_CS_LuaExclude
vimfung edited this page Nov 19, 2018
·
1 revision
该类型主要对导出到lua中的类型进行注解,告诉框架原生类型那些属性、方法是不被导出到lua中的。用于控制lua对原生类型的访问权限。在需要排除的方法或属性中加入该注解即可实现导出限制。
[AttributeUsage(AttributeTargets.All)]
class LuaExclude : Attribute;
下例演示了如何限制Person
类的age
属性和walk
方法导出到lua中
public class Person : LuaExportType
{
private string _name;
public string name
{
get
{
return _name;
}
set
{
_name = value;
}
}
private int _age;
[LuaExclude]
public int age
{
get
{
return _age;
}
set
{
_age = value;
}
}
public void say(String text)
{
Debug.LogFormat("%s say: %s", name, text);
}
[LuaExclude]
public void walk()
{
Debug.LogFormat("%s walk", name);
}
public static Person createPerson()
{
return new Person();
}
}