An open API service indexing awesome lists of open source software.

https://github.com/jdsherbert/unity-define-scripting-symbols

Script to add the specified scripting define symbols to the build settings (once script compilation has finished.)
https://github.com/jdsherbert/unity-define-scripting-symbols

csharp define symbols unity unity-2d unity-3d unity2d unity3d unityengine

Last synced: 9 months ago
JSON representation

Script to add the specified scripting define symbols to the build settings (once script compilation has finished.)

Awesome Lists containing this project

README

          

![image](https://github.com/JDSherbert/Unity-Define-Scripting-Symbols/assets/43964243/3c7f083e-8465-4f19-b7e5-f558c5309d2f)

# Unity - Define Scripting Symbols



Stars Badge
Forks Badge
Watchers Badge
Issues Badge

-----------------------------------------------------------------------


Extension Tool For Unity



License



-----------------------------------------------------------------------
## Overview

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:
```cs
///
/// Symbols to add to build settings.
///
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:

```cs
#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

}
```