Skip to content

Commit

Permalink
Fix error when turning visual debugging on/off in Unity 5.4 or newer
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeca committed Nov 21, 2016
1 parent 88383d7 commit 12385e5
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ScriptingDefineSymbols() {
_buildTargetToDefSymbol = Enum.GetValues(typeof(BuildTargetGroup))
.Cast<BuildTargetGroup>()
.Where(buildTargetGroup => buildTargetGroup != BuildTargetGroup.Unknown)
.Where(buildTargetGroup => !isBuildTargetObsolete(buildTargetGroup))
.Distinct()
.ToDictionary(
buildTargetGroup => buildTargetGroup,
Expand All @@ -37,5 +38,11 @@ public void RemoveDefineSymbol(string defineSymbol) {
);
}
}

bool isBuildTargetObsolete(BuildTargetGroup value) {
var fieldInfo = value.GetType().GetField(value.ToString());
var attributes = (ObsoleteAttribute[])fieldInfo.GetCustomAttributes(typeof(ObsoleteAttribute), false);
return (attributes != null && attributes.Length > 0);
}
}
}

0 comments on commit 12385e5

Please sign in to comment.