You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2023-10-25-making-unity-a-decent-employee-0.md
+64-25Lines changed: 64 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -12,18 +12,28 @@ published: false
12
12
# target publish date: december
13
13
---
14
14
15
-
[hook with jeff, that stupid asshole]
15
+
It's a cloudy monday morning. Your jeans are soaked from the rain on the way to the office. There's only a sip of cold coffee left in your mug as you are leaving your desk with your presentation notes.
16
+
17
+
Your heart is pounding, as you open the door to the meeting room, knowing that a dozen of people sit there, waiting.
18
+
Jeff, the coworker you teamed up with, nods and smiles, reassuring that everything is prepared. Everyone's staring at you.
19
+
20
+
"So, this is the fantastic game Jeff and I worked on", you say nervously.
21
+
"Jeff, could you please put it on the Screen?"
22
+
23
+
Jeff goes "Alright!" and plugs his Laptop in. Everyone sees the cat trying to eat cotton candy, his desktop background.
24
+
"Jeff could you please open the Game?" What is he waiting for?
25
+
26
+
"No, I cannot open the Game", Jeff explains calmly, "the attachment in your mail last week was corrupted, so of course I don't have it. I didn't want to get in your way."
16
27
17
28
### WTjeFf?!
18
29
19
30
You take a deep breath. Isn't that wonderful. What a bold move, Jeff.
20
31
21
-
Think about it for a second: If your human colleague was doing what Unity does, you'd dig up their dead pet cat called Pumpkins, and plant its severed head on their bed while they're sleeping. Well, at least I would.
32
+
Think about it for a second: If your human colleague was doing what Unity does, you'd dig up their dead pet cat called Pumpkins, and leave the stiff body on their bed while they're sleeping. Well, at least I would.
22
33
23
-
![image of pumpkins the cat. if you are reading this instead of seeing the image: he was cute, trust me.]()
24
-
<!-- maybe leave this image without a link intentionally? -->
34
+

25
35
26
-
Let's shift perspectives: What would you have done in Jeff's position?
36
+
Let's shift perspectives: What would you have done in Jeff's position? What would be the right thing to do? What would be the nicest thing you could imagine?
27
37
28
38

29
39
@@ -44,14 +54,14 @@ If anything goes wrong, they will try to pretend that nothing happened. Happily
44
54
45
55
<!-- meme idea: this is fine -->
46
56
47
-
BUT don't give up! You and me, we are clever developers, we will not restrain from employing dark magic to squeeze Unity into something we can work with.
57
+
BUT don't give up! Let me tell you: You and me, we are clever developers, we will not restrain from employing dark magic to squeeze Unity into something we can work with.
48
58
49
59
> If your strategy was instead to switch to Unreal (what are you doing here??!), please let me know how it went in the comments. I might envy you :>
50
60
51
-
# Are you series
61
+
# Why so series
52
62
<!-- TODO: this section is as focused as the drawer in your kitchen that contains both the scissors and the banana shaped tupperware. delete everything except the table of contents? -->
53
63
54
-
Now, in my handful of years of fulltime Unity development, I have learned one or two things, that I'm happy to share today. Maybe this stuff is widely known, maybe it's a secret, maybe I'm an Idiot lol. All I know is that I'm writing the blog posts I wish I had read when starting to developing real projects in Unity.
64
+
Hi! I'm Johannes. In my handful of years of fulltime Unity development at [SWCode](https://swcode.io), I have discovered one or two goodies, that I'm happy to share with you now. Maybe this stuff is widely known, maybe it's a secret, maybe I'm an Idiot lol. All I know is that I'm writing the blog posts I wish I had read when starting to developing real projects in Unity.
55
65
56
66
> I can't be the only one thinking that Unity is horribly unreliable. I often wondered how all the professional studios deal with that, and my colleagues did too. In case you know, hit me up in the comment section!
57
67
@@ -63,43 +73,72 @@ The key strategy is to find problems sooner in the development workflow, instead
63
73
64
74
Learning from statically typed languages, we will add checks that run while Unity is building your application. We will automate error prone manual processes. We will craft our own C#, with blackmagic and hooks! We will exploit Unity's feature of adding scripts to the Editor to make up for missing functionality, which is actually a very neat feature of Unity c:
65
75
76
+

77
+
66
78
While I'm at it, let me dial back a bit on my rant. Don't let me shit on Unity for something we can easily add ouselves. I just wish it was there by default.
67
79
68
80
> Disclaimer: I'm working in a rather unconventional project environment. For example, we embed a Unity View into an existing Android/iOS App. That's because we at [SWCode](https://swcode.io) build an app that uses AR, called [SoesTour](https://www.so-ist-soest.de/de/tourismus/sehenswertes/soestour.php). The app aims to revive historical sites that long vanished, by digitally showing them at their exact locations in the real world. Due to this complicated setup, I had to touch with some nasty Unity bits that most people might not have to touch. I want this article to be generally applicable, so don't worry about it. It might be fun either way!
69
81
70
-
Oh MY GOD JOHANNES STOP talking already! Let's get GOING!
82
+
Oh my GOD JOHANNES STOP talking already! Let's get GOING!
71
83
72
84
The Four Strategies
73
85
-------------------
74
86
75
87
0.[YOU ARE HERE] Introduction
76
88
77
89
1. Write better code (duh!)
78
-
- Raise the level of abstraction
79
-
- Utilize basic C# language features because Unity doesn't
80
-
- Add obvious missing C# language features using black magic
81
-
- Create your high level Domain, instead of fiddling with unnecessary details all the time
82
90
91
+
In addition to utilizing the boring old clean code strategies, we will add missing basic features to both Unity and C#. Everything else builds on those.
92
+
83
93
2. Use code instead of assets (the controversial one)
84
-
- generate at compile time
85
-
- avoid using the editor to hook up objects
94
+
95
+
We will use code to control Unity, generating and modifying assets, instead of manually editing them by hand.
86
96
87
97
3. Smoothen the overall workflow (the one you might have expected)
88
-
- Automate import processes
89
-
- Automate setting the settings
90
-
- Automate clicking the clickies
91
-
- Seriously, let me press ONE button and then give me twenty minutes to pet my cat ... UHHHH work on something else.
98
+
99
+
Also we will automate clicking the clickies.
100
+
Seriously, let me press ONE button and then give me twenty minutes to pet my cat ... UHHHH work on something else.
92
101
93
102
4. Perform rigorous checks at build time (the banger! also black magic)
94
-
- Check asset data
95
-
- Check settings
96
-
- Check code
103
+
104
+
This one is huge. We will make sure that you notice bad project files before waiting for the 20 minute long build process to complete.
105
+
I've not seen this one anywhere else yet, but I'm sure any serious developer MUST be doing that... right?
106
+
107
+
These are rather large topics and I want to go into detail about them, so this will probably be more than one article. Goo look for a link at the end of this blogpost in case I forgot to go back here and edit this text before I click the juicy UPLOAD BUTTON! :D<!-- Note to future self: definitely don't ever remove this, I think it's cute -->
108
+
109
+
Within each topic, I will first describe the problematic situation that you too might have encountered in Unity. Afterwards I'll present my attempt at making it less horrible. I'll also try to share my experiences that I made after working with those solutions for quite some time. There will be code! Maybe a lot of it! Some will be controversial!
110
+
111
+
## Find the Jeff
112
+
<!-- todo: maybe move this hint from the introduction to a surprise at the end? -->
113
+
> In each post, I'll challenge you to find the hidden Jeff.
114
+
To find him, you'll have to find the matching code section for that posts Jeff story. If you find him, just be proud of yourself. Take the first character of each heading where Jeff's code section appears. These four letters are the secret code.
115
+
<!-- TODO what to do with the code? GIMME SOMETHING -->
116
+
117
+
This introduction does not contain a Jeff.
118
+
<!-- because he hid in this markdown comment! congrats! :D there, get him!!
119
+
<-- --<< JEFF (hiding) >>-- -->
120
+
121
+
(Sorry if your name is Jeff, I had to choose a name. Visit me in Soest and the beer is on me!)
122
+
123
+
## A note on performance
124
+
<aname="performance"><!-- link to this anchor using `post-url/#performance` --></a>
125
+
126
+
We're still not starting with the real content. Here's why:
127
+
128
+
A recurring theme in this series will be performance. So let me get this straight, once, and link to this section a thousand times from those indivudal blog posts:
129
+
130
+
- of course performance matters
131
+
- but only in a fraction of the code
132
+
- and developer time is more important
133
+
- so use abstractions first, and optimize only where you've __measured__ a performance bottleneck
97
134
98
-
These are rather large topics and I want to go into detail about them, so this will probably be more than one article. Goo look for a link at the end of this blogpost in case I forgot to go back here and edit this text before I click the juicy UPLOAD BUTTON! :D<!-- Note to future self: I definitely don't ever want to remove this, I think it's cute -->
135
+
We will use crazy Reflection and LINQ and write horribly inefficient code. That is, if you were to run it every frame unconditionally. But it's only used in tests, or once at initialization, or on build time. So get ready to unlearn those annoying for-loops and write better code in less time!
99
136
100
-
Within each topic, I will first describe the problematic situation you too might have encountered in Unity. Afterwards I'll present my attempt at making it less horrible. I'll also share my experiences that I made after working with those solutions for quite some time. There will be code! Maybe a lot of it! Some will be controversial!
137
+
All the time you save by choosing high-level abstractions, you gain for later optimization. It pays off. If this ever didn't work out for you, meet me outside, in the comment section.
101
138
102
-
If there is one thing I hate more than badly designed software, it's blog posts that promise a wonderful world, but then never get to the point, leaving you hyped up. That's why I personally made sure, for you specifically, that this blog posts has some real code in it, and you're not left with a hollow promise yet again: The first blog post of this series is already online!
139
+
## The code is now.
140
+
If there is one thing I hate more than badly designed software, it's blog posts that promise a wonderful world, but then never get to the point, leaving you all hyped up. That's why I personally made sure, for you specifically, that this blog posts has some real code in it, and you're not left with a hollow promise yet again: The first blog post of this series is already online!
0 commit comments