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

Question Adding Dependency for A Sample in a Custom Package

Discussion in 'Package Manager' started by AliCanKeskin, Oct 26, 2022.

  1. AliCanKeskin

    AliCanKeskin

    Joined:
    Jun 7, 2022
    Posts:
    17
    Hello, I have a custom package with some dependencies. I have added some samples that includes some prefabs and scenes that have other dependencies such as "TextMeshPro". When I try to import samples from the Package Manager , naturally, it gives errors and says : "Problem detected while importing the Prefab file". How can I add those dependencies ? As a workaround I thought maybe I will convert my scene to a ".unitypackage" and put them inside the Sample, so that user can "re-import" the sample , but it just seems stupid to make user re-import stuff. Is there a way to do this? I have read the documentation for custom packages but could not find a thing for this. So, if there is not a way to do this, do you happen to know any better workaround for this ?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,019
    Did you specify TextMeshPro as a dependency in the package.json?
     
  3. AliCanKeskin

    AliCanKeskin

    Joined:
    Jun 7, 2022
    Posts:
    17
    it is not a dependency for the package but it is a dependency for the sample. So I do not want to specify it as a dependency in the package.json
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,019
    The sample has an assembly definition file? You can try put it in there and see if that triggers package manager to download it, though I think that dependency needs to be in the package.json.

    The alternative way is to create two packages. Many packages do so to separate the unit tests so that the core package doesn't have to reference all the dependencies and assets only required for testing. The same would work for samples, though you would lose the ability for users to Install the sample from the package's detail view in Package Manager. But you could put that in the documentation that there's a "<YourPackage> Examples" package.