예제 #1
0
        public BindType(Type t)
        {
            type = t;
            name = LuaExport.GetTypeStr(t);
            if (t.IsGenericType)
            {
                libName  = LuaExport.GetGenericLibName(t);
                wrapName = LuaExport.GetGenericLibName(t);
            }
            else
            {
                libName  = t.FullName.Replace("+", ".");
                wrapName = name.Replace('.', '_');
                if (name == "object")
                {
                    wrapName = "System_Object";
                }
            }

            if (t.BaseType != null)
            {
                baseName = LuaExport.GetTypeStr(t.BaseType);
                if (baseName == "ValueType")
                {
                    baseName = null;
                }
            }
            if (t.GetConstructor(Type.EmptyTypes) == null && t.IsAbstract && t.IsSealed)
            {
                baseName = null;
                IsStatic = true;
            }
        }
예제 #2
0
        public static void Binding()
        {
            if (!Application.isPlaying)
            {
                EditorApplication.isPlaying = true;
            }

            BindType[] list = WrapFile.binds;

            for (int i = 0; i < list.Length; i++)
            {
                LuaExport.Clear();
                LuaExport.className     = list[i].name;
                LuaExport.type          = list[i].type;
                LuaExport.isStaticClass = list[i].IsStatic;
                LuaExport.baseClassName = list[i].baseName;
                LuaExport.wrapClassName = list[i].wrapName;
                LuaExport.libClassName  = list[i].libName;
                LuaExport.Generate(null);
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < list.Length; i++)
            {
                sb.AppendFormat("\t\t{0}Wrap.Register();\r\n", list[i].wrapName);
            }
            EditorApplication.isPlaying = false;

            GenLuaBinder();
            Debug.Log("Generate lua binding files over");
            AssetDatabase.Refresh();
        }
예제 #3
0
 private static string[] GetGenericName(Type[] types)
 {
     string[] results = new string[types.Length];
     for (int i = 0; i < types.Length; i++)
     {
         if (types[i].IsGenericType)
         {
             results[i] = GetGenericName(types[i]);
         }
         else
         {
             results[i] = LuaExport.GetTypeStr(types[i]);
         }
     }
     return(results);
 }