Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    545
    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
    .