Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Undocumented Unity-controlled Define symbols

Discussion in 'General Discussion' started by casimps1, Apr 8, 2014.

  1. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    I know about platform-specific defines which are documented here:

    https://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html

    But today I realized that Unity actually puts a lot more Defines into the Mono project than just those listed on that page. The list of defines in my current C# project I'm working on in Windows is here (This comes from the Compiler options under my Assembly-CSharp mono project):

    DEBUG;
    TRACE;
    UNITY_ANDROID;
    ENABLE_MICROPHONE;
    ENABLE_TEXTUREID_MAP;
    ENABLE_AUDIO_FMOD;
    ENABLE_MONO;
    ENABLE_SPRITES;
    ENABLE_TERRAIN;
    ENABLE_GENERICS;
    ENABLE_SUBSTANCE;
    INCLUDE_WP8SUPPORT;
    ENABLE_WWW;
    ENABLE_IMAGEEFFECTS;
    ENABLE_WEBCAM;
    INCLUDE_METROSUPPORT;
    RENDER_SOFTWARE_CURSOR;
    ENABLE_NETWORK;
    ENABLE_PHYSICS;
    ENABLE_CACHING;
    ENABLE_CLOTH;
    UNITY_ANDROID_API;
    ENABLE_2D_PHYSICS;
    ENABLE_SHADOWS;
    ENABLE_AUDIO;
    ENABLE_NAVMESH_CARVING;
    ENABLE_SINGLE_INSTANCE_BUILD_SETTING;
    UNITY_4_3_2;
    UNITY_4_3;
    ENABLE_PROFILER;
    UNITY_EDITOR;
    UNITY_EDITOR_WIN​

    So, I see the defines I expected to see based on the documentation, but there are many many more as well. Now, most of these defines clearly come from Unity as they correspond to Unity features (e.g. - terrain, 2D physics, etc.), but I can find no documentation on them anywhere. It makes me wonder what they would be used for and if there is any way to control them. For example, is there some hidden option to disable terrain if your game doesn't use that system, possibly reducing build size?

    I also noticed that when I tick the "Development Build" checkbox on my Build Settings in the Unity Editor it updates the C# Mono project to also include the DEVELOPMENT_BUILD define. So, it appears that Unity will modify these defines based on settings specified in the Unity Editor.

    Does anyone have any insight into any of these extra defines?
     
    v01pe_ likes this.
  2. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    292
    If there's no documentation, it would be because they are only used internally to control the options for their rendering pipeline, occlusion system, editor, and other Unity black boxes. Unity would turn them off and on based on your project settings.

    If you pay up for a source license, there is probably super secret documentation on all of them Unity would release to you.
     
  3. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    I would say that all those ENABLE_* belong to the build stripping and are used internally to compile unitys own engine code..
     
  4. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Just stick to the documented ones. :)
     
  5. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,500
    Yeah, I'd suspect that they're undocumented because we're not meant to mess with them. They're probably there for internal testing/configuration/deployment pipeline/etc.
     
  6. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    But undocumented features make me feel like a hacker! :)
     
  7. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    :) Then doit. But if you have any problems, just hack your way out of them.
     
    joshcamas likes this.
  8. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    265
    Heey, maybe I can use this one... It's really annoying how OnAudioFilterRead will continue playing audio even when you hard disable audio within unity.
     
  9. JanWosnitza

    JanWosnitza

    Joined:
    Jun 23, 2012
    Posts:
    6
    These are compile-flags in VisualStudio (Project Properties -> Build Tab) and nothing Unity special. These are pretty usefull in non-Unity projects. Since Unity defines "DEVELOPMENT_BUILD" and "UNITY_EDITOR" they're more or less useless.
     
  10. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    241
    Last edited: Oct 7, 2022
  11. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,071
    You mean aside from trying to use something that is undocumented?