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.

Temp Logs into Documentation

Here’s an idea I had while writing a server application I needed to test on a remote computer with limited debugging abilities…

I insert debug logs, temporary logs, before and/or after important sections of flow so I could see in the console what is going on and what is failing. But I wouldn’t want them there when the app rolls into production.

And then I thought, people hate writing in-line documentation but it’s quite important. And here I have all these debug logs explaining what is going on. So, instead of deleting them, comment them out. Then I have them for later, if I want, and they pretty much function like in-line documentation.

Win-Win!


Posted in IT, Life, Practice, Programming, Thinking Out Loud, Work by with comments disabled.

קצת גאה בעצמי

היה לי יום טוב היום.

זאת אומרת, הוא התחיל בזה שחשבתי שיש לי שעון ואז גיליתי שיש לי אבל, משום מה, הוא לא העיר אותי. אז היפלתי על מעין לטפל במוצארט בבוקר ומיהרתי החוצה.

סיימתי עוד פרויקט בעבודה והראיתי אותו לבוס. קיבלתי כמה תיקונים עליהם אני עדיין עובד. בסדר. אבל אני כן גאה בזה שבשביל להשיג כל מיני אפקטים הייתי צריך להשתמש בחבילת תוכנה שכולם משתמשים בה אבל לא הצלחתי לגרום לה לעשות בדיוק מה שאני רוצה. כששאלתי, התשובה שקיבלתי היא ‘יש דרך אבל היא לא כל כך טובה אבל ככה כולם עושים’. אז לא רציתי לעשות את זה ככה. כתבתי גרסה משל עצמי.

לא שכתבתי ספריה פופלארית מאפס אבל, אם היא מסוגלת לעשות א’ ועד ת’, אני צריך ח’ וחצי, אולי שני ח’. והיא לא הייתה יכולה לתת לי את זה. אז לקחתי שעה וחצי וכתבתי משהו שעושה שלושה וחצי ח’, כדי שיהיה וזה כבר היה על הדרך.

וחזרתי הביתה ועשיתי התעמלות. יום בטן. לא הצלחתי להגיע לגבול הנוכחי אבל הצלחתי לסיים את הקודם בהצלחה. לפחות זה. אני כבר מרגיש יותר טוב. בהחלט יותר ערני ואנרגטי.

😉


Posted in IT, Life, Me, Programming by with comments disabled.

Tidbits of Experience: Unity App on Android Not Showing Permission Request Dialog

It happened to me that an app I was creating required some Android permissions and while it did show the permission dialogs when I first installed it, subsequent builds, with more or different permissions, didn’t pop the dialog. Even after uninstalling and reinstalling the app, nothing happened.

Digging through the AndroidManifest.xml file Unity was generating, I found this line:

<meta-data android:name=”unityplayer.SkipPermissionsDialog” android:value=”true” />

So, to override, make sure you have an AndroidManifest.xml file in your Plugins\Android directory (you can copy the generated file from Temp\StagingArea as a start) and make sure you have the line:

<meta-data android:name=”unityplayer.SkipPermissionsDialog” android:value=”false” />

Under your Application tag.

It will ask for permissions every time you reinstall the app but it should be good from then on out.


Posted in Life, Practice, Programming, Thinking Out Loud by with comments disabled.

The Push Forward Extensions

Here is a package of several extensions I’ve created that I use in my Unity projects. I thought they would be useful and would appreciate any feedback.

Push Forward Extensions.


Posted in Programming, Work by with comments disabled.

I Made a Game!

It’s here.

You need a phone and at least four people to play it.

Have fun. I’m tired. Good night.


Posted in From the Writing Desk, Gaming, Life, Programming by with comments disabled.

Success!

So, I’m working on a dice roller for Android…

And today, after much mucking about with HTTP packages and a little mucking about with System.Net (after I got tired and decided to do it bare bones) and a little bit of https wrangling, I finally got my first real response from Random.org. And it was pretty quick.

Yay! I’m out.


Posted in High-Tech, Life, Programming by with 5 comments.

Fuck You, Xamarin

After messing around with tutorials and trying to put something together for about a month and finally running into huge building/libraries/references issues that I couldn’t solve for a few days, I decided to quit Xamarin development. At least, for now.

Even planned as a simple 2D application, I’m willing to accept the splash screen and loading times so I can do this handily in Unity GUI. And I know it will compile very easily to Android and, slightly less easily, to iOS. It will definitely be quicker and easier to build.


Posted in IT, Life, Programming by with comments disabled.

Don’t You Just Love it When a Plan Comes Together

Yesterday was interesting. I was doing my thing, as usual. I knew there were problems with the latest store version we uploaded but I was practicing not shoving my nose in to things I probably shouldn’t. It happens to me quite a lot that I try to help but I really shouldn’t, for various reasons. So, this time, I did that.

I don’t know exactly how much time has passed but I noticed the rest of the team wasn’t getting any progress. So, I joined in, took a look at what they were doing, suggested some things that didn’t quite help, and then decide to investigate it on my own. I pushed some breakpoints in the flow and spent about 15 minutes looking at exactly what was happening. Then I said: “I can tell you exactly what is happening!”

Then everyone crowded around my station while I explained why it happens and what I think we should do to fix it. The response was stunned silence. So, I said “No objections or suggestions? Ok, I’ll do what I said.” Then some stayed to watch. :)

It doesn’t happen all the time. But it’s fun when it does.


Posted in IT, Programming, Work by with comments disabled.

Global Game Jam 2016

7:19 – Soon, we will start. Feeling: Excited.

11:14 – Got there. Heard the keynote. Got the theme (No, not telling). Now Brainstorming.

11:42 – Getting to work.

00:31 – Home now. Was a busy day. The venue itself isn’t that great; the air conditioning is brutal, the separate spaces are nice but it’s tough to even stay properly hydrated. Took out the pup. Going to go to sleep soon.

10:51 – Back in the saddle again. 7 Hours to demo.

12:43 – Finished the basic system. Now starting to write content. The peckishness has begun. They said pizzas are forthcoming.

13:37 – Refueled and ready to go again.

18:14 – Wrapping up. Getting ready for the presentation.

20:34 – Presentations completed. Some really nice games. Mine felt inadequate. Maayan’s looked very nice. They both, one Twine based, one completely console, definitely turned some heads in a room mostly composed of Unity developers.

00:57 – Concluded with a family dinner at Maayan’s parents and a viewing of Gav HaUma. Now, finally, going to sleep. Tomorrow, a full workday awaits.


Posted in Gaming, Life, Programming by with comments disabled.