clone(recursive:)
Duplicates an entity to create a new entity.
Declaration
@MainActor @preconcurrency func clone(recursive: Bool) -> SelfParameters
- recursive:
A Boolean that you set to
trueto recursively copy all the children of the entity. Otherwise, no descendants are copied.
Return Value
The duplicate.
Discussion
All component data is cloned automatically. If you clone an entity that stores custom data that’s not part of a component, override the didClone(from:) method to copy that data manually.