I have had a lot of frustration with this relatively new feature, but I’m not here to complain. I am offering the solution to users facing the same struggle that I had. The solution isn’t even difficult, it just wasn’t obvious to me. Perhaps I was too accustomed to the old way. If I am incorrect about any of this or missing information, please let me know.
The Problem
I understand that users have asked for better export options when it comes to including script dependencies. However, the “fix” to this was apparently to force ALL scripts to be included as dependencies when ANY script is exported. Really? This was the fix? This creates all new dangers that involve overwriting scripts in the destination project, scripts that have nothing to do with the export and should never have been exported in the first place. You can avoid this by not including dependencies, but then you loose all meta-data asset dependencies! I know that you can manually select dependencies, but when doing this for multiple assets it was not particularly intuitive.
The Solution
Here is an example of how to export multiple objects and their asset dependencies without automatically including all scripts.
Assume you have a Player prefab and an Enemy prefab, each with their respective components, meta-data, and scripts. You want to export them both into one package but not include every single script in your project (without having to manually uncheck a large number of scripts from the export dialog).
Right-click the Player prefab and choose “Select Dependencies”.
Navigate to the Enemy prefab and do the same thing… but before you do this, hold CONTROL (Windows).
The newly selected dependencies will be added to the previously selected ones (in the Inspector window).
Now you can right click and “Export Package”.
Make sure to de-select “Include Dependencies” before exporting.
This of course works for more than two objects, keep going as far as you need.
To the devs
The most friendly option for this seems to just have two different “Include Dependency” check-box options in the export dialog. One that says “Include Asset/Meta Dependencies” and one that says “Include All Scripts”. We get the best of both worlds without any confusion. Of course the best option seems to be for the exporter to only include scripts that actually are dependencies, but I realize that would be much more involved, and in the end, a dependency based export will always have special considerations.
Anyway, I hope this helps even just one person who struggled with the new export system in the way I did.
I had nightmares with this eventually I selected the unity scene and right click did select dependencies, then right click did export asset from this, you actually only get what you need this way. The other way is bugged.
Even with this method, not all dependencies are correctly selected though :
I have a Monobehaviour that depends on an Enum which was declared in a different file. After selecting the dependencies, the file containing the Enum was not selected.
I thought maybe I was doing something wrong when I tried to click the select all dependencies checkbox and it started pulling in every .cs script in the project. At least I know why now.
Yeah 2019 and this is still incredibly confusing from an end user perspective. Even sadder that I had to find the answer on a forum instead of the UI indicating to me that the “select all dependencies” box was just going to select everything.
I think Unity could benefit from some in editor popups warning you when a button has a label that results in something other than what the label describes happening.
It could be as simple as a tooltip that pops when you hover over the button that says “WARNING: THIS WILL SELECT ALL SCRIPTS, EVEN ONES THAT ARE TOTALLY NOT DEPENDENCIES!!!”
(Apologies for necroing an 8-year-old thread but this source control would save SO many developers who show up here on the boards in a hot panic because something broke).