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

When are we going to get a decent system to export prefabs?

Discussion in 'Prefabs' started by Arano, Jan 7, 2020.

  1. Arano

    Arano

    Joined:
    Aug 29, 2019
    Posts:
    7
    most prefabs i am trying to export exports close to the entire codebase of the project
    if by a miracle it does export it has a 60% fail rate when importing on another project to break all links completely

    such a great system..
     
  2. DaftPuzzler

    DaftPuzzler

    Joined:
    Dec 1, 2018
    Posts:
    12
    Are you saying you're putting most of your project in a prefab, exporting that, and then are shocked when it doesn't work well? Or are you saying the editor is incorrectly exporting unnecessary parts of the project?
     
  3. Arano

    Arano

    Joined:
    Aug 29, 2019
    Posts:
    7
    The second part, unity picks a mountain of things to export even with small prefabs.
    picking the exported components manually does work but its real time consuming.
     
    DaftPuzzler likes this.
  4. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,877
    It's true, for scripts Unity just includes more or less everything because we don't know which scripts the Prefab depends on. We only figure out what to include based on Asset dependencies, not script dependencies. What this means is that we don't do code analysis to calculate scripts that depend on other scripts etc, and even if we did, it wouldn't catch certain cases like usage of reflection. So scripts is just some annoyance where you have to know yourself which scripts the Prefab depends on (if you don't want to include everything), because Unity doesn't know it.
     
    Cromfeli, DaftPuzzler and hippocoder like this.
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    It's completely understandable that Unity can't really figure out code dependencies. The problem is that the interface for export package is useless. Here's what happens when you select "export package" for a prefab with two simple scripts on it:

    upload_2020-1-16_14-11-11.png

    Look at that scroll bar!

    This means that we have to manually go through that list and deselect every script. Or, we can uncheck "Include Dependencies", and get nothing. What we're interested in when exporting a prefab is all the meshes and materials and such attached to it.

    A solution that would make this workable would be for "Include Dependencies" to select just the scripts attached to the prefab, and then let us deal with code dependencies manually. The "include every script so we're sure this will work" approach isn't a very good idea at all.
     
    Cromfeli, fffMalzbier and DaftPuzzler like this.
  6. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,877
    Right, fair enough, I'll pass on the feedback.
     
    Cromfeli, fffMalzbier and DaftPuzzler like this.
  7. Arano

    Arano

    Joined:
    Aug 29, 2019
    Posts:
    7
    Sounds like a good idea to me, usually i know what scripts i need to export (or in most cases i do not even want to export all script dependencies as most of them will be inside the other project anyway (for example something like DoTween)

    The most important thing is that i can be assured that all my materials and textures are picked up so my prefab looks the same as it did in my other project.