Small script to automatically add scripting defines to your Unity build. The defines you specify in the readonly string class will be added when the script is compiled. They will be added in the order you've defined. You can read more about defining custom scripting symbols here: https://docs.unity3d.com/Manual/CustomScriptingSymbols.html
Be aware that this script must be put into an "Editor" folder in order to work correctly.
You can add the additional scripting defines like this:
/// <summary>
/// Symbols to add to build settings.
/// </summary>
public static readonly string[] Symbols = new string[]
{
"SOME_SYMBOL",
"ANOTHER_SYMBOL",
"MY_ENGINE_DEF",
"ENABLE_DEBUG"
};
Here is an example of using those defined symbols when building code:
#if MY_SYMBOL
using MyNamespace;
#endif
public class MyClass
{
#if MY_SYMBOL
public void SomeFunc()
{
//Do Something here if your symbol is defined
}
#endif
#if !MY_SYMBOL
public void SomeFunc()
{
//throw some exception if not defined
throw new Exception("My symbol is not defined!");
}
#endif
}