One principle advantage of type safety is catching errors at compile time.
TypeSafe brings this same advantage to your Unity-powered game when loading resources, scenes or using layers and tags.
Key Features
Automatically scans your project and generates strong-typed classes than can be used to replace raw strings in your code.
Using these safe classes ensures that any resource, layer or scene you try and use in code always exists.
Moving, renaming or deleting a resource will cause compile errors at the place in code they were used.
@iamsam , voucher sent via PM. Thanks for your interest!
@movra , unfortunately TypeSafe won’t help there In C#6 there is the nameof() operator which is perfect, but we’ll have to wait for Unity to upgrade their version of Mono for that. Alas! Were you interested in having a voucher?
@Simie Sure, I want to try using TypeSafe with Entitas. It’s a nifty framework but you still have code like this to load prefabs:
public void Start() {
const string resourceName = "Opponent";
for (int i = 1; i < 10; i++) {
var speed = Random.value * 0.02f;
_pool.CreateEntity()
.AddResource(resourceName)
.AddPosition(i + i, 0, 0)
.AddMove(speed, speed);
}
}
which connects to
public void Execute(List<Entity> entities) {
foreach (var e in entities) {
var res = Resources.Load<GameObject>(e.resource.name);
var gameObject = Object.Instantiate(res);
gameObject.transform.parent = _viewContainer;
e.AddView(gameObject);
}
}
I have used it for only half an hour just replacing the resource path magic strings, but I can already tell TypeSafe makes development in Unity a lot more robust. Looking at the feature list I’ve barely scraped the surface.
The asset itself is also very polished, just looking at details like filtering folders and the ability to customize the naming scheme.
Hey, I’d love to give this a shot if you’ve still got the voucher left!
I’ve got something that I cooked up for myself that works pretty well on a basic level, but it’s nowhere near as feature-complete (or customizable) as TypeSafe.
1.0.1 is been approved and is now available on the asset store.
The next version, 1.1.0, will have a system for hooking external data into TypeSafe so you can generate classes with your own data. This should be submitted within a few days and be available shortly after.
This is an extremely polished asset store product which will really make your code robust and bug free. Extremely easy to use and is very polished. I was working on something similar but after trying this last week, I can say a million thanks to the author for creating the plugin. I fully recommend it :).
PS. I am sorry for the late update, will put a review on the asset store too.
@iamsam , thanks for the kind words! I’m really pleased you have found TypeSafe useful.
I’ve just submitted version 1.1.0 to the asset store. A big thanks to @electroflame for helping me test the custom data source part of this release. Changelog is below, and it should be approved and available on the asset store within about a week.
1.1.0
New:
Added ITypeSafeDataSource interface for using TypeSafe for custom data. See documentation for details.
Added TypeSafeApi static class for invoking TypeSafe scan/compile process via script.
PrefabResource.Instantiate(Vector3) overload added (no rotation)
Fixes:
Fixed “Object has been cleaned up” warning when saving a scene with TypeSafe enabled.