Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Samples in Packages - Manual Setup

Discussion in 'Package Manager' started by ethan_jl_unity, Feb 1, 2019.

  1. ethan_jl_unity

    ethan_jl_unity

    Unity Technologies

    Joined:
    Sep 27, 2018
    Posts:
    1
    In Package Manager UI 2.0 (compatible with Unity 2019.1), you can include samples in a package.

    A sample could be a piece of example code, or some beginner assets that can be optionally brought into the user's project under the `Assets` folder.

    In the future, the editor will expose packaging functionality to properly expose samples, but in the meantime, here's is an example on how samples can be manually configured to be recognized in the Package Manager UI.

    First, make sure to place your samples under the `Samples~` folder.

    <Root>
    ├── package.json
    ├── Samples~
    │ ├── Sample Folder 1
    │ │ └── …
    │ └── Sample Folder 2
    │ └── …
    └── ...


    Then you need to specify them in the `package.json` file. Note that each sample needs to point to a directory.

    {
    "Samples": [
    {
    "displayName": "Sample Name 1",
    "description": "Description for sample 1",
    "path": "Samples~/Sample Folder 1"
    },
    {
    "displayName": "Sample Name 2",
    "description": "Description for sample 2",
    "path": "Samples~/Sample Folder 2"
    }
    ]
    }


    Then you'll be able to see the import buttons in Package Manager UI as shown below.



    When the user chooses to import a sample, samples will be copied to the project’s `Assets/Samples/Package Name/Version/Sample Name` directory, thus allowing it to be modified.
     
    Guerro323, alexzzzz, M_R and 2 others like this.
  2. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    575
    Thank you Ethan. As soon as I can move to Unity 2019.1 will jump into this.
     
  3. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    634
    It took me a long time to figure out why this wasn't working for me. As it turns out, you need to spell samples with a lower-case s, so not upper-case like in your example ;)

    Code (CSharp):
    1.   "samples": [
     
    bddckr likes this.