If you’ve been working with Unity for any sort of while you’ve probably used Coroutines before. They’re not exactly the bread and butter of using Unity but they’re like the jam or honey you put immediately after. You’ve probably used a lot of “yield return null” to wait for the next frame before resuming execution? I bet you even have used a “yield return null” loop to check a predicate every frame before continuing. I’ve done it myself. I’ve even written a repeating coroutine helper that uses null to check a predicate before running a given action. Well… stop that. Recently (and by ‘recently’, I mean at least a year) Unity now has two new conditions you can use in coroutines: WaitUntil and WaitWhile and they do exactly what you think they do. Just use any of these two instead of your usual “yield return” and put in a function (even a lambda) that returns a boolean then the coroutine will handle the checking by itself. It’ll check every frame if the predicate is fulfilled and will break if it is or isn’t, respectively. The underlying code this represents is exactly the same like you wrote yourself before but now your code can be a lot more elegant. You’re welcome.
Posted in IT, No Category, Programming and tagged Unity by Eran with .
Posted in IT, No Category, Programming by Eran with .
Recently, some clueless joe on Twitter said he will pay 10,000$ to the person who adds a multiplayer aspect to Zelda: Breath of the Wild. If he was going to donate to a modder who was working on it, that would have been fine but it seems like he was thinking that he could hire someone to do something like that for that kind of money. Here is a long, detailed response to this which you should read but here’s the summary: 10,000$ would pay for about two work months of the average+ programmer. Also, networking is hard. The hardest networking challenges in gaming usually arise in fighting games because they usually need to be exactly per pixel and per frame accurate and, probably over distances where network traffic takes more time to go back and forth than it takes pro players twitch reflexes to react. You can see how important this is if you go back and read about the network woes of Street Fighter V. Now, the demands of a PvE, open world, action RPG would probably be a lot less strict but these are still difficult problems. Especially if you’re talking about tacking on something like this onto a game that was definitely not designed for it. You want a more current example? On the one hand, Battlefield 2042 is out now and it’s buggy as hell. On the other hand, Halo Infinite’s multiplayer is also out and it’s much better. Probably because the team is backed Continue Reading →
Posted in Gaming, Less Interesting News, Practice, Programming, Thinking Out Loud by Eran with .
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. In your Project window, below all your regular files is a Packages folder. Right click on it and select Show in Explorer. In that Packages folder, create a new directory and name it however you like. This will be the root of your package. Do remember that the folder name can not contain spaces. Create a new “package.json” file. This page right here explains everything about the structure of the file. And here is an example file. Back in Unity, your new package should be visible with the name you gave it. 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. 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. Continue Reading →
Posted in Practice, Programming, Thinking Out Loud by Eran with .
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, No Category, Practice, Programming, Thinking Out Loud, Work by Eran with .
היה לי יום טוב היום. זאת אומרת, הוא התחיל בזה שחשבתי שיש לי שעון ואז גיליתי שיש לי אבל, משום מה, הוא לא העיר אותי. אז היפלתי על מעין לטפל במוצארט בבוקר ומיהרתי החוצה. סיימתי עוד פרויקט בעבודה והראיתי אותו לבוס. קיבלתי כמה תיקונים עליהם אני עדיין עובד. בסדר. אבל אני כן גאה בזה שבשביל להשיג כל מיני אפקטים הייתי צריך להשתמש בחבילת תוכנה שכולם משתמשים בה אבל לא הצלחתי לגרום לה לעשות בדיוק מה שאני רוצה. כששאלתי, התשובה שקיבלתי היא ‘יש דרך אבל היא לא כל כך טובה אבל ככה כולם עושים’. אז לא רציתי לעשות את זה ככה. כתבתי גרסה משל עצמי. לא שכתבתי ספריה פופלארית מאפס אבל, אם היא מסוגלת לעשות א’ ועד ת’, אני צריך ח’ וחצי, אולי שני ח’. והיא לא הייתה יכולה לתת לי את זה. אז לקחתי שעה וחצי וכתבתי משהו שעושה שלושה וחצי ח’, כדי שיהיה וזה כבר היה על הדרך. וחזרתי הביתה ועשיתי התעמלות. יום בטן. לא הצלחתי להגיע לגבול הנוכחי אבל הצלחתי לסיים את הקודם בהצלחה. לפחות זה. אני כבר מרגיש יותר טוב. בהחלט יותר ערני ואנרגטי. 😉
Posted in IT, Me, No Category, Programming by Eran with .
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 No Category, Practice, Programming, Thinking Out Loud by Eran with .
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 Eran with .
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, No Category, Programming by Eran with .
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, No Category, Programming by Eran with 5 comments.