Skip to content

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

License

Notifications You must be signed in to change notification settings

JDSherbert/Unity-Define-Scripting-Symbols

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

image

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:

/// <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

}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages