Unity macro definition

  1. What is the macro definition: it is to execute different code in different environments, such as executing different code on the Android platform and on the Apple platform, so that you can compile the code specifically for your target platform

    1. Are there any built-in macros in Unity?

      1. UNITY_EDITOR called in the Unity editor
      2. UNITY_ANDROID Android Platform
      3. UNITY_IPHONE Apple platform.
    2. grammar

      
      #if UNITY_EDITOR
      
       youkeBtn.gameObject.SetActive(false);
       weChatBtn.gameObject.SetActive(true);
      
      #endif
      
      
      #if UNITY_ANDROID || UNITY_IPHONE
      
       youkeBtn.gameObject.SetActive(true);
       weChatBtn.gameObject.SetActive(false);
      
      #endif
      
      
      #if UNITY_STANDALONE
      
      Debig.Log("PC平台(包括window,Mac,Linux)")
      
      #endif
      
    3. custom macro definition

      1. Set in OtherSetting under Unity's PlayerSetting. After setting, you need to click the Enter key to take effect.
        write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325543540&siteId=291194637