Skip to content

Commit

Permalink
fix for unity 2017.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pangweiwei committed Nov 8, 2017
1 parent a550aef commit 81a636d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Assets/Plugins/Slua_Managed/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void TracebackErr(string msg, bool hasStacktrace = false)
UnityEngine.Application.SetStackTraceLogType (UnityEngine.LogType.Error, Type);
#else
UnityEngine.Debug.LogError(msg);
#endif
#endif
}


Expand Down
108 changes: 66 additions & 42 deletions Assets/Slua/Editor/LuaCodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ static bool filterType(Type t, List<string> noUseList, List<string> uselist)
static public void Generate()
{
#if UNITY_2017_2_OR_NEWER
GenerateFor("UnityEngine.CoreModule", "Unity/", 0, "BindUnity");
GenerateFor(new string[] { "UnityEngine.CoreModule",
"UnityEngine.UnityWebRequestWWWModule",
"UnityEngine.PhysicsModule" }, "Unity/", 0, "BindUnity");
#else
GenerateFor("UnityEngine", "Unity/", 0, "BindUnity");
#endif
Expand All @@ -174,66 +176,91 @@ static public void GenerateAds()
GenerateFor("UnityEngine.Advertisements", "Unity/", 2, "BindUnityAds");
}

static public void GenerateFor(string asemblyName, string genAtPath, int genOrder, string bindMethod)
{
if (IsCompiling)
static List<Type> GetExportsType(string[] asemblyNames, string genAtPath) {

List<Type> exports = new List<Type>();

foreach (string asemblyName in asemblyNames)
{
return;
}
Assembly assembly;
try { assembly = Assembly.Load(asemblyName); }
catch (Exception) { continue; }

Assembly assembly;
try { assembly = Assembly.Load(asemblyName); }
catch (Exception) { return; }
Type[] types = assembly.GetExportedTypes();

Type[] types = assembly.GetExportedTypes();
List<string> uselist;
List<string> noUseList;

List<string> uselist;
List<string> noUseList;
CustomExport.OnGetNoUseList(out noUseList);
CustomExport.OnGetUseList(out uselist);

CustomExport.OnGetNoUseList(out noUseList);
CustomExport.OnGetUseList(out uselist);
// Get use and nouse list from custom export.
object[] aCustomExport = new object[1];
InvokeEditorMethod<ICustomExportPost>("OnGetUseList", ref aCustomExport);
if (null != aCustomExport[0])
{
if (null != uselist)
{
uselist.AddRange((List<string>)aCustomExport[0]);
}
else
{
uselist = (List<string>)aCustomExport[0];
}
}

// Get use and nouse list from custom export.
object[] aCustomExport = new object[1];
InvokeEditorMethod<ICustomExportPost>("OnGetUseList", ref aCustomExport);
if (null != aCustomExport[0])
{
if (null != uselist)
aCustomExport[0] = null;
InvokeEditorMethod<ICustomExportPost>("OnGetNoUseList", ref aCustomExport);
if (null != aCustomExport[0])
{
uselist.AddRange((List<string>)aCustomExport[0]);
if ((null != noUseList))
{
noUseList.AddRange((List<string>)aCustomExport[0]);
}
else
{
noUseList = (List<string>)aCustomExport[0];
}
}
else

string path = GenPath + genAtPath;
foreach (Type t in types)
{
uselist = (List<string>)aCustomExport[0];
if (filterType(t, noUseList, uselist) && Generate(t, path))
exports.Add(t);
}
Debug.Log("Generate interface finished: " + asemblyName);
}
return exports;
}

aCustomExport[0] = null;
InvokeEditorMethod<ICustomExportPost>("OnGetNoUseList", ref aCustomExport);
if (null != aCustomExport[0])
static public void GenerateFor(string[] asemblyNames, string genAtPath, int genOrder, string bindMethod) {
if (IsCompiling)
{
if ((null != noUseList))
{
noUseList.AddRange((List<string>)aCustomExport[0]);
}
else
{
noUseList = (List<string>)aCustomExport[0];
}
return;
}

List<Type> exports = new List<Type>();
List<Type> exports = GetExportsType(asemblyNames, genAtPath);
string path = GenPath + genAtPath;
foreach (Type t in types)
GenerateBind(exports, bindMethod, genOrder, path);
if (autoRefresh)
AssetDatabase.Refresh();
}

static public void GenerateFor(string asemblyName, string genAtPath, int genOrder, string bindMethod)
{
if (IsCompiling)
{
if (filterType(t, noUseList, uselist) && Generate(t, path))
exports.Add(t);
return;
}


List<Type> exports = GetExportsType(new string[] { asemblyName }, genAtPath);
string path = GenPath + genAtPath;
GenerateBind(exports, bindMethod, genOrder, path);
if (autoRefresh)
AssetDatabase.Refresh();
Debug.Log("Generate interface finished: " + asemblyName);

}

static String FixPathName(string path) {
Expand Down Expand Up @@ -604,9 +631,6 @@ static bool Generate(Type t, string path)

static bool Generate(Type t, string ns, string path)
{
//if (t.IsInterface)
// return false;

CodeGenerator cg = new CodeGenerator();
cg.givenNamespace = ns;
cg.path = path;
Expand Down

0 comments on commit 81a636d

Please sign in to comment.