Search Unity

Custom package dependencies not installed on import [SOLVED]

Discussion in 'Package Manager' started by keenanwoodall, Feb 26, 2019.

  1. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    I'm working on a custom package that has dependencies on the Burst and Mathematics packages. I have a package.json file in the root of my package, as you can see here:

    upload_2019-2-25_20-35-56.png

    I exported the "Deform" folder and it's contents into a .unitypackage and dropped it into a new Unity project. From what I understand, the package manager should look for package.json files in the Assets folder and install any dependencies. However, after importing the .unitypackage in a new project, Burst and Mathematics were not installed and my asmdef files were missing references.

    Here's my package.json file
    Code (csharp):
    1. {
    2.     "name": "com.beans.deform",
    3.     "author": "Keenan Woodall",
    4.     "displayName": "Deform",
    5.     "version": "0.0.1-preview.1",
    6.     "unity": "2018.3",
    7.     "description": "A framework for deforming meshes in the editor and at runtime.",
    8.     "category": "Unity",
    9.     "keywords":
    10.     [
    11.         "burst",
    12.         "mathematics",
    13.         "mesh",
    14.         "modifiers",
    15.         "deformers"
    16.     ],
    17.     "dependencies":
    18.     {
    19.         "com.unity.burst": "0.2.4-preview.45",
    20.         "com.unity.mathematics": "0.0.12-preview.20"
    21.     }
    22. }
    It appears either the package manager isn't working correctly, or I misunderstand how it works.

    Edit: I'm using Unity 2018.3.6f1 and Package Manager 2.0.3
     
    Last edited: Feb 26, 2019
  2. cassandraL

    cassandraL

    Unity Technologies

    Joined:
    Dec 7, 2017
    Posts:
    111
    Hi,
    packages should go under the Packages folder.
    After moving your package there, you might have trouble with assets. That is because the path needs to point to the new path and should include your package folder as well:

    Example:
    Path to access the file image.png in the package subfolder /EditorResources of the Deform package:

    "Packages/Deform/EditorResources/image.png"


    Loading a texture:

    Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath("Packages/Deform/EditorResources/image.png", typeof(Texture2D));


    You can also get the asset's absolute path by using the Pat
    h.GetFullPath() method
    string absolute = Path.GetFullPath("Packages/Deform/EditorResources/image.png");
     
    TomTrottel and BigBrotherLee like this.
  3. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    That got it to work, thanks. I'm curious, how does the Package Manager handle dependencies? I checked the Package Manager window and it doesn't show Burst or Mathematics installed, even though my package isn't missing references to them. If a user installed a different version of Burst than the one used by my package would there be any issues?
     
  4. cassandraL

    cassandraL

    Unity Technologies

    Joined:
    Dec 7, 2017
    Posts:
    111
    If your project has dependencies on pkgA@1.0.0 and pkgB@1.0.0, but pkg B depends on pkgA@2.0.0, then Unity would usually choose pkgA@1.0.0 (because pkgA@1.0.0 is listed directly in the project manifest, which is higher level than the dependencies of those packages).

    If you have a conflict on the same level, then the highest version will win.
    The rules are similar to Nuget's: https://docs.microsoft.com/en-us/nu...ndency-resolution#dependency-resolution-rules

    In the case where a user does install a different version of burst then the one used by your package, it can indeed lead to errors sometimes.