Beispiel #1
0
        static void GenerateModule(ModuleInfo moduleInfo, string path)
        {
            WrapGenerator.ExportPath = path;

            foreach (var t in moduleInfo)
            {
                WrapGenerator.GenerateClassWrap(moduleInfo.Name, t.type, t.generateSuperMembers, t.excludeMembers);
            }
        }
Beispiel #2
0
        public static void GenerateWraps()
        {
            WrapGenerator.Clear();

            var path = Application.dataPath + "/LunaFramework/SystemType/";

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            GenerateModule(Luna.systemModule, path);
            WrapGenerator.GenerateEnums();

            path = Application.dataPath + "/LunaFramework/BaseType/";
            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            GenerateModule(LunaClient.baseTypes, path);
            GenerateModule(LunaClient.mathTypes, path);
            GenerateModule(LunaClient.uiTypes, path);
            WrapGenerator.GenerateEnums();

            path = Application.dataPath + "/LunaFramework/CustomType/";
            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            //GenerateModule(LunaClient.customTypes, path);

            var types = typeof(LunaClient).Assembly.GetTypes();

            foreach (var t in types)
            {
                if (!t.IsSubclassOf(typeof(LunaClient)))
                {
                    continue;
                }

                var fields = t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                foreach (var fieldInfo in fields)
                {
                    var attr = fieldInfo.GetCustomAttribute(typeof(SharpLuna.LunaExportAttribute));
                    if (attr != null)
                    {
                        var moduleInfo = fieldInfo.GetValue(null) as ModuleInfo;
                        if (moduleInfo != null)
                        {
                            GenerateModule(moduleInfo, path);
                        }
                    }
                }
            }

            WrapGenerator.GenerateEnums();

            AssetDatabase.Refresh();
        }