Search Unity

Build Script for Disabled Addressables in editor

Discussion in 'Addressables' started by dwit_mass_creation, Feb 5, 2020.

  1. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    74
    I've attached editor script (add it to any Editor folder) for Disabling Addressables in Editor mode.

    You can then add new group with this script to "Build and Play mode scripts" in AddressableAssetSettings asset. Then choose in Addressables Groups in "Play Mode Script" "Use No Addressables (disabled)".

    Currently (for like 10% of target assets in Addressables) entering Play Mode in editor with "Use Asset Database (faster)" is taking more than 10 seconds (only for caching Addressables). So for all assets it will take more than 1 minute to enter Play Mode.

    In editor then I just use direct references and in build mode I build Addressables and use address references.
    If I want to test Addressables in Editor (I don't 99.9% of time) I can just enable "Use Asset Database (faster)" and custom define (for example USE_ADDRESSABLES):

    Code (CSharp):
    1. #if UNITY_EDITOR || !USE_ADDRESSABLES
    2.         public GameObject asset;
    3. #endif
    4.  
    5. #if UNITY_EDITOR || USE_ADDRESSABLES
    6. public string address;      
    7. #endif
    It's all about iteration time. This way you can add Addressables at any time in development and not worry about Play mode start times (especially if you don't care about build which does one person or automated server). That way you do not waste time for all other developers (artists, designers etc).

    Is there any other way to disable addressables in editor only? Clearing or setting addresses for assets is currently taking Unity several minutes (many assets) so it's not viable.
     

    Attached Files: