#Authoring component tags in ECS

1 messages · Page 1 of 1 (latest)

onyx grail
#

ive been messing around with ECS a little, but sadly the documentation is still not great. do any of you happen to know how i can convince a baker to add a component tag (that is, a component with no data) without resorting to the entity manager? for some reason, it seems that the way youd normally do this, the Bake method, only works if you specify data within AddComponent. i guess i could use a dummy variable or something, but surely there is a better way

(nb i dont check this forum very often so please ping me if you know a solution)

candid knoll
#

You can either do:
AddComponent(entity, new TagComponent());
or
AddComponent<TagComponent>(entity);

onyx grail
#

when i add a dummy variable, this works perfectly fine - but as-is, it does not add the appropriate component to entities in the subscene

stable tulip
#

Wild guess, but I wonder if it's because of the empty Authoring class. At first glance you seem to be doing everything right. Can you try expanding the Authoring class with some gibberish? Some editable field and maybe pass that to baker?

#

Or maybe your baking is just not running at all? (somehow)

onyx grail
#

but i cant imagine that this is the way youre supposed to do it

stable tulip
#

I thought you meant it only works if you specify data in the tag component that you're trying to add, not the Authoring MonoBehaviour "...specify data within AddComponent..."

#

Could be a bug, I'm not sure they'd have expected completely empty authoring classes. Although you might as well ignore it, here's the best life-hack I learnt about DOTS; Doing an authoring class / baker for every small amount of data is how they teach it, but it is not how you should use it. Instead of having GravityAuthoring/Baker/Tag as a whole separate thing, just think for example, PlayerAuthoring that adds a whole bunch of stuff. You could even have a checkbox in editor that specifies if it should add GravityTag as well. I usually have about 3 - 5 components per authoring, some of them just tags, some parameterized by the authoring etc. Ofc this is completely arbitrary, but point is, making a baker and authoring for every (or even every second) component... is a waste. 🙂

#

Systems are a little different, but that's off-topic.

stable tulip
#

You're welcome!

onyx grail
#

update: it seems like my initial code is working just fine - a query for GravityTag behaves exactly like you would expect, and i get the appropriate duplication errors if i add the authoring script twice - but unity does not visibly assign the component to the entity for some reason

#

notice how PhysicsComponent, another custom component that does have data, is displaying just fine while GravityTag is apparently invisible

#

is this a bug?

mint ruin
#

The tag is right there up the top

#

Am I missing something?

onyx grail
#

the only thing you are missing, i am afraid, is that i am seemingly blind :P

#

i suppose i was implicitly expecting all tags to be bold because of the scene tag

#

i guess that does resolve the problem lol