> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/scene-fusion/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/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfobjecteventdispatcher.md).

# Class sfObjectEventDispatcher

Namespace: [KS.SceneFusion.Client.Unity.Editor](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor.md)\
Assembly: KSUnity-Source.dll

The object event dispatcher listens for object events and calls the corresponding functions on the translator registered for the object's type.

```csharp
public class sfObjectEventDispatcher
```

#### Inheritance

object ← [sfObjectEventDispatcher](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfobjecteventdispatcher.md)

## Properties

### IsActive <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_isactive" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_isactive"></a>

Is the object event dispatcher running?

```csharp
public bool IsActive { get; }
```

#### Property Value

bool

## Methods

### Create(Object) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_create_unityengine_object" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_create_unityengine_object"></a>

Creates an sfObject for a uobject by calling TryCreate on each translator until one of them handles the request.

```csharp
public sfObject Create(Object uobj)
```

#### Parameters

`uobj` Object

uobj to create sfObject for.

#### Returns

[sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

for the uobject. May be null.

### Get() <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_get" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_get"></a>

```csharp
public static sfObjectEventDispatcher Get()
```

#### Returns

[sfObjectEventDispatcher](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfobjecteventdispatcher.md)

singleton instance.

### GetTranslator(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator_ks_scenefusion_client_sfobj" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator_ks_scenefusion_client_sfobj"></a>

Gets the translator for an object.

```csharp
public sfBaseTranslator GetTranslator(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj to get translator for.

#### Returns

[sfBaseTranslator](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfbasetranslator.md)

translator for the object, or null if there is no translator for the object's type.

### GetTranslator(string) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator_system_string" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator_system_string"></a>

Gets the translator for the given type.

```csharp
public sfBaseTranslator GetTranslator(string type)
```

#### Parameters

`type` string

#### Returns

[sfBaseTranslator](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfbasetranslator.md)

translator for the type, or null if there is no translator for the given type.

### GetTranslator\<T>(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator__1_ks_scenefusion_client_sf" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator__1_ks_scenefusion_client_sf"></a>

Gets the translator for an object.

```csharp
public T GetTranslator<T>(sfObject obj) where T : sfBaseTranslator
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj to get translator for.

#### Returns

T

translator for the object, or null if there is no translator for the object's type.

#### Type Parameters

`T`

### GetTranslator\<T>(string) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator__1_system_string" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_gettranslator__1_system_string"></a>

Gets the translator for the given type.

```csharp
public T GetTranslator<T>(string type) where T : sfBaseTranslator
```

#### Parameters

`type` string

#### Returns

T

translator for the type, or null if there is no translator for the given type.

#### Type Parameters

`T`

### GetUObject(sfObject, Object) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_getuobject_ks_scenefusion_client_sfobject" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_getuobject_ks_scenefusion_client_sfobject"></a>

Calls GetUObject on the translator for an sfObject.

```csharp
public Object GetUObject(sfObject obj, Object current = null)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj to get UObject for.

`current` Object

current value of the serialized property we are getting the UObject reference for.

#### Returns

Object

for the sfObject.

### InitializeTranslators() <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_initializetranslators" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_initializetranslators"></a>

Calls Initialize on all translators. Invokes OnInitialize and removes all OnInitialize handlers.

```csharp
public void InitializeTranslators()
```

### OnConfirmCreate(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onconfirmcreate_ks_scenefusion_client_sfo" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onconfirmcreate_ks_scenefusion_client_sfo"></a>

Calls OnConfirmCreate on the translator for an object.

```csharp
public void OnConfirmCreate(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj that whose creation was confirmed.

### OnConfirmDelete(sfObject, bool) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onconfirmdelete_ks_scenefusion_client_sfo" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onconfirmdelete_ks_scenefusion_client_sfo"></a>

Calls OnConfirmDelete on the translator for an object.

```csharp
public void OnConfirmDelete(sfObject obj, bool unsubscribed)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj that whose deletion was confirmed.

`unsubscribed` bool

true if the deletion occurred because we unsubscribed from the object's parent.

### OnConfirmSubscription(sfObject, bool) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onconfirmsubscription_ks_scenefusion_clie" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onconfirmsubscription_ks_scenefusion_clie"></a>

Calls [OnConfirmSubscription](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfbasetranslator.md#ks_scenefusion_client_unity_editor_sfbasetranslator_onconfirmsubscription_ks_scenefusion_client_sfob) on the translator for an object.

```csharp
public void OnConfirmSubscription(sfObject obj, bool subscribed)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj whose subscription state changed.

`subscribed` bool

True if we subscribed to receive the object's children.

### OnCreate(sfObject, int) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_oncreate_ks_scenefusion_client_sfobject_s" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_oncreate_ks_scenefusion_client_sfobject_s"></a>

Calls OnCreate on the translator for an object.

```csharp
public void OnCreate(sfObject obj, int childIndex)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj that was created.

`childIndex` int

childIndex the object was created at.

### OnDelete(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_ondelete_ks_scenefusion_client_sfobject" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_ondelete_ks_scenefusion_client_sfobject"></a>

Calls OnDelete on the translator for an object.

```csharp
public void OnDelete(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj that was deleted.

### OnDeselect(Object) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_ondeselect_unityengine_object" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_ondeselect_unityengine_object"></a>

Calls OnDeselect on the translator for a uobject.

```csharp
public void OnDeselect(Object uobj)
```

#### Parameters

`uobj` Object

uobj that was deselected.

### OnDirectLockChange(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_ondirectlockchange_ks_scenefusion_client" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_ondirectlockchange_ks_scenefusion_client"></a>

Calls OnDirectLockChange on the translator for an object.

```csharp
public void OnDirectLockChange(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj whose direct lock state changed.

### OnListAdd(sfListProperty, int, int) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlistadd_ks_scenefusion_sflistproperty_s" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlistadd_ks_scenefusion_sflistproperty_s"></a>

Calls OnListAdd on the translator for an object.

```csharp
public void OnListAdd(sfListProperty list, int index, int count)
```

#### Parameters

`list` [sfListProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sflistproperty.md)

list that elements were added to.

`index` int

index elements were inserted at.

`count` int

number of elements added.

### OnListRemove(sfListProperty, int, int) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlistremove_ks_scenefusion_sflistpropert" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlistremove_ks_scenefusion_sflistpropert"></a>

Calls OnListRemove on the translator for an object.

```csharp
public void OnListRemove(sfListProperty list, int index, int count)
```

#### Parameters

`list` [sfListProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sflistproperty.md)

list that elements were removed from.

`index` int

index elements were removed from.

`count` int

number of elements removed.

### OnLock(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlock_ks_scenefusion_client_sfobject" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlock_ks_scenefusion_client_sfobject"></a>

Calls OnLock on the translator for an object.

```csharp
public void OnLock(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj that was locked.

### OnLockOwnerChange(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlockownerchange_ks_scenefusion_client_s" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onlockownerchange_ks_scenefusion_client_s"></a>

Calls OnLockOwnerChange on the translator for an object.

```csharp
public void OnLockOwnerChange(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj whose lock owner changed.

### OnParentChange(sfObject, int) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onparentchange_ks_scenefusion_client_sfob" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onparentchange_ks_scenefusion_client_sfob"></a>

Calls OnParentChange on the translator for an object.

```csharp
public void OnParentChange(sfObject obj, int childIndex)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj whose parent changed.

`childIndex` int

childIndex of the object. -1 if the object is a root.

### OnPropertyChange(sfBaseProperty) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onpropertychange_ks_scenefusion_sfbasepro" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onpropertychange_ks_scenefusion_sfbasepro"></a>

Calls OnPropertyChange on the translator for an object.

```csharp
public void OnPropertyChange(sfBaseProperty property)
```

#### Parameters

`property` [sfBaseProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfbaseproperty.md)

property that changed.

### OnRemoveField(sfDictionaryProperty, string) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onremovefield_ks_scenefusion_sfdictionary" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onremovefield_ks_scenefusion_sfdictionary"></a>

Calls OnRemoveField on the translator for an object.

```csharp
public void OnRemoveField(sfDictionaryProperty dict, string name)
```

#### Parameters

`dict` [sfDictionaryProperty](/scene-fusion/api-reference/ks.scenefusion/ks.scenefusion.sfdictionaryproperty.md)

dict the field was removed from.

`name` string

name of removed field.

### OnSelect(Object) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onselect_unityengine_object" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onselect_unityengine_object"></a>

Calls OnSelect on the translator for a uobject.

```csharp
public void OnSelect(Object uobj)
```

#### Parameters

`uobj` Object

uobj that was selected.

### OnUnlock(sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onunlock_ks_scenefusion_client_sfobject" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_onunlock_ks_scenefusion_client_sfobject"></a>

Calls OnUnlock on the translator for an object.

```csharp
public void OnUnlock(sfObject obj)
```

#### Parameters

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj that was unlocked.

### Register(string, sfBaseTranslator) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_register_system_string_ks_scenefusion_cli" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_register_system_string_ks_scenefusion_cli"></a>

Registers a translator to handle events for a given object type.

```csharp
public void Register(string objectType, sfBaseTranslator translator)
```

#### Parameters

`objectType` string

objectType the translator should handle events for.

`translator` [sfBaseTranslator](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfbasetranslator.md)

translator to register.

### Start(sfSession) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_start_ks_scenefusion_client_sfsession" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_start_ks_scenefusion_client_sfsession"></a>

Starts listening for events and calls OnSessionConnect on all registered translators.

```csharp
public void Start(sfSession session)
```

#### Parameters

`session` [sfSession](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfsession.md)

session to listen to events on.

### Stop(sfSession) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_stop_ks_scenefusion_client_sfsession" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_stop_ks_scenefusion_client_sfsession"></a>

Stops listening for events and calls OnSessionDisconnect on all registered translators.

```csharp
public void Stop(sfSession session)
```

#### Parameters

`session` [sfSession](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfsession.md)

session to stop listening to events on.

### TryCreateSFObject(Object) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_trycreatesfobject_unityengine_object" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_trycreatesfobject_unityengine_object"></a>

Creates an sfObject for a uobject if the uobject is not already synced and is a syncable asset type or not an asset by calling TryCreate on each translator until one of them handles the request.

```csharp
public bool TryCreateSFObject(Object uobj)
```

#### Parameters

`uobj` Object

uobj to create sfObject for.

#### Returns

bool

true if an sfObject was creaed for the uobj.

### TryCreateSFObject(Object, out sfObject) <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_trycreatesfobject_unityengine_object_ks_s" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_trycreatesfobject_unityengine_object_ks_s"></a>

Creates an sfObject for a uobject if the uobject is not already synced and is a syncable asset type or not an asset by calling TryCreate on each translator until one of them handles the request.

```csharp
public bool TryCreateSFObject(Object uobj, out sfObject obj)
```

#### Parameters

`uobj` Object

uobj to create sfObject for.

`obj` [sfObject](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfobject.md)

obj for the uobject. May be null.

#### Returns

bool

true if an sfObject was creaed for the uobj.

### OnInitialize <a href="#ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_oninitialize" id="ks_scenefusion_client_unity_editor_sfobjecteventdispatcher_oninitialize"></a>

Invoked after translators are initialized. Once this is fired, it is safe to access translators using sfObjectEventDispatcher.Get().GetTranslator calls.

```csharp
public event sfObjectEventDispatcher.InitializeHandler OnInitialize
```

#### Event Type

[sfObjectEventDispatcher](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfobjecteventdispatcher.md).[InitializeHandler](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sfobjecteventdispatcher/ks.scenefusion.client.unity.editor.sfobjecteventdispatcher.initializehandler.md)
