Upgrading to 2.0.0

Turian 2.0.0 makes data assets and references behave the way Unity users expect. Most projects upgrade without touching code; read on if you use data assets from scripts or implement IAssetLoader yourself.

Data assets are shared

Before: every GetContent() call read the file again and returned a new, independent copy. Now: each data asset is one shared object. Everything that loads it — GetContent(), IAssetLoader, a field referencing it — gets the same instance, and a change made through one is seen by all.

Who is affected: scripts that changed a data asset's values expecting a private copy (for example, an enemy lowering the Health it read from a shared stats asset).

What to do: take a copy where you need one:

var myStats = DataAsset.Instantiate(sharedStats);
myStats.Health -= damage;   // the shared asset is untouched

Play Mode still starts from the saved values each time; changes made while playing are never written to disk.

Direct references are saved as references

Before: a component field typed as a node, a component or a data asset was saved as a full copy of that object, so after reloading it pointed at a detached duplicate. Now: such fields — and lists or arrays of them — are saved as references and reconnected when the scene loads:

public class Turret : Component
{
    public Node? Target;           // saved as {"$ref": "<id>"}
    public WeaponData? Weapon;
}

Who is affected: projects with such fields (the built-in FollowCameraComponent.Target is one).

What to do: nothing — scenes saved in the old form still load, and are rewritten in the new form the next time you save them. If you really want a copy, mark the field [SerializeInline].

IAssetLoader has new members

Who is affected: only code that implements IAssetLoader itself; code that calls it is unaffected.

What to do: implement LoadContentAsync<TData>(id), PreloadAsync(ids) and PreloadLabelAsync(label), or delegate them to a wrapped RuntimeAssetLoader.

Coming from Unity

Unity Turian 2.0.0
public Transform target; public Node? Target;
public Rigidbody body; public SomeComponent? Body;
public WeaponData weapon; (ScriptableObject) public WeaponData? Weapon; (DataAsset)
Instantiate(scriptableObject) DataAsset.Instantiate(dataAsset)
if (target == null) after Destroy if (ObjectReferences.IsMissing(Target))
[SerializeReference] (polymorphic managed data) inline by default for plain classes; [SerializeInline] for engine objects
Addressables labels asset Labels + IAssetLoader.PreloadLabelAsync

Unlike Unity, a data asset cannot reference a scene object at all: the compiler reports TUR0001 and suggests NodeRef<T> or ComponentRef<T>, which store an id to resolve against a scene at runtime.


← All docs Edit this page