Skip to content

Commit

Permalink
Fix warning in Unity 2017.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbad authored and jacobdufault committed Jul 29, 2020
1 parent 5757870 commit dbea7d5
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions Assets/FullSerializer/Source/Aot/Editor/fsAotConfigurationEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,39 @@ namespace FullSerializer {
[InitializeOnLoad]
public static class PlayStateNotifier {
static PlayStateNotifier() {
EditorApplication.playmodeStateChanged += ModeChanged;
#if UNITY_2017_2_OR_NEWER
EditorApplication.playModeStateChanged += ModeChanged;
#else
EditorApplication.playmodeStateChanged += ModeChanged;
#endif
}

private static void ModeChanged () {
if (!EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying) {
Debug.Log("There are " + fsAotCompilationManager.AotCandidateTypes.Count + " candidate types");
foreach (fsAotConfiguration target in Resources.FindObjectsOfTypeAll<fsAotConfiguration>()) {
var seen = new HashSet<string>(target.aotTypes.Select(t => t.FullTypeName));
foreach (Type type in fsAotCompilationManager.AotCandidateTypes) {
if (seen.Contains(type.FullName) == false) {
target.aotTypes.Add(new fsAotConfiguration.Entry(type));
EditorUtility.SetDirty(target);
}
private static void LogCandidateTypes() {
Debug.Log("There are " + fsAotCompilationManager.AotCandidateTypes.Count + " candidate types");
foreach (fsAotConfiguration target in Resources.FindObjectsOfTypeAll<fsAotConfiguration>()) {
var seen = new HashSet<string>(target.aotTypes.Select(t => t.FullTypeName));
foreach (Type type in fsAotCompilationManager.AotCandidateTypes) {
if (seen.Contains(type.FullName) == false) {
target.aotTypes.Add(new fsAotConfiguration.Entry(type));
EditorUtility.SetDirty(target);
}
}
}
}

#if UNITY_2017_2_OR_NEWER
private static void ModeChanged (PlayModeStateChange c) {
if (c == PlayModeStateChange.EnteredPlayMode) {
LogCandidateTypes();
}
}
#else
private static void ModeChanged () {
if (!EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying) {
LogCandidateTypes();
}
}
#endif
}

[CustomEditor(typeof(fsAotConfiguration))]
Expand Down

0 comments on commit dbea7d5

Please sign in to comment.