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

Is there any definition when a package imported?

Discussion in 'Package Manager' started by watsonsong, May 15, 2019.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    374
    I want to check whether a specify package has imported using `#if #end` scope, which make my code work correctly both in the project with or without specify package.
    How can I do this, is there any definition can tell me a package is imported?
     
  2. mathieur

    mathieur

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    29
    Hello! You can achieve this by creating a define when a package is present on the assembly definition asset of your package.

    Here is an example that would add a ADS_PRESENT definition for your C# code when the ads package is present, for this assembly:

    Screen Shot 2019-05-14 at 5.09.05 PM.png