©2018 OMNIRIFT LLC

Asset Review: TypeSafe - Resource Constants



Enter Unity:

You have some programming experience, and the inspector's drag-and-drop features just make development so fast.

You make a couple of games this way, but notice some organization problems in your last one.

You'd rather just finish and release though.

3 years later, you're developing a full-scale video game.

3 months into development, you notice a stringy mess of drag-and-drop references!

"There has to be a better way than dragging these asset references to EVERY GameObject and Prefab!"

Well there is, and it's called TypeSafe.


What Does It Do?

TypeSafe is a Unity Asset that allows you to generate references to your Resources as constants in your code.

That means to reference Layers, Tags, Prefabs, and some others, you won't have to drag anything or create constants by hand.

Pretty awesome. Here's an example:

var playerLayer = SRLayers.Player

Okay, so we have a reference to the layer assigned to Player objects. Now, I don't have to record it as a constant string anywhere because TypeSafe already did that automatically.

Let's say for example we wanted our player not to be able to shoot themselves. We could do something like this:

Physics.IgnoreLayerCollision(SRLayers.Player, SRLayers.PlayerProjectile)

Wonderful.

"Okay, so I don't have to type layer names in my scripts. Big whoop, I'd rather keep my 10 bucks."

...but wait, there's more!

So TypeSafe also stores references to everything in the Resources folder. What's more is that each folder is a class, which allows for great code readability.

For example, let's say I have 3 different enemies I want to reference. They're in my Resources/Prefabs/Enemies/ folder. Here we go:

enemy1 = SRResources.Prefabs.Enemies.Gunship

enemy2 = SRResources.Prefabs.Enemies.Interceptor

enemy3 = SRResources.Prefabs.Enemies.Frigate

Naturally they're spaceships because this is an Omnirift post.

Anyway, I have references to my enemies prefabs and I can now spawn them in the game or do anything else I'd like with them.

But what if you wanted to spawn all of them in a loop? Check it out:

foreach (GameObject enemy in SRResources.Prefabs.Enemies.GetContents<GameObject>()) {

// do something with enemy

}

Oh look, I didn't have to drag my 3 enemy prefabs into a Singleton Unity GameObject's collection with the inspector and iterate over it. This is why TypeSafe is really great.

Performance

I'll be honest, this asset gives some addition to the infamous 'Unity Refresh' when refocusing Unity in your OS after file/code changes.

That's why in TypeSafe's settings menu, you can choose either automatic rebuilds or manual builds.


I get it though, "why would I want to stop using one of Unity's biggest features?"

You wouldn't.

You see, what TypeSafe does is provide you with great organizational power, but as the cliche goes, with great power comes great responsibility.

When using constants for many different features, you want to keep reusability in mind.

For example, if I wanted my spaceships to spawn variable gun projectiles, rather than making 3 different spaceship scripts just to reference different constants, I could use the inspector to drag and drop a different projectile reference to the projectile attribute.

So make sure you only use TypeSafe constants when you know you won't need a variable attribute.

Should I Get It?

TypeSafe does not really have a lot of negatives. The only real problem with it is that it can be slow with a large project.

The good thing is that there is a solution: use manual constant generation instead of automatic.

Personally I use automatic constant generation, but I use a very strong computer because of Unity and Unity Plugin overhead.

TypeSafe also doesn't cost much at all; it's a very good deal at $10.00, or $8.00 if you have a Plus or Pro subscription.

Yes, you should get it, and you can do that here:


Okay, now that we're done talking about buying TypeSafe, use it and let me know what you think! (Or just send me hate comments, whatever makes you feel better.)

Have an awesome day,

Bilal

#gamedev #unity #review #assetstore #unityassetstore #unity3d

45 views