I have written my method which adds a new script define, I call it in the preprocess build script and for the test after the adding method there is a fragment marked compile directive with Debug.Log, unfortunately this code does not execute, only during the second build it executes. Is it possible to refresh the code after adding the script define in the preprocess script?
Code:
public class PreProcessTest : IPreprocessBuildWithReport
{
public int callbackOrder { get; }
public void OnPreprocessBuild(BuildReport report)
{
AddScriptDefine("TEST_SCRIPT_DEFINE");
#if TEST_SCRIPT_DEFINE
Debug.Log("Test!");
#endif
Debug.Log("End");
}
private static void AddScriptDefine(string scriptDefine)
{
PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, out string[] defines);
string[] newDefines = new string[defines.Length + 1];
for (int i = 0; i < defines.Length; i++)
newDefines[i] = defines[i];
newDefines[newDefines.Length - 1] = scriptDefine;
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, newDefines);
}