Creating Custom Packages in Unity! (Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll be creating our own custom package for unity's package manager and hosting it on github the unity package manager or upm is the official package management system for unity the package manager is a modular and dynamic software and asset delivery system you can use the package manager to define project dependencies resolve package dependencies download and add packages as needed and integrate content in your projects a upm package is a folder with a specific and standardized layout it is important that upm packages adhere to the unity package standards for them to function properly this means making sure your package follows the recommended folder layout and version labeling format in this video we'll be creating a custom package following best practices a package is a container that stores various types of features or assets it should be fully self-contained and include all required assets for the package to function properly many different features and assets can be distributed in packages common uses include editor tools and libraries like for example a text editor an animation viewer or test frameworks runtime tools in libraries like a physics api or a graphics pipeline asset collections such as textures or animations in this example we have created an editor tool that we would like to share as a package we've created our tool in its own unity project this tool adds a new menu item under edit create parent for selected this tool allows us to select several objects in the hierarchy and then click edit create parent for selected to create a new empty parent game object for the selected objects we'll make a package for this create parent tool so we'll be able to use it in other unity projects and share it with other developers first we will need to create the folder layout for our package the best practice of a package requires you to follow the layout anatomy and folder structure and provide all necessary documentation as well as readme files and change logs open the packages folder of your unity project in your file explorer you can do this by right-clicking the packages folder in the project window and selecting open an explorer on windows or reveal in finder on macos in the packages folder create a new subfolder for your custom package and give it your package's name in the subfolder we will need a package json file that describes the package and its dependencies you can create the package json file using your code editor or you can use the example package json file which is linked in the description below once you've created your packages folder it will appear in the unity editors project view under packages we can now move all the files we want as part of our custom package into our new custom package folder it is recommended to follow the package layout convention in this example we have a single editor script so we'll create an empty editor folder and move our script to it if you'd like more information on package layout convention visit the documentation on package layout which is linked in the description below once we've set up our package contents we need to edit the package json manifest file to describe the package and its dependencies so that other users will be able to use our package safely inside your custom package folder select the package json file to view its contents in the inspector we can edit the package json file in the inspector and fill out all the fields you will need to fill out the name description version and compatible unity versions as well as any other package dependencies that your package relies on to function properly it is important to follow naming and version format conventions if you'd like more information on the manifest file and each of its fields visit the package manifest documentation linked below if your custom package has scripts you must associate scripts inside a package to an assembly definition file of the type asmdef assembly definition files are the unity equivalent of a c project in the dot-net ecosystem you will need to create one asmdec file for the editor-specific code and one for the runtime-specific code you will also need to create a separate asmdef file for your package tests if you've created them for more information on package asm dev conventions visit the documentation linked below in our example we only have one editor folder right click and choose create assembly definition name your asmdef according to the convention which is companyname.featurename.editor this should match what you've placed inside your package.json previously finally if you intend to distribute your package it is recommended to add a license md file and a third-party notices md file for more information on these files please visit the meeting legal requirements documentation on packages linked below in this example we've added an open source license md file based on the mit license our custom package is complete let's share it there are many ways you can distribute your package at its simplest you can zip up your custom package folder and send the zip file wherever you like then in any compatible unity project you can add the package to the package manager as a zip file using add package from disk we can also distribute your package through a git repository such as github or gitlab by distributing our package through our git repository anyone who wants to use your package can download our package directly from the package manager using its git url note that git must be installed on the user's machine for the package manager to be able to use git urls git can be installed by using the official git installer or by installing a version control software such as github desktop for more information visit the documentation page on git urls linked in the description below let's take a look at distributing our package through a git repository for this example we will be using github but the package manager is compatible with other git-based services in our github account let's create a new repository for our package add the git ignore for unity and we can select a license here let's click create repository and now our git repo is up and running we can now add our package files into our repository we can do this by using a git client or we can do it on the website by clicking upload files on your repositories main page now let's upload and commit all the contents of our custom package including the meta files if the meta files do not appear in the package folder let's change them to be visible inside the unity editor under edit project settings editor version control mode visible meta files with the completed package repository we can now share our package easily on github we can get the direct get url by clicking clone or download and then copying the url provided then in any compatible unity project open window package manager and click add package from git url and paste in the url note that installing packages through the git url feature requires git to be installed on the machine the package manager will clone the package from the repository and install it as a package into the project for more details visit the documentation on git urls and the package manager we hope you enjoy sharing your packages directly from your git repositories we can't wait to see all the custom packages you create thanks for watching
Info
Channel: Unity
Views: 70,010
Rating: undefined out of 5
Keywords: Unity3d, Unity, Unity Technologies, Games, Game Development, Game Dev, Game Engine, Unity 2020, Unity Packman, Unity Package Manager, Packages in Unity, game development, unity game dev, unity game dev tutorial, custom packages, unity tutorial, package manager unity
Id: mgsLb3TKljk
Channel Id: undefined
Length: 8min 10sec (490 seconds)
Published: Mon Sep 07 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.