Entity.RemoveComponent<T> method

template<typename T> void RemoveComponent();

Description

Removes component T from the entity. Safe to call whether or not the component is attached — no-op when absent. Existing references to the removed component are invalidated.

Note: when removing runtime-owning components (AudioComponent with an active AL source, RigidBodyComponent with a Jolt body), free the runtime resource first to avoid leaks.

Example

if (player.HasComponent<Thread::OutlineComponent>())
    player.RemoveComponent<Thread::OutlineComponent>();

Entity.RemoveComponent<T> metoda

template<typename T> void RemoveComponent();

Opis

Usuwa komponent T z encji. Bezpieczne niezależnie od tego, czy komponent jest podpięty — gdy go brak, nic się nie dzieje. Istniejące referencje do usuniętego komponentu przestają być ważne.

Uwaga: usuwając komponenty, które posiadają zasoby czasu działania (AudioComponent z aktywnym źródłem AL, RigidBodyComponent z ciałem Jolt), najpierw zwolnij ten zasób, żeby uniknąć wycieków.

Przykład

if (player.HasComponent<Thread::OutlineComponent>())
    player.RemoveComponent<Thread::OutlineComponent>();