#Managed Component vs AddComponentObject

1 messages · Page 1 of 1 (latest)

vast bough
#

I am having difficulty seeing why I would need

public class MyManagedComponent : IComponentData
{
public Transform transform;
// other managed state..
}

Anywhere I see this pattern emerging, I find myself wondering why not add the MonoBehaviours, Transforms etc in question directly using AddComponentObject.

What are the advantage of managed components vs just adding the managed stuff with AddComponentObject?

dapper sundial
#

What if you want to have more than 1 Transform referenced on the entity?

#

Say, 1 for root, 1 for skinned root, 1 for hand slot etc

vast bough
#

Ok then why not just add that monobehaviour with AddComponentObject which conveniently has all the serializefield transform you mentioned?

dapper sundial
#

A lot of APIs only work with IComponentData

vast bough
#

So in most case you're better off with IComponentData then?

dapper sundial
#

class based IComponentData also supports the auto IDisposeable, IClonable pattern

vast bough
#

I mean just adding that interface to the monobehaviour should be enough right? Doesn't need to be a empty class?

dapper sundial
#

Which is great for creating and managing gameobject lifecycles automatically

vast bough
#

Hmm ok thanks!