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.)
- Host: GitHub
- URL: https://github.com/jdsherbert/unity-define-scripting-symbols
- Owner: JDSherbert
- License: mit
- Created: 2023-12-04T01:06:11.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T17:52:16.000Z (about 2 years ago)
- Last Synced: 2025-02-13T22:38:12.908Z (11 months ago)
- Topics: csharp, define, symbols, unity, unity-2d, unity-3d, unity2d, unity3d, unityengine
- Language: C#
- Homepage:
- Size: 30.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Unity - Define Scripting Symbols
-----------------------------------------------------------------------
-----------------------------------------------------------------------
## 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
}
```