Search Unity

#define for imported packages

Discussion in 'Addressables' started by Jaimi, Jan 18, 2020.

  1. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    Is there a compiler define for imported packages?

    For example, if i import the Addressables package, is there something like this I can do?

    Code (csharp):
    1.  
    2. #if PACKAGE_ADDRESSABLES
    3.    // do all kinds of crazy, wacky addressable stuff here, that would create 8,000 compiler
    4.    // errors if the addressables package wasn't imported.
    5. #endif
    6.  
    Because if not, that would be absolutely fantastic.
     
    BruceKristelijn and AskCarol like this.
  2. AskCarol

    AskCarol

    Joined:
    Nov 12, 2019
    Posts:
    234
    Thanks! I'll bring this up with the team.
     
  3. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,065
  4. bsanterre

    bsanterre

    Joined:
    Oct 8, 2014
    Posts:
    22
    Adding my vote to this. Writing a third-party plugin, with integrations into various engine features (like Timeline), would be a lot easier if I could have a define for the presence of the TImeline package.

    Unfortunately, what Adrian suggested will not work, because my code lives outside of the Timeline package.
     
  5. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    The version defines feature does not require changes in the source package (Timeline in your example). It was created to fulfill the exact requirement you are asking for. We decided to go that way because we could not provide *symbols* for all packages plus their specific version. It would generate tons of symbols (maybe megabytes of) in builds that would be mostly unused. We know the feature is less intuitive than having static define. But it returns, it is much more powerful and efficient.

    Hope it helps,

    Pascal
     
  6. BruceKristelijn

    BruceKristelijn

    Joined:
    Apr 28, 2017
    Posts:
    107
    Did this ever get added? Or do I miss something? Could really use this!
     
  7. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    As mentioned previouslym this could be implemented through version defines: https://docs.unity3d.com/Manual/class-AssemblyDefinitionImporter.html#version-defines

    Static define as requested here is not possible, and as explained by Pascal, it will cause a define explosion that is not desirable.

    Moving forward, it is our scripting team at Unity who are working on things like this and it's out of the Package Managers team. For those here invested in this, would you like me to move the thread to their subforum, or would you like to raise this yourselves in a new thread?
     
  8. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    I honestly don't see how this helps us asset creators who rely on other peoples packages, but sure, feel free to move it.