Posts Tagged preprocessor

IL2CPP Output for C# 7.3: Everything Else

Tags: , , , , ,

Today we conclude the series by looking at all the remaining features in C# 7.3 that we get access to in Unity 2018.3. Read on to learn about new kinds of structs, in parameters, new where constraints, discards, default literals, generalized async returns, and new preprocessor symbols!

Read the rest of this article »

1 Comment

C++ Scripting: Part 8 – Platform-Dependent Compilation

Tags: , , , ,

The series continues today to fill a small, but important gap in the C++ plugin’s build script. Unity helpfully provides symbols like UNITY_IOS for us to check with #if. This lets us add and remove blocks of code that should only be present in a certain build of the game. We’d like the same functionality in C++ that Unity provides to C#, so today we’ll upgrade the build script to allow that.

Read the rest of this article »

No Comments

How to Detect If the Unity Engine Is Available

Tags: ,

Sometimes we write code that’s meant to be run outside of the Unity engine. This could be anything from unit tests being run in MonoDevelop or Visual Studio to shared code that’s used on a multiplayer server. Regardless, the Unity engine isn’t available for use unless you’re running in the editor or a deployed build. This means you’ll have problems whenever you access the Unity engine via Debug.Log, GameObject, or MonoBehaviour. Today’s article shares some quick tips that enable you to tweak your code so that you can detect whether the Unity engine is available for use. Read on to learn how!

Read the rest of this article »


Easily “Compile Out” Function Calls

Tags: , ,

Taking another break from the iterator series, this week we’ll take a look at an exciting .NET feature that can easily and cleanly remove the calls to a function throughout the whole code base. Unity uses this for Debug.Assert and you can use it for all sorts of functions, too. Wouldn’t it be nice if we could strip out all the debug functions from the production build of our game but leave them in during development? Read on to learn how!

Read the rest of this article »


From AS3 to C#, Part 20: Preprocessor Directives

Tags: ,

Today’s article continues the series by looking at C#’s preprocessor support, which is like an expanded version of AS3’s compile-time constants and conditional compilation. Read on to learn about all the strange (and powerful) #something lines you can put in your code.

Read the rest of this article »