Get Started with Custom Unity Packages (Step by Step)

Sdílet
Vložit
  • čas přidán 17. 06. 2024
  • Learn how to package your custom code in a modular, version controlled way with Unity Custom Packages, that include Dependency management! Understand the difference between a basic unity packaged Asset and a Custom Unity Package. Today we're taking our Improved Timers code from the previous video and packaging it to share with the community!
    FEATURED TOOL:
    Smart Editor Tool: assetstore.unity.com/packages...
    Jon Skeet on Stack Overflow:
    stackoverflow.com/users/22656...
    Want to support me? 😀
    Buy me a coffee! ko-fi.com/adammyhre
    🔔 Subscribe for more Unity Tutorials / @git-amend
    Discord: / discord
    #unity3d #gamedev #indiedev
    ▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
    0:00 Two Types of Packages
    3:10 Custom Unity Packages
    7:20 Assembly Definitions
    9:40 Manifest
    14:46 Local Packages
    Source code: github.com/adammyhre/Unity-Im...
    More Useful Code:
    github.com/adammyhre?tab=repo...
    Unity Utility Library: github.com/adammyhre/Unity-Utils
    Lock Inspector Hotkey: gist.github.com/adammyhre/475...
    Assets Shown In This Video (Affiliate Links)
    Procedural Progress Bar: assetstore.unity.com/packages...
    Dungeon Mason Tiny Hero Duo: (FREE): assetstore.unity.com/packages...
    Tiny Heroes: assetstore.unity.com/packages...
    Tidal Flask Dungeon Pack: assetstore.unity.com/packages...
    Hierarchy Icons: assetstore.unity.com/packages...
    Better Transform: assetstore.unity.com/packages...
    Better Mesh Filter: assetstore.unity.com/packages...
    Kyeoms VFX: assetstore.unity.com/publishe...
    Follow me!
    linktr.ee/gitamend
  • Hry

Komentáře • 93

  • @git-amend
    @git-amend  Před 22 dny +16

    Happy Sunday once again! I hope this video helps demystify making custom packages - please post any follow up questions you might have or comments you'd like to share! And of course, please make use of the Improved Timers package in your own projects if you want! 👍

    • @zORg_alex
      @zORg_alex Před 22 dny

      I use my custom packages in private git repos for licensed assets that are cumbersome to import and cannot be shared in public repo. So anybody cloning that repo will see that it has private dependency and the name of that asset.

    • @damonfedorick
      @damonfedorick Před 22 dny

      i use git desktop, seems to do the job and all in a UI system.

  • @dustintaub
    @dustintaub Před 22 dny +12

    This has become the best Unity learning channel on CZcams. There are dozens of tutorials on the basics but this is the only channel with actionable, advanced topics every week. Keep it up!!

    • @git-amend
      @git-amend  Před 22 dny +5

      Thanks for the kind words! Lots more to come!

  • @zyxpip8363
    @zyxpip8363 Před 22 dny +10

    The "Quick Recap" part near the end of the video is definitely a great addition to the video format
    It's quick & subtle, but totally needed

    • @git-amend
      @git-amend  Před 22 dny +2

      Yeah, I'm glad I included that. Will probably continue that in the future!

  • @Fitz0fury
    @Fitz0fury Před 22 dny +4

    This is 100% getting used today. A lot of my game is sitting in about 5 different projects I have been merging. This is gold for me.

    • @git-amend
      @git-amend  Před 22 dny

      Awesome, let me know how it works out for you.

  • @Patricebrouh
    @Patricebrouh Před 22 dny +2

    We are Lucky to have you

  • @GameDragon2k
    @GameDragon2k Před 22 dny +3

    The biggest take away I got from this, is that Rider has an interface for editing markdown files, and I've been using Notepad all this time. Holy shit.

    • @git-amend
      @git-amend  Před 22 dny

      Haha! Nice isn’t it! I actually discovered that by accident myself a while ago.

  • @MarushiaDark316
    @MarushiaDark316 Před 22 dny +1

    "We're gonna rewrite history with a git-amend."
    I see what you did there. :U

    • @git-amend
      @git-amend  Před 22 dny +1

      Hahah.. wasn't intentional, I swear!

  • @stephanedurette5785
    @stephanedurette5785 Před 12 dny

    you have the highest quality unity tutorials I've seen on CZcams for a long time. Thanks a bunch!

    • @git-amend
      @git-amend  Před 12 dny

      Wow, thanks! Glad you think so! You're welcome.

  • @user-rm2pj9jf8s
    @user-rm2pj9jf8s Před 22 dny +2

    It was the easiest to understand than any of the Unity 'modular' lectures I learned.
    Now I can make my codes into Assets!

    • @git-amend
      @git-amend  Před 22 dny +2

      Great! Glad to hear that!

    • @user-rm2pj9jf8s
      @user-rm2pj9jf8s Před 22 dny +1

      @@git-amend I've learned so much from the community you've created, the lectures you've created. You're a giant who shows me the horizon of that far sea through your shoulders.
      Thank you always.

  • @RafaelAzriaiev-kv9qm
    @RafaelAzriaiev-kv9qm Před 22 dny

    Great was looking forward for your video, great topic

    • @git-amend
      @git-amend  Před 22 dny

      Awesome, hope it helps you out!

  • @rohanvishayal8724
    @rohanvishayal8724 Před 22 dny

    Great Video! Thank you for sharing. Lots to learn :)

  • @techdave99
    @techdave99 Před 22 dny

    Thanks for the video. It helped understand packages a little better.

  • @TChrisBaker
    @TChrisBaker Před 21 dnem

    I always wondered how to do this and I got it working right away. Thank you !

    • @git-amend
      @git-amend  Před 21 dnem +1

      Nice, that's what I like to hear!

  • @Johan-rm6ec
    @Johan-rm6ec Před 22 dny

    Dude you rock keep them vids coming!!!!

  • @SanderDecleer
    @SanderDecleer Před 22 dny +1

    Awesome video on a great topic. The only thing I would add is that you can start creating your package in a 'Packages' folder, adjacent to the 'Assets' folder. This way you can check how the package works without moving it to another project while still keeping it inside of your project during development.

    • @git-amend
      @git-amend  Před 22 dny

      Great tip! Thanks for sharing that!

  • @user-tf1gz7mm1n
    @user-tf1gz7mm1n Před 22 dny

    Thank you for these videos!! They've been so helpful and motivating.
    Every time you surprise me with a topic, I wanted to learn more about.
    Again, great video! Keep it up

  • @fleity
    @fleity Před 21 dnem

    Very nice video, great overview.
    There is one thing I missed in the video. Embedded packages. Usually packages are saved in the library package cache folder but they can be moved to project/packages which gives you write access to them (instead of being read only in the cache folder). Of course updates can overwrite your changes so be careful. But that can be hugely useful if you want to modify stuff AND you can actively develop on that package while having unity treat it as a package in the context of the project.

    • @git-amend
      @git-amend  Před 21 dnem

      Thanks for the comment. We might cover a few more things that are beyond introduction level in a future video, that's a good thing to point out. Cheers!

  • @kpm25
    @kpm25 Před 22 dny

    Thanks once again Adam! The least I can do is leave a comment:)

  • @connorjagielski6760
    @connorjagielski6760 Před 22 dny

    I always thought this was some sort of black magic that only asset store devs knew. Thanks for sharing!

    • @git-amend
      @git-amend  Před 22 dny +1

      You're welcome. Publishing on the Store is actually easier than most people think, maybe we'll cover that in a future video.

  • @mracipayam
    @mracipayam Před 13 dny

    Thanks for helpful video

  • @NathanSL11
    @NathanSL11 Před 22 dny +1

    Great video as always! Another big gotcha with the UPM is that it cannot currently resolve git dependencies in the package.json only the project manifest. Hopefully they add that feature someday.

    • @git-amend
      @git-amend  Před 22 dny

      Thanks. Yes, I hope so too - that would be fantastic.

  • @005Racot500
    @005Racot500 Před 22 dny

    Thanks for the video. Would be nice to listen about dependencies from another package in git or local, how to resolve circular dependency of packages, and a few words about UPM.
    Also if you use local packages in a team remotely, you required to has them in same path or shared drive.

    • @git-amend
      @git-amend  Před 22 dny

      All great topics - perhaps in a future video.

  • @aaatthh
    @aaatthh Před 16 dny

    Thanks for amazing videos, they are priceless, I watch them multiple times so I can fully inject them into my workflow, I really enjoy them, and they make learning these topics enjoyable. By the way I have a question: How would you do an audio system/manager? Which pattern would you use? Thank you

    • @git-amend
      @git-amend  Před 16 dny

      Thank you! The topic of audio management has come up several times. There will be a video about that soon!

  • @ragerungames
    @ragerungames Před 21 dnem

    great. i see that you have custom script templates where you selected monobehavior scripts, pretty cool

    • @git-amend
      @git-amend  Před 21 dnem +1

      I think that is actually just the default in Unity 6 now... I'll have to double check that.

    • @ragerungames
      @ragerungames Před 21 dnem

      @@git-amend oh if unity 6 then pretty cool and time saviour.. previously it was just available on rider

  • @marc8150
    @marc8150 Před 22 dny +1

    Hey Adam, great video and especially useful for my current project :D.
    I'm curious about your experience as a developer and with Unity in general.
    Also I've been working through your videos whenever I find one useful for my own projects and as a Junior some videos literally took me days to fully understand and iterate on, how long does it actually take you to produce a video and how do you design the code? Because that in general is something we as viewer don't get to see and I always wonder how much time it must've took you to come with the solution we get to see.
    Maybe that would even be a good video idea. One dedicated solely on how to build and design unity systems (which would probably become a series of videos because of the complexity^^)

    • @git-amend
      @git-amend  Před 22 dny

      That's a very interesting question! To be honest, it depends on the topic. If it's a topic I'm very familiar with, the amount of research will be low and I'll dogfood a prototype in an hour. I try to start early in the week, so I can iterate on the video idea a few times in the evenings if I have to. The actual recording of a video is the longest part, because recording, audio and video editing are areas I can stand to improve upon - so that takes roughly 8-12 hours on Saturday with breaks here and there. Luckily the subject of the video - code or otherwise - will already be prepared before that, plus I seem to enjoy creating the videos as much as I like programming, so time flies. I agree that systems design and thinking are skills that could be taught here, and we'll get to that too!

    • @marc8150
      @marc8150 Před 22 dny +1

      @@git-amend Awesome, sounds good! Thanks for the detailed answer and I think system design will be the perfect addition to your design pattern videos. If those videos regarding system design will be just as good as your design pattern videos I honestly think you're literally the ultimate resource for advanced Unity developers

  • @damonfedorick
    @damonfedorick Před 22 dny

    Nice.

    • @damonfedorick
      @damonfedorick Před 22 dny

      i ended up figuring this all out myself a few months ago, knowing how to package your assets is a good way to keep your stuff super organized as well sharing anything with your team or friends becomes a lot easier.

    • @git-amend
      @git-amend  Před 22 dny

      @@damonfedorick Yes, agreed. Thanks for the comment!

  • @TheSuzakton
    @TheSuzakton Před 22 dny

    Really nice video and easy to understand.
    On an other note does your Improved timers still work as expected in a production build after making them a package ?
    I have a problem with the [InitializeOnLoadMethod] in different assemblies. My method seems to not be called as i launch my game.
    If you faced this problem and have a solution i would really need some insight :)

    • @git-amend
      @git-amend  Před 21 dnem

      Don't forget that [InitializeOnLoadMeth­od] is Editor only. [RuntimeInitializeOnLoadMethod] is for play mode and builds. The ImprovedTimers package does work in a build by the way, just as expected.

    • @TheSuzakton
      @TheSuzakton Před 21 dnem

      ​@@git-amend Oh yeah it was [RuntimeInitilizeOnLoadMethod] it was just a typo on my question.
      Well i try to find why it's not runing on my code. Thanks and keep doing awesome videos :)

  • @TheKr0ckeR
    @TheKr0ckeR Před 21 dnem

    Just in time! Thanks a lot! I want to create an extension method library which is using DoTween, Since dotween is a third party asset, what kind of approach should i follow if my package is has dependencies with 3rd assets. As far as i know, we cant create custom packages with 3rd party assets

    • @git-amend
      @git-amend  Před 21 dnem

      Sadly, this is still an outstanding issue that Unity has said they are working on, as well as making independent git repositories dependencies. What most people do is explicitly tell users that they have to install XYZ before installing your custom package.

  • @techdave99
    @techdave99 Před 22 dny

    Watch the ending of the video for a pro tip! Worth watching the whole video. (Don't forget to share the video!)

  • @sima19995
    @sima19995 Před 22 dny

    Great video! The only setback with packages I've experienced is that if you need to modify any of your own imported packages on the fly you'd have to open the original Unity project to do so. This often leads me copy pasting the files instead. Is there any workaround that you know of?

    • @git-amend
      @git-amend  Před 22 dny

      This is a common issue, especially when working in teams where each team is developing different parts but they are dependencies.
      One thing you can do as a small developer is try the git subtree command. This lets you have multiple repositories in the same project.

    • @sima19995
      @sima19995 Před 22 dny

      @@git-amend Thanks for the info! I'm not an expert at git, after a bit of digging around I don't quite understand how this would work. Would this mean that there is a dummy wrapper parent repo and the sub repo with the actual code would be editable in all projects?

    • @git-amend
      @git-amend  Před 22 dny +2

      Using git subtree, you can integrate an external package repository into your main project repository, allowing you to treat the package as part of your project’s codebase. By using commands like git subtree add to include the package and git subtree push to update the package’s upstream repository, you can make and manage changes to the package from within any project that includes it. This approach ensures that updates to the package can be synchronized across multiple projects. Maybe I can try to show this in a video soon since several ppl have asked.

  • @BOBROFFNIK.shorts
    @BOBROFFNIK.shorts Před 21 dnem

    Thanks about mentionin war crimes 🙏

  • @DisturbedOne69
    @DisturbedOne69 Před 22 dny +2

    Is it possible to add the package dependecies to the exported in a usual way package? I'm wondering because my package on the asset store has a dependency on some of the Unity's packages and I am currently just telling to user "Hey, this is not installed and the package relies on it". Just adding a package.json to the root folder didn't seem to do the trick.

    • @git-amend
      @git-amend  Před 22 dny +2

      Unfortunately it's not possible to add dependencies to usual way packages or Assets sold on the store. This was a topic a while ago on the Unity forums, but all that came out of that was a suggestion to submit it as an idea for future improvements. I know what you mean though, it's not very user friendly.
      forum.unity.com/threads/adding-a-dependency-to-an-asset-store-product-in-a-projects-manifest-json.1108304/

    • @DisturbedOne69
      @DisturbedOne69 Před 22 dny +2

      @@git-amend It actually is possible. Idk how I've missed this, but using the "Asset Store Publishing Tools", you can optionally include the project manifest and add UPM packages in the uploader window. It's exactly what I wanted, but it wouldn't work for the asset store packages though. Then you can just export the package on your PC without uploading it into the publisher portal, but there is some overhead because you need a publisher profile.

    • @git-amend
      @git-amend  Před 22 dny

      @@DisturbedOne69 Well that's very interesting, I had no idea. I'll have to look into that. I don't remember ever seeing anything from the Asset Store that included a manifest.

  • @lizkimber
    @lizkimber Před 22 dny

    Have you found a way to install from "My assets" eg store bought assets, into projects via code, without importing them as files from the unity cache?

    • @git-amend
      @git-amend  Před 22 dny

      I have yes, use it all the time. There is some sample code that you can check out here, but maybe we'll cover it more in depth in a future video as well. We covered this briefly in the 3D platformer series, as it evolved over several videos. Take a look here:
      github.com/adammyhre/3D-Platformer/tree/master/Assets/MyTools

    • @lizkimber
      @lizkimber Před 22 dny

      @@git-amend thanks, ive seen so many different things about installing asset store packages, and so far all have failed to work correctly, as yours finds the cache and loads from it - specifically one of the non criteria was not to load from the cache. eg i want it to be the latest version, so to download it if necessary.

  • @tahaaltndag3554
    @tahaaltndag3554 Před 19 dny

    Can we add other custom packages as dependencies in package.json? Let's say that my custom package codes are dependent on UniTask how can i overcome this dependency problem?

    • @git-amend
      @git-amend  Před 19 dny

      Unfortunately not at this time. Unity allows you to add Git packages as dependencies in the Project level Manifest file, but not in the package.json file of an embedded package. I believe this is something they are working on, but don't hold your breath. The general workaround is to install the dependencies first, then the package that relies on them next.

  • @OskGame
    @OskGame Před 22 dny

    So every time I edit, I will edit in another project and push it. Is there a way to edit in an existing project and push it to git?

    • @git-amend
      @git-amend  Před 22 dny

      There is, but it requires a good understanding of git. There is a command that is distributed with many versions of git called git subtree. This lets you have multiple repositories in one project.

  • @nullx2368
    @nullx2368 Před 14 dny

    Wait, is there a way to put it on git to have multiple people using it on a private repo?

    • @git-amend
      @git-amend  Před 14 dny

      Sure, you can invite anyone to collaborate on a private repo on GitHub - this will ensure they have access. In the specific repository, go into Settings > Collaborators.

  • @amitmoryosef2223
    @amitmoryosef2223 Před 22 dny

  • @atqamz
    @atqamz Před 21 dnem

    the discord server invitation link is invalid :(

    • @git-amend
      @git-amend  Před 21 dnem

      It is working, please try it again in a bit. Check that you haven't joined the max number of allowed Discords!

  • @adventuretuna
    @adventuretuna Před 22 dny +1

    Be careful putting a Resources folder inside your packages. When someone imports your package, all the files inside the Resources folder in your package will also be part of the project's build regardless if it is being used or not. Spent hours figuring this out trying to hit a 150MB build size limit.

    • @git-amend
      @git-amend  Před 22 dny

      Wow, I’ve never seen that! Great tip!

  • @Eitrum
    @Eitrum Před 22 dny +2

    While custom packages look like a good feature, it's truly a pain to work with in larger projects if you need to change or update the packages to implement a new feature in your game project. It takes a lot of back and forth, swapping out from registry to embedded packages so you can try the features out, then backport it to the package, revert all changes locally, and lastly update the package. Truly awful workflow for the actual game developer that need to build or update the packages to work with their game.
    And if you think it will be perfect package on first try without having to change or update it, you are indeed wrong most of the time.

    • @sima19995
      @sima19995 Před 22 dny

      I made a comment of my own regarding this issue before realizing someone else already wrote one. This is the only reason I tend to avoid using packages.