Search Unity

#if UNITY_WEBGL && !UNITY_EDITOR not get stripped in webgl build:D

Discussion in 'Web' started by suiboli, Sep 7, 2020.

  1. suiboli

    suiboli

    Joined:
    Mar 27, 2020
    Posts:
    11
    Update: Both
    #if UNITY_WEBGL && !UNITY_EDITOR
    and
    #if UNITY_WEBGL && !UNITY_EDITOR
    work as intended;).
    ---
    Update: It turns out to be some functions name conflicts in web template index.html, while the functionality of platform specific compilation code has not been tested yet. Thank you for your time.
    ---
    Editor: 2019.4.9f1.
    In convenience of testing in editor, I tried to use platform dependent compilation,
    #if UNITY_WEBGL && !UNITY_EDITOR
    , for those running only in webgl, such as
    recieveData(string json)
    method called by javaSritpts,
    [DllImport("__Internal")] private static extern void querySceneCode();
    jslib plugin method, etc.

    And
    #if UNITY_EDITOR
    for those testing in Editor only.

    But the webgl-only codes,
    #if UNITY_WEBGL && !UNITY_EDITOR
    , seem to be stripped in build.

    In addition, I tried
    #if !UNITY_WEBGL || UNITY_EDITOR
    for the codes not for webgl build,
    but it seems to always run in runtime in webgl build.

    Any Help will be appreciated.
     
    Last edited: Sep 8, 2020
    dan_ginovker likes this.