> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentityfactory.md).

# Class ksEntityFactory

Namespace: [KS.Reactor.Client.Unity](/reactor/api-reference/ks.reactor.client.unity.md)\
Assembly: KSUnity-Source.dll

Factory for creating game objects for entities. Use this class to implement your own entity factory and assign it to ksRoom.EntityFactory.

```csharp
public class ksEntityFactory
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksEntityFactory](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentityfactory.md)

#### Derived

[ksEntityLinker](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentitylinker.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Methods

### GetGameObject(ksEntity, GameObject) <a href="#ks_reactor_client_unity_ksentityfactory_getgameobject_ks_reactor_client_unity_ksentity_unityengine_g" id="ks_reactor_client_unity_ksentityfactory_getgameobject_ks_reactor_client_unity_ksentity_unityengine_g"></a>

Gets the game object for an entity. The returned game object must have a [ksEntityComponent](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentitycomponent.md) and must not be assigned to another non-destroyed entity.

```csharp
public virtual GameObject GetGameObject(ksEntity entity, GameObject prefab)
```

#### Parameters

`entity` [ksEntity](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentity.md)

The entity to get the game object for.

`prefab` GameObject

The prefab associated with the entity's asset Id or the scene prefab with the matching entity id.

#### Returns

GameObject

Game object representing the entity.

### ReleaseGameObject(ksEntityComponent) <a href="#ks_reactor_client_unity_ksentityfactory_releasegameobject_ks_reactor_client_unity_ksentitycomponent" id="ks_reactor_client_unity_ksentityfactory_releasegameobject_ks_reactor_client_unity_ksentitycomponent"></a>

Called when an entity is destroyed and [DestroyWithServer](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentity.md#KS_Reactor_Client_Unity_ksEntity_DestroyWithServer) is true, or when [CleanUp](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentitycomponent.md#KS_Reactor_Client_Unity_ksEntityComponent_CleanUp) is called on a game object that is not linked to a non- destroyed entity. Not called for entity game objects that are part of the initial scene. Override this to implement your own destruction logic. The default implementation destroys the game object.

```csharp
public virtual void ReleaseGameObject(ksEntityComponent entity)
```

#### Parameters

`entity` [ksEntityComponent](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentitycomponent.md)

Entity component to release the game object from.

### ReleaseGameObject(ksEntity) <a href="#ks_reactor_client_unity_ksentityfactory_releasegameobject_ks_reactor_client_unity_ksentity" id="ks_reactor_client_unity_ksentityfactory_releasegameobject_ks_reactor_client_unity_ksentity"></a>

```csharp
[Obsolete("Use the overload that takes a ksEntityComponent argument instead.")]
public virtual void ReleaseGameObject(ksEntity entity)
```

#### Parameters

`entity` [ksEntity](/reactor/api-reference/ks.reactor.client.unity/ks.reactor.client.unity.ksentity.md)
