fix exported type getting in unity 2017.2 or newer
@@ -45,9 +45,12 @@ namespace SLua
static bool autoRefresh = true;
- static bool IsCompiling {
- get {
- if (EditorApplication.isCompiling) {
+ static bool IsCompiling
+ {
+ get
+ {
+ if (EditorApplication.isCompiling)
+ {
Debug.Log("Unity Editor is compiling, please wait.");
}
return EditorApplication.isCompiling;
@@ -62,9 +65,11 @@ namespace SLua
{
EditorApplication.update += Update;
// use this delegation to ensure dispose luavm at last
- EditorApplication.playmodeStateChanged+=()=>{
+ EditorApplication.playmodeStateChanged += () =>
+ {
- if(isPlaying==true && EditorApplication.isPlaying==false) {
+ if (isPlaying == true && EditorApplication.isPlaying == false)
+ {
if (LuaState.main != null) LuaState.main.Dispose();
}
@@ -73,7 +78,8 @@ namespace SLua
}
- static void Update(){
+ static void Update()
+ {
EditorApplication.update -= Update;
Lua3rdMeta.Instance.ReBuildTypes();
@@ -120,7 +126,8 @@ namespace SLua
static bool filterType(Type t, List<string> noUseList, List<string> uselist)
{
- if (t.IsDefined (typeof(CompilerGeneratedAttribute),false)) {
+ if (t.IsDefined(typeof(CompilerGeneratedAttribute), false))
+ {
Debug.Log(t.Name + " is filtered out");
return false;
}
@@ -148,7 +155,11 @@ namespace SLua
[MenuItem("SLua/Unity/Make UnityEngine")]
static public void Generate()
{
+#if UNITY_2017_2_OR_NEWER
+ GenerateFor("UnityEngine.CoreModule", "Unity/", 0, "BindUnity");
+#else
GenerateFor("UnityEngine", "Unity/", 0, "BindUnity");
+#endif
}
[MenuItem("SLua/Unity/Make UnityEngine.UI")]
@@ -605,7 +616,16 @@ namespace SLua
static void GenerateBind(List<Type> list, string name, int order,string path)
{
// delete wrapper dll
+ try
+ {
System.IO.File.Delete(GenPath + WrapperName);
+ }
+ catch {}
+
+ if (!Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);
+ }
CodeGenerator cg = new CodeGenerator();
cg.path = path;
