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
syncCoherenceSynccomponentComponentdescriptorDescriptor
Returns
AddBinding(CoherenceSync, Component, string)
public static Binding AddBinding(CoherenceSync sync, Component component, string memberName)
Parameters
syncCoherenceSynccomponentComponentmemberNamestring
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
gameObjectGameObjectmemberNamestring
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
gameObjectGameObject
Exceptions
- ArgumentNullException
When
gameObjectis 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
syncCoherenceSyncbindingBindingThe Binding instance that represents a synced member.
invalidReasonstringIf 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
syncCoherenceSyncbindingBinding
Returns
RemoveBinding(CoherenceSync, Component, Descriptor)
Removes a Binding from a CoherenceSync.
public static bool RemoveBinding(CoherenceSync sync, Component component, Descriptor descriptor)
Parameters
syncCoherenceSynccomponentComponentdescriptorDescriptor
Returns
RemoveBinding(CoherenceSync, Component, string)
public static bool RemoveBinding(CoherenceSync sync, Component component, string memberName)
Parameters
syncCoherenceSynccomponentComponentmemberNamestring
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
gameObjectGameObjectmemberNamestring
Returns
Type Parameters
T
RemoveBindings(CoherenceSync, Predicate<Binding>)
public static int RemoveBindings(CoherenceSync sync, Predicate<Binding> match)
Parameters
syncCoherenceSyncmatchPredicate<Binding>
Returns
RemoveInvalidBindings(CoherenceSync)
Removes all invalid Bindings from a given CoherenceSync.
public static int RemoveInvalidBindings(CoherenceSync sync)
Parameters
syncCoherenceSync
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
gameObjectGameObjectGameObject to convert into a Prefab.
prefabPathstringPath where the Prefab Asset will be written on disk.
prefabGameObjectReference to the Prefab Asset.
interactionModeInteractionModeThe 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
syncCoherenceSyncThe 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
syncis 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