Search Unity

Question Creating custom packages

Discussion in 'Package Manager' started by Lroemon, Jan 27, 2021.

  1. Lroemon

    Lroemon

    Joined:
    Mar 5, 2020
    Posts:
    1
    Hello,

    I'm working on a code in the idea to share it. I saw two possibilities to do it: 1) Assets Store and 2) Package Manager. I decided to use the second option following the documentation here: https://docs.unity3d.com/2020.2/Documentation/Manual/CustomPackages.html
    Unfortunately, the documentation is not really clear on few points and missing information that confused me. So I've few questions about it and hope people could help me to find solutions. My problems are the following:

    1. Assembly Definition naming convention: in the documentation, we can see two different information about this. The first one is there https://docs.unity3d.com/2020.2/Documentation/Manual/cus-layout.html and the second one is there https://docs.unity3d.com/2020.2/Documentation/Manual/cus-asmdef.html . We can see that the name for Assembly Definition file is not the same. By example, we have
    << Runtime/MyCompany.MyFeature.Runtime.asmdef >>
    and
    << Runtime/Unity.[YourPackageName].asmdef >>

    ➣ Which one should be used ?

    2. Local Package Dependencies: imagine the case where there are 2 packages A and B imported in the project from local disk. B depends of A, so I need to use code from A inside B. Both are in development at the same time.

    ➣ There is a easy way to configure this case ? (with npm, there is the command link)

    3. Folders Structure of Local Package is not preserved in Visual Studio: as presented by Tom-Atom there: https://forum.unity.com/threads/loc...y-structure-in-visual-studio-solution.708317/ ,
    the local package folders structure is not preserved in Visual Studio.

    ➣ There is a solution without writing a script ? (Is it a good solution to write the package code inside the assets folder of the project and then copy-paste it inside the package folder? But this solution is not really good to maintain the development)

    Thanks people for helping,
    Sam
     
  2. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    For the question about asmdefs, the "Package layout" docs actually state "This is the package layout convention followed by official Unity packages" so the naming convention "Unity.[YourPackageName].Editor.asmdef" makes sense for Unity packages.

    In the "Assembly definition and packages" docs, it says "Editor/MyCompany.MyFeature.Editor.asmdef" so you can see that "Unity" has been replaced by "MyCompany" which makes sense.

    What's a bit confusing is that "[YourPackageName]" becomes "MyFeature" in the 2nd doc. This should probably say "[YourPackageName]" in both instances so we'll flag this with our documentation team to fix.

    For your 2nd question about an equivalent to "npm link", we don't have an exact equivalent to this but the scenario the user describes should be a valid workflow i.e. have 2 local packages in the same project.

    This way, each package lives in its own repo somewhere on disk, the project will load both as local dependencies, and you can develop both packages in tandem. The difference with "npm link" is that you only declare one dependency and then the linked dependency happens behind the scenes.

    In our case, the Unity project will need to declare a dependency on both local packages and they will both be resolved as root-level dependencies but Package A can still depend on Package B even though both A and B are in the project manifest.

    For the 3rd question about the VSCode project structure. I really hope this has been fixed by the vscode package in Unity... are you still getting this issue?