Skip to content

Preprocessor Directives

scottyboy805 edited this page Jan 5, 2022 · 4 revisions

The following define directives can be used to change the behavior or profile the interpreter:

  • API_NET35 - Forces dotnow to use .Net 3.5 API's and C# 4 language features for compatibility with legacy Unity versions.
  • UNSAFE - Allows the interpreter to take advantage of unsafe code principles like pointers to execute CIL code quicker. This is not fully implemented yet and should be disabled in most cases for now.
  • UNITY_EDITOR - The interpreter is running inside the Unity editor environment. 'Debug.Log' will be used to provide additional information in errors.
  • UNITY_STANDALONE - The interpreter is running on a Unity standalone platform. Same feature as above (output to application log file, or debug console).
  • UNITY_PROFILE - The interpreter will mark each method call in the unity profiler window for easy analysis of CLR method execution times. Note that this will impact interpreter performance.
  • UNITY_PROFILE_INSTRUCTIONS - (WARNING: This will cause severe performance issues and should only be used for testing small, non-looping code snippets) The interpreter will mark each executed instruction in the Unity profiler window so that the performance of individual instructions can be analyzed. Use with caution to avoid editor crashes or freezes.
  • UNITY_DISABLE - Disables usage of Unity API throughout the entire code base. Mainly added to support unit tests where internal calls to Unity API methods would cause issues.
  • ROSLYNCSHARP - Used to enable seamless add-on integration with the Unity Roslyn C# Compiler asset. Allows for compilation and execution (Interpreted) of C# code at runtime on IL2CPP platforms.
Clone this wiki locally