#Singleton entity during baking

1 messages · Page 1 of 1 (latest)

jovial ridge
#

Is there a way to create a singleton entity in the Baker Bake function, I have gone through the docs but haven't found any.

neat hill
#

a singleton is just only 1 instance of an entity

#

var entity = EntityManager.CreateEntity(typeof(mycomponent))

#

you now have a singleton

#

var entity1 = EntityManager.CreateEntity(typeof(mycomponent))
you now no longer have a singleton

#

so to create a singleton in baking is just only bake 1 copy of an entity

#

there's nothing special or different about a singleton

#

the getsingleton method just has a check for entitycount == 1 in it