Giter Site home page Giter Site logo

jdsherbert / unity-define-scripting-symbols Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 31 KB

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

License: MIT License

C# 100.00%
csharp define symbols unity unity-2d unity-3d unity2d unity3d unityengine

unity-define-scripting-symbols's Introduction

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

}

unity-define-scripting-symbols's People

Contributors

jdsherbert avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.