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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UNITY_ANDROID #if Problem

Discussion in 'Editor & General Support' started by steveg2357, Sep 8, 2015.

  1. steveg2357

    steveg2357

    Joined:
    Aug 21, 2014
    Posts:
    34
    I’m using Unity 5.1.3 with MonoDevelop on a Mac with Yosemite 10.10.5 and I’m having problems with #if statements, For example, when I do

    #if UNITY_ANDROID
    something1
    #elif UNITY_IPHONE
    something2
    #else
    something3
    #endif

    in MonoDevelop it shows autocompletion for UNITY_ANDROID and “No completion found” for UNITY_IPHONE. In addition, something2 and something3 are grayed out but something1 is not. I can successfully build in MonoDevelop but get an Android compile error when I try to run this in Unity Editor. [something1 contains UnityEngine Android and Java statements.]

    Steve
     
  2. steveg2357

    steveg2357

    Joined:
    Aug 21, 2014
    Posts:
    34
    I just tried the same thing on Windows 8 64 bit with the same result. Autocompletion of UNITY_ shows UNITY_5, UNITY_5_1, UNITY_5_1_3, UNITY_ANDROID, UNITY_ANDROID_API, UNITY_ASSERTIONS, UNITY_EDITOR and UNITY_EDITOR_64. It also shows UNITY_EDITOR_OSX on a Mac and UNITY_EDITOR_WIN on Windows.
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    I think you can only get auto-completion for symbols that are currently defined...