How to Make a Unity Package (For the Unity Package Manager)

Let’s say you have a bunch of code you want to drag around with you to every new Unity project, or maybe just the next project you’re doing for the same company. Don’t just copy and paste the same directory over and over again forcing you to also copy changes and updates. Create a package instead!

Unity has switched over to a package model for a lot of the engine’s capabilities. And it also allows you to import non-Asset Store packages straight from GitHub or even locally. So how do you take what you have and make it an easily distributable package? Follow these steps.

  1. In your Project window, below all your regular files is a Packages folder. Right click on it and select Show in Explorer.
  2. In that Packages folder, create a new directory and name it however you like. This will be the root of your package.
    1. Do remember that the folder name can not contain spaces.
  3. Create a new “package.json” file.
    1. This page right here explains everything about the structure of the file.
    2. And here is an example file.
  4. Back in Unity, your new package should be visible with the name you gave it.
  5. Clicking on package file will open it in the Editor UI, allowing you to edit it more conveniently so you don’t have to go back to the JSON.
  6. In that Inspector window, you can also easily add Dependencies if your package requires it which is a much easier workflow than typing them out.
  7. After this basic set up, you’ll want to add your content, this link here will show you the folder and file structure required of a package.
    1. You need the package.json file.
    2. Adding a “README.md”, “CHANGELOG.md”, and “LICENSE.md” files is general practice and provides a better user experience.
    3. The “Editor” folder should contain your editor scripts.
    4. The “Runtime” folder should contain your runtime scripts.
    5. And you can add additional “Tests” and “Documentation~” under their respective folders.
      1. Under “Tests” you do have to add “Editor” and/or “Runtime” sub-folders depending on what you’re testing.
    6. You may also add additional folders and files as you wish.
  8. Just drop your scripts, assets, and whatever else you want from your current project into the correct folder in the package (Regular scripts into “Runtime”, editor scripts into “Editor”, and test scripts into “Tests”).
  9. Then, for every folder you have files in, right click it and select “Create\Assembly Definition”.
    1. It is recommended to name them in reverse web notation in a way that is easy to understand.
    2. For tests, you need to add a reference to your relevant assembly definition file (The runtime file for runtime tests and editor file for editor tests) and to the Unity TestRunner assemblies (Yes, both).
      1. Also, make sure that Editor is the only platform selected.
  10. That’s it, your done defining.
  11. If you move the package anywhere else for safe keeping, you can add it from the Package Manager by pressing the ‘+’ sign, selecting “Add from Disk” and finding your package.json file.
  12. But it is recommended that you upload the contents of your package (Not the folder itself but everything in it) to some Git repository and then you can always add it from Git and your users will be much happier for a constantly updated package.

Posted in Practice, Programming, Thinking Out Loud by with no comments yet.

Blegh.

I apologise to anyone who was expecting something from me recently. I’m feeling sick and this might take a while.


Posted in Life by with no comments yet.

Flash Fiction February 16: Mountain

Blog Archives - Examining LifeEveryone has their mountain. You don’t find it. It’s not there to begin with. You have to build it.

Some people like their mountains small, easy to build, easy to climb. They top it off in some short time and feel satisfied with themselves.

But, as they say, it’s the darers and the dreamers who look at the blueprints for all the tiny mountains and then look away. They dig and scramble and find the parts and the scraps. They design their own mountain. They build it from trash, from non-existence, and from hope. They make it tower over the others and change the skyline.

When other people see that mountain rise up on the landscape, they ooh and ahh. Some cheer, some deride. But they are all intrigued. Will this one succeed? Is this one even climbable? Who is that person that built this mountain? How will the climb be? Who will they be if and when they reach the top? Who will we all be?

Not all of them reach the top. Usually just a scant few do. But, when they do, they change everything.


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 15: Desert

I grew up in a desert. I lived in a desert all my life.

Sometimes people came to my desert, mostly to throw sand at me, or show me how cool trees are and that I couldn’t have any.

I tried to stay inside my desert, keep away from the edges.

A desert isn’t the most comfortable place. I know that. But it’s what I’m familiar with. The outside is more scary.

A desert is vast. It’s very hard to see outside of it, when you’re standing in the middle.

The sand gets everywhere. It makes everything heavy and coarse and annoying. But if you live in the desert, you stay in the desert. Even though it’s hard, it can be harder to get out.

In 2020, a lot more people found their way into their own private desert.

I didn’t choose my desert. It found me. But now I’m working my way out. And it’s ok to ask for help.


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 14: City

Cities are not concrete and steel. Cities are not stone and wood.

Describing a city like that is like describing juice with the design of the bottle that contains it.

Planes can fall on it. Busses could explode in it. Buildings could be razed and neighbourhood could be displaced.

But the city remains if the people do.

It’s when the populous turns on each other, devalues each other, and demonizes each other, that the city falls.

Unfortunately (or fortunately), the same can be said of any sub-part of civilisation.


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 13: New

I’m a scientist. Just so you know where I was starting from. I’m also a little bit anxious. And, by ‘a little bit’, I mean a lot. But it’s not that strange for a bride to be anxious leading up to her wedding day, right? Yes, what I did about it might be construed as strange.

You know how a bride is supposed to have ‘something old, something new, something burrowed, and something blue’ for luck. Well, I wanted to be as lucky as I could be. So, I went to my friends for help.

Jackie is a sociologist. She studies society’s relationship with things. I knew she was my first stop. I explained my situation to her and she gave me a simple pink handkerchief with stitched flowers. Why a handkerchief? It was involved in a longitudinal study of lending and burrowing. She said it was the item that travelled the most. I asked how much. She pulled up one of her datasheets to make sure and said, ‘16,522 times’.

Next, I went to Stuart. He’s a material scientist and an amateur artist. I enquired as to the bluest thing he has. He said he’ll get back to me. He called me about a week later and said he experimented with sapphire dust, lapis lazuli, cordierite, kyanite, and azurite and managed to produce an artificial gem he now calls Deepest Blue and that I’m welcome to the first prototype.

My friend Jen is an archeological anthropologist. She also works for her uni’s museum. I didn’t know anyone from the geology department so I went to her. She knew what I wanted before I even opened my mouth. She said she could get in a lot of trouble. I promised I’ll give it right back after the ceremony and keep it in whatever way she said. It took me promising her a favor from my field before she relented and gave me a Denisovan finger bone. I asked how much. She said about 250 thousand years, give or take 10 or 15 thousand.

I was in charge of the ‘Something New’ Department. You see, I’m a high-energy practical physicist. I experiment with various particles travelling at near lightspeed. And we’ve finally got enough theory together to try and make our own artificial wormhole. And the fun thing about wormholes is that they allow you to create a close time-like curve, the only known way to actually time-travel without breaking causality. Of course, they are not very stable and you are limited in what you can transfer. We fired that baby up three days before the wedding and it was stable for 0.78 milliseconds. But, that was enough to get a short radio burst. When we deciphered it, this is what we got, this little, low-res image of you, twelve weeks along, not even born yet, a picture that was not taken yet and won’t be taken for another three months. Of course, I had to make sure to do the experiment again at that time and send the image back otherwise the universe might have blown up or something, no biggy.

And that’s the story of how I won marriage.


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 12: Old

Why are you interviewing me? Why are you watching this video? Do you really think this is interesting? Yes, I was the first person in the world to get the life extension treatment. But I have no great survival tips for you. It’s all science.

Explain it? Do you really think I know exactly how it works. Something about termite division limitation and resetting. What? Tel-o-meres? Exactly. I’m not a bio-geneticist or whatever they’re called. I was guinea pig. I still am a guinea pig. Those are the conditions.

1029 years old. Yes. I’m not even the oldest. I was young when I got the first dose. After me, older people got it. I’m just the longest running test. I guess that counts for something.

I come for a check up every year. They track my every move. See that flashing red light in my ankle, just under the skin. That’s how. Anyway, they check up on me, make sure everything is running smoothly, and every 20-30 years give me another dose.

How was I selected? Well, I volunteered. It was either this or a shorter life in prison. That ankle monitor is part of the terms of my parole. Yes, there are other parts. But you want your viewers to come back for another one, don’t you?


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 11: Music

Music is just a pleasant sounding noise. Noise is just a disturbance in a medium — in most cases, air. Well, if you consider space itself as the medium, then all objects produce disturbances in that medium. All stellar objects produce music.

All you need to do is map the fabric of space in the local sector, map the gravity fields of all stellar objects, measure their movements and gravitic interactions over time and there you go, you have music.

Now, the question is, what kind of music? Well, it depends on you frame it, which scale you use, how you transform your telemetry, how much distortion you add. But I found that this arrangement works best: Classic, single G star systems are gentle Baroque. Multi-star system sound more like Beethoven. Pulsars sound like techno-funk. Magnetars are speed metal. Neutron stars sound like Aphex Twin no matter what you do with it.

And colliding black holes work best as Norwegian Death Metal.


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 10: Creature

This thing will change everything you thought you knew about life.

We found it on X/2152 H3. Yes, that comet. You probably thought that it was all just dead matter, just some rock and ice and nothing spectacular. But apparently, just because we didn’t see the regular traces of biological functions doesn’t mean there isn’t anything alive.

Yes, I know it looks like a nanoscopic block of nothing but that’s why we’re using a quantum-tunneling nanoscope. Look closer. Do you see it now? The Planck perturbations? Yes? Isn’t it awesome?!

Don’t tell me it can’t be! It’s right there in front of your face! You can see the reactions. That thing interacts with the quantum foam. It eats virtual particles!

What is it doing to the fabric of our reality? Well, that’s what we’re going to look into next. No, it’s not making nanoscopic black holes. Don’t be ridiculous. It wouldn’t have survived this long if it would. How long? I don’t know. That comet has an X designation. We’ve only been following it for just over a year now. We haven’t figured out its trajectory yet. Of course, that’s why I was so interested in it.

Could these things be affecting the comet’s orbit? Possibly. The Quantum Foam is the basis of our reality. It bubbles and sinks like a lake surface under heavy rain. Virtual particles pop in and out of existence all the time. It’s an even push and pull on the fabric of the universe. If you remove one virtual particle, you are creating a sort of divot in space-time.

No, please don’t write about a new life form pooping divots in space-time…


Posted in From the Writing Desk, Life, Stories by with no comments yet.

Flash Fiction February 09: Food

Have you ever heard of food blindness?

You probably heard of face blindness, right? Prosopagnosia is a neurological condition meaning a person can’t make out details in faces, can’t distinguish between different face, and/or can’t recognise a face is even a face and not a bacon-cheese omelet.

You might be salivating at the that last concept there but I wouldn’t know. I know of the concept. I’ve read stories and seen movies where a character craves a food item so much their mouth starts producing excess drool with no conscious control. But it never happened to me. I have food blindness.

What does that mean? Exactly what you think it means. I can’t distinguish between different tastes. Sour, sweet, salty, bitter, umami, nothing. No, it doesn’t mean everything tastes like chicken or ash. I don’t even know how those taste. Have you tried licking not dirty, not freshly cleaned glass? Can you tell me what water tastes like? Exactly. that’s what I mean. It’s nothing.

My friends sometimes gush over how this hamburger is so good, how this is the best fruit salad they ever ate, or how I should try real Champagne or real gelato, but it doesn’t make a difference. I wish it would. It seems like I’m missing a big part of life and it always makes me a bit sad when we go out to dinner, to celebrate, just to have fun, to enjoy life… and food.

But, you know what?

I dominate spicy-eating competitions.


Posted in From the Writing Desk, Life, Stories by with no comments yet.