Class CoherenceSyncUtils
Utility class for CoherenceSync related operations.
public static class CoherenceSyncUtils
- Inheritance
-
CoherenceSyncUtils
Methods
AddBinding(CoherenceSync, Component, Descriptor)
Adds a Binding to a CoherenceSync.
public static Binding AddBinding(CoherenceSync sync, Component component, Descriptor descriptor)
Parameters
sync
CoherenceSynccomponent
Componentdescriptor
Descriptor
Returns
AddBinding(CoherenceSync, Component, string)
public static Binding AddBinding(CoherenceSync sync, Component component, string memberName)
Parameters
sync
CoherenceSynccomponent
ComponentmemberName
string
Returns
AddBinding(GameObject, Type, string)
public static Binding AddBinding(GameObject gameObject, Type type, string memberName)
Parameters
Returns
AddBinding<T>(GameObject, string)
public static Binding AddBinding<T>(GameObject gameObject, string memberName) where T : Component
Parameters
gameObject
GameObjectmemberName
string
Returns
Type Parameters
T
DestroyCoherenceComponents(GameObject)
Destroys the CoherenceSync component for the given GameObject, and any other component that depends on it.
public static void DestroyCoherenceComponents(GameObject gameObject)
Parameters
gameObject
GameObject
Exceptions
- ArgumentNullException
When
gameObject
is null.
IsBindingValid(CoherenceSync, Binding, out string)
Check if an existing synced member is still valid.
public static bool IsBindingValid(CoherenceSync sync, Binding binding, out string invalidReason)
Parameters
sync
CoherenceSyncbinding
BindingThe Binding instance that represents a synced member.
invalidReason
stringIf the binding is invalid, this string holds the reason why.
Returns
Remarks
A binding is valid if:
- The target Component exists.
- The associated Descriptor for the given Component type exists.
RemoveBinding(CoherenceSync, Binding)
Removes a Binding from a CoherenceSync.
public static bool RemoveBinding(CoherenceSync sync, Binding binding)
Parameters
sync
CoherenceSyncbinding
Binding
Returns
RemoveBinding(CoherenceSync, Component, Descriptor)
Removes a Binding from a CoherenceSync.
public static bool RemoveBinding(CoherenceSync sync, Component component, Descriptor descriptor)
Parameters
sync
CoherenceSynccomponent
Componentdescriptor
Descriptor
Returns
RemoveBinding(CoherenceSync, Component, string)
public static bool RemoveBinding(CoherenceSync sync, Component component, string memberName)
Parameters
sync
CoherenceSynccomponent
ComponentmemberName
string
Returns
RemoveBinding(GameObject, Type, string)
public static bool RemoveBinding(GameObject gameObject, Type type, string memberName)
Parameters
Returns
RemoveBinding<T>(GameObject, string)
public static bool RemoveBinding<T>(GameObject gameObject, string memberName) where T : Component
Parameters
gameObject
GameObjectmemberName
string
Returns
Type Parameters
T
RemoveBindings(CoherenceSync, Predicate<Binding>)
public static int RemoveBindings(CoherenceSync sync, Predicate<Binding> match)
Parameters
sync
CoherenceSyncmatch
Predicate<Binding>
Returns
RemoveInvalidBindings(CoherenceSync)
Removes all invalid Bindings from a given CoherenceSync.
public static int RemoveInvalidBindings(CoherenceSync sync)
Parameters
sync
CoherenceSync
Returns
- int
Number of Bindings removed.
- See Also
TryConvertToCoherenceSyncPrefab(GameObject, string, out GameObject, InteractionMode)
Adds a CoherenceSync component and converts a GameObject into a Prefab. Prefabs using CoherenceSync are ready to be networked by coherence.
public static bool TryConvertToCoherenceSyncPrefab(GameObject gameObject, string prefabPath, out GameObject prefab, InteractionMode interactionMode = 1)
Parameters
gameObject
GameObjectGameObject to convert into a Prefab.
prefabPath
stringPath where the Prefab Asset will be written on disk.
prefab
GameObjectReference to the Prefab Asset.
interactionMode
InteractionModeThe interaction mode for this action.
Returns
UpdateBindings(CoherenceSync)
Updates Binding Descriptors, adds missing required Bindings, and removes invalid Bindings.
public static bool UpdateBindings(CoherenceSync sync)
Parameters
sync
CoherenceSyncThe target component.
Returns
Remarks
When creating CoherenceSync components from code, you must call this method to ensure Bindings are up-to-date.
Exceptions
- ArgumentNullException
When
sync
is null.
- See Also
Events
OnBeforeBindingAdded
Raised before adding a binding to Bindings.
public static event Action<CoherenceSync, Binding> OnBeforeBindingAdded
Event Type
OnBeforeBindingRemoved
Raised before deleting a binding from Bindings.
public static event Action<CoherenceSync, Binding> OnBeforeBindingRemoved