Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Platform settings for packages

Discussion in 'Package Manager' started by Virtuactions, Feb 13, 2019.

  1. Virtuactions

    Virtuactions

    Joined:
    Jun 5, 2017
    Posts:
    13
    Is there any way to select platforms for packages like for plugins or asmdef files and use Define Constaints?
     
  2. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    144
    Hi @Virtuactions,

    At this time, packages are platform-agnostic, and Define Symbols are a compilation feature. However plugins and asmdefs in packages can be platform-aware, so you could have packages that are effectively not used when present in a project with the wrong platform enabled.

    You could also implement something like a bootstrap package that will use the
    PackageManager.Client.List
    API to look at current packages, and
    PackageManager.Client.Add
    API to add the necessary package when detecting a platform change. I'm not sure about specific programmatic hooks for that, but you could easily hack something using
    InitializeOnLoadAttribute
    or
    InitializeOnLoadMethodAttribute
    .