Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Package Manager packages support references to outside project

Discussion in 'Editor & General Support' started by roberto_sc, Jan 10, 2020.

  1. roberto_sc


    Dec 13, 2010
    I was surprised to find out that it is possible to have a package managed by Package Manager with references to the game project.

    I was moving some files from one project into a package to be used in a new project, using the Package Manager. I was following

    Some of these files have references to a plugin, so I had the idea to #ifdef the lines that use the plugin so if in the future someone decides to use the same plugin they can add a compilation directive to enable the code in the package. But then I thought it wouldn't work, because:

    1. maybe compilation directives from Player Preferences are not used when compiling packages;
    2. maybe packages are compiled before everyone else;
    3. the package has its own asmdef which doesn't point to the plugin.

    But it did work!

    Something doesn't look right here. What is happening?

    In my package I have a .cs file with the following:
    Code (CSharp):
    2. using Sirenix.OdinInspector;
    3. #endif
    If I add the package using the Package Manager, set USE_ODIN_INSPECTOR in PlayerPreferences and add the plugin to my project everything works fine.

    This is probably the first post where someone is complaining because something is working.
  2. AndrewRyan


    Apr 7, 2014
    I assume this works because you made your package expect to reference the plugin in the project. This wouldn't otherwise work if those scripts were loosely contained in the project space.