# GetExistingSystemManaged

> Return an existing instance of a system of type T in this World.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## GetExistingSystemManaged\<T>()

Return an existing instance of a system of type `T` in this World.

```csharp
public T GetExistingSystemManaged<T>() where T : ComponentSystemBase
```

### Returns

| Type | Description                                                                                                  |
| ---- | ------------------------------------------------------------------------------------------------------------ |
| T    | The existing instance of system type `T` in this World. If no such instance exists, the method returns null. |

### Remarks

**Note:** This system reference is not guaranteed to be safe to use. If the system or world is destroyed then the OnDestroy and cleanup functionality will have been called for this system.

If possible, using [World.GetExistingSystem](/engine/7000.0/script-reference/unity/entities/world/getexistingsystem.md) is preferred, and instead of public member data, component data is recommended for system level data that needs to be shared between systems or externally to them. This defines a data protocol for the system which is separated from the system functionality.

Private member data which is only used internally to the system is recommended.

Keep in mind using a managed reference for systems

* encourages coupling of data and functionality

* couples data to the system type with no direct path to decouple

* does not provide lifetime or thread safety guarantees for data access

* does not provide lifetime or thread safety guarantees for system access through the returned managed reference

## GetExistingSystemManaged(Type)

Return an existing instance of a system of type `type` in this World. Prefer the version that takes a SystemTypeIndex where possible to avoid unnecessary reflection.

```csharp
public ComponentSystemBase GetExistingSystemManaged(Type type)
```

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The system type

### Returns

| Type                                                                                         | Description                                                                                                     |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [ComponentSystemBase](/engine/7000.0/script-reference/unity/entities/componentsystembase.md) | The existing instance of system type `type` in this World. If no such instance exists, the method returns null. |

### Remarks

**Note:** This system reference is not guaranteed to be safe to use. If the system or world is destroyed then the OnDestroy and cleanup functionality will have been called for this system.

If possible, using [World.GetExistingSystem](/engine/7000.0/script-reference/unity/entities/world/getexistingsystem.md) is preferred, and instead of public member data, component data is recommended for system level data that needs to be shared between systems or externally to them. This defines a data protocol for the system which is separated from the system functionality.

Private member data which is only used internally to the system is recommended.

Keep in mind using a managed reference for systems

* encourages coupling of data and functionality

* couples data to the system type with no direct path to decouple

* does not provide lifetime or thread safety guarantees for data access

* does not provide lifetime or thread safety guarantees for system access through the returned managed reference

## GetExistingSystemManaged(SystemTypeIndex)

Return an existing instance of a system of type `type` in this World. This avoids unnecessary reflection.

```csharp
public ComponentSystemBase GetExistingSystemManaged(SystemTypeIndex type)
```

### Parameters

**** (\[SystemTypeIndex]\(/engine/7000.0/script-reference/unity/entities/systemtypeindex)): The system type

### Returns

| Type                                                                                         | Description                                                                                                     |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [ComponentSystemBase](/engine/7000.0/script-reference/unity/entities/componentsystembase.md) | The existing instance of system type `type` in this World. If no such instance exists, the method returns null. |

### Remarks

**Note:** This system reference is not guaranteed to be safe to use. If the system or world is destroyed then the OnDestroy and cleanup functionality will have been called for this system.

If possible, using [World.GetExistingSystem](/engine/7000.0/script-reference/unity/entities/world/getexistingsystem.md) is preferred, and instead of public member data, component data is recommended for system level data that needs to be shared between systems or externally to them. This defines a data protocol for the system which is separated from the system functionality.

Private member data which is only used internally to the system is recommended.

Keep in mind using a managed reference for systems

* encourages coupling of data and functionality

* couples data to the system type with no direct path to decouple

* does not provide lifetime or thread safety guarantees for data access

* does not provide lifetime or thread safety guarantees for system access through the returned managed reference
