Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Export Package Headaches - Export Dependencies vs Export ALL scripts

Discussion in 'Editor & General Support' started by jczaban, Mar 7, 2013.

  1. jczaban

    jczaban

    Joined:
    Apr 26, 2009
    Posts:
    3
    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.
     
  2. Martian-Games

    Martian-Games

    Joined:
    Jan 19, 2012
    Posts:
    43
    Yeah this has been driving me crazy - thanks so much for this clever (doh!) method .. works very well thanks! ;)
     
  3. k2rlian

    k2rlian

    Joined:
    Feb 18, 2016
    Posts:
    1
    Still valid, thanks!
     
  4. khross

    khross

    Joined:
    Aug 17, 2013
    Posts:
    3
    Thanks man! I was getting all the trash with my exports...
     
  5. iwillbenice

    iwillbenice

    Joined:
    Jun 7, 2013
    Posts:
    21
    Unity 5.4.2f2 still have this prob. Thanks for thread.
     
  6. insomniaunleashed

    insomniaunleashed

    Joined:
    Mar 29, 2016
    Posts:
    10
    mate, perfect solution, shame we are now up to 5.5 and this export is still doing the same thing...but no matter this works...my thanks
     
  7. WDudderz

    WDudderz

    Joined:
    Apr 6, 2013
    Posts:
    12
    This is still a great work around in 5.6. Thanks so much!
     
  8. imerso

    imerso

    Joined:
    May 6, 2011
    Posts:
    278
    Awesome, thanks. =)
     
  9. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,593
    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.
     
    michaelday008 and Brogan89 like this.
  10. Estecka

    Estecka

    Joined:
    Oct 11, 2013
    Posts:
    62
    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.
     
  11. Deleted User

    Deleted User

    Guest

    2017.3, still happening.

    That's right, as OP said, Unity can't detect dependencies between scripts.
     
  12. Andergraw

    Andergraw

    Joined:
    Nov 28, 2016
    Posts:
    6
    So simple and not that obvious.
    Thanks mate
     
  13. jtok4j

    jtok4j

    Joined:
    Dec 6, 2013
    Posts:
    320
    Nice solution. Thank-you.
     
  14. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    You saved the day ;)
     
  15. michaelday008

    michaelday008

    Joined:
    Mar 29, 2019
    Posts:
    135
    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!!!"
     
  16. GluedPixel

    GluedPixel

    Joined:
    Nov 26, 2018
    Posts:
    11
    My life was a lie.... I had the same thought as @michaelday008 I was manually checking each thing missing a lot of "dependencies". Thank you, OP.

    Unity should do something about this, that's just a bad design.
     
  17. photonic

    photonic

    Joined:
    Dec 29, 2012
    Posts:
    47
    Unbelievable but true .. still the best solution after so many years .. thanks @jczaban
     
  18. tankpop

    tankpop

    Joined:
    Nov 11, 2020
    Posts:
    1
    Still an issue... workaround is still best solution.
     
    PunkDrifteR and Ziplock9000 like this.
  19. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    83
    Still an issue indeed, and thank God for home-made project backup!
     
    Last edited: Apr 11, 2021
  20. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,717
    Please consider using source control in order to guard and protect your hard-earned work.

    Personally I use git because it is free and there are tons of tutorials out there to help you set it up.

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up the right .gitignore file:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    (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).
     
  21. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    179
    You can also use a simple script which does the trick:
    Code (CSharp):
    1.            
    2.  
    3. AssetDatabase.ExportPackage(rootAssetPathOfPrefab,
    4.                 yourFilePathOnDisk,
    5.                 ExportPackageOptions.IncludeDependencies |
    6.                 ExportPackageOptions.Interactive);
    7.  
    8.  
    Enjoy ;)
     
    PunkDrifteR and radiantboy like this.
  22. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    234
    Haven't tested with Unity 2021.3 (only 2021.2) but even with well-set assembly definitions and namespaces, exporting one script as a package export all the scripts.
     
    Last edited: May 23, 2022
  23. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    234
    This still works incredibly well, thank you :)
     
  24. Jumeuan

    Jumeuan

    Joined:
    Mar 14, 2017
    Posts:
    39
    @jczaban You save my day, thank you so much!
    To Some pro captain, can you make a editor right click to easy export? :rolleyes:
     
  25. adamgffrd

    adamgffrd

    Joined:
    Sep 26, 2018
    Posts:
    35
    Great tip, thank you!!!
     
    PunkDrifteR likes this.