Adding changed check to PreprocessorDefine (#1698)

* Adding changed check to PreprocessorDefine

this stops ProjectSettings being marked as dirty each time the editor is opened

* Update PreprocessorDefine.cs

Co-authored-by: vis2k <info@noobtuts.com>
This commit is contained in:
James Frowen 2020-04-13 09:14:04 +01:00 committed by GitHub
parent 8aabb54929
commit eec45ff8fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,8 @@ static class PreprocessorDefine
[InitializeOnLoadMethod]
public static void AddDefineSymbols()
{
HashSet<string> defines = new HashSet<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';'))
string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
HashSet<string> defines = new HashSet<string>(currentDefines.Split(';'))
{
"MIRROR",
"MIRROR_1726_OR_NEWER",
@ -27,7 +28,14 @@ public static void AddDefineSymbols()
"MIRROR_11_0_OR_NEWER",
"MIRROR_12_0_OR_NEWER"
};
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", defines));
// only touch PlayerSettings if we actually modified it.
// otherwise it shows up as changed in git each time.
string newDefines = string.Join(";", defines);
if (newDefines != currentDefines)
{
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newDefines);
}
}
}
}