Class CoherenceSyncConfigUtils
public static class CoherenceSyncConfigUtils
- Inheritance
-
CoherenceSyncConfigUtils
Methods
AddExistingConfig(CoherenceSyncConfig)
Adds an existing CoherenceSyncConfig asset to the registry, if it's not registered already.
public static bool AddExistingConfig(CoherenceSyncConfig config)
Parameters
config
CoherenceSyncConfig
Returns
- bool
True if the Config was successfully added, false otherwise.
AddSyncedMember(Component, Descriptor)
Start syncing a given member of the given Component instance.
public static Binding AddSyncedMember(Component componentInstance, Descriptor descriptor)
Parameters
componentInstance
ComponentComponent instance from a prefab where you wish to start syncing a member.
descriptor
DescriptorDescriptor for the synced member of componentInstance that you wish to start syncing.
Returns
- Binding
Reference to the synced member Binding that was instantiated, if the operation was successful.
Remarks
ComponentInstance must already belong to a prefab hierarchy of an existing CoherenceSync Object.
AddSyncedMember(Component, string)
Start syncing a given member of the given Component instance.
public static Binding AddSyncedMember(Component componentInstance, string memberName)
Parameters
componentInstance
ComponentComponent instance from a prefab where you wish to start syncing a member.
memberName
stringName of the member from Component componentInstance that you wish to start syncing over the network. It can be a variable, property or method.
Returns
- Binding
Reference to the synced member Binding that was instantiated, if the operation was successful.
Remarks
ComponentInstance must already belong to a prefab hierarchy of an existing CoherenceSync Object.
AddSyncedMember<T>(GameObject, string)
Start syncing a given member of Component T in GameObject go.
public static Binding AddSyncedMember<T>(GameObject go, string memberName) where T : Component
Parameters
go
GameObjectPrefab reference where you wish to start syncing a member.
memberName
stringName of the member from Component T that you wish to start syncing over the network. It can be a variable, property or method.
Returns
- Binding
Reference to the synced member Binding that was instantiated, if the operation was successful.
Type Parameters
T
Remarks
If go is not a CoherenceSync Object, an entry will be created. If go doesn't have an instance of Component T, it will be added.
ChangeConfigRegistryMode(CoherenceSyncConfigRegistryMode)
Changes the Config Registry Save Mode, it will do the necessary operations to update the current mode to the new one.
public static void ChangeConfigRegistryMode(ProjectSettings.CoherenceSyncConfigRegistryMode newMode)
Parameters
newMode
ProjectSettings.CoherenceSyncConfigRegistryModeThe new Config Registry Save Mode.
CreateCoherenceSyncConfig(Object)
Create an CoherenceSync Config for the given Unity Object.
public static CoherenceSyncConfig CreateCoherenceSyncConfig(Object obj)
Parameters
obj
ObjectReference to the Unity Object that you want to create a CoherenceSync Config for.
Returns
- CoherenceSyncConfig
The created CoherenceSyncConfig, or the existing one.
Remarks
Only GameObjects with the CoherenceSync component attached are supported as CoherenceSync Objects at the moment.
DeleteAllOrphanedSyncedMembers()
Iterate through every CoherenceSync Config and clean every synced member that is no longer valid. (see IsValidSyncedMember)
public static void DeleteAllOrphanedSyncedMembers()
DeleteCoherenceSyncConfig(CoherenceSyncConfig)
Delete an existing CoherenceSync Config.
public static bool DeleteCoherenceSyncConfig(CoherenceSyncConfig entry)
Parameters
entry
CoherenceSyncConfigReference to the entry that you want to delete.
Returns
- bool
True if the Config was successfully deleted, false otherwise.
DeleteCoherenceSyncConfig(string)
Delete an existing CoherenceSync Config for a given Unity Object, if it exists.
public static bool DeleteCoherenceSyncConfig(string guid)
Parameters
guid
stringAsset GUID of the Unity Object that you want to delete the CoherenceSync Config of.
Returns
- bool
True if the Config was successfully deleted, false otherwise.
DeleteCoherenceSyncConfig(Object)
Delete an existing CoherenceSync Config for a given Unity Object, if it exists.
public static bool DeleteCoherenceSyncConfig(Object obj)
Parameters
obj
ObjectReference to the Unity Object that you want to delete the CoherenceSync Config of.
Returns
- bool
True if the Config was successfully deleted, false otherwise.
DeleteOrphanedSyncedMembersForEntry(CoherenceSyncConfig)
Clean every synced member that is no longer valid for the given config. (see IsValidSyncedMember)
public static bool DeleteOrphanedSyncedMembersForEntry(CoherenceSyncConfig config)
Parameters
config
CoherenceSyncConfig
Returns
DeleteSyncedMember(Component, Descriptor)
Stop syncing a given member of the given Component instance.
public static bool DeleteSyncedMember(Component componentInstance, Descriptor descriptor)
Parameters
componentInstance
ComponentComponent instance from a prefab where you wish to stop syncing a member.
descriptor
DescriptorDescriptor for the synced member of componentInstance that you wish to stop syncing.
Returns
- bool
Reference true if the synced member was successfully deleted, false otherwise.
Remarks
ComponentInstance must already belong to a prefab hierarchy of an existing CoherenceSync Object.
DeleteSyncedMember(Component, string)
Stop syncing a given member of the given Component instance.
public static bool DeleteSyncedMember(Component componentInstance, string memberName)
Parameters
componentInstance
ComponentComponent instance from a prefab where you wish to stop syncing a member.
memberName
stringName of the member from Component componentInstance that you wish to stop syncing over the network. It can be a variable, property or method.
Returns
- bool
Reference true if the synced member was successfully deleted, false otherwise.
Remarks
ComponentInstance must already belong to a prefab hierarchy of an existing CoherenceSync Object.
FindCoherenceSyncConfig(string)
Finds entry for a given Unity Object represented by its asset guid, if it exists
public static CoherenceSyncConfig FindCoherenceSyncConfig(string assetGuid)
Parameters
assetGuid
stringThe GUID of the Unity Object we want to get the CoherenceSync Config from.
Returns
- CoherenceSyncConfig
The CoherenceSync Config that belongs to the given Unity Object, if it exists.
Remarks
Only GameObjects with the CoherenceSync component attached are supported as CoherenceSync Objects at the moment.
FindCoherenceSyncConfig(Object)
Finds entry for a given Unity Object, if it exists
public static CoherenceSyncConfig FindCoherenceSyncConfig(Object obj)
Parameters
obj
ObjectThe Unity Object we want to get the CoherenceSync Config from.
Returns
- CoherenceSyncConfig
The CoherenceSync Config that belongs to the given Unity Object, if it exists.
Remarks
Only GameObjects with the CoherenceSync component attached are supported as CoherenceSync Objects at the moment.
GetConfigRegistry()
Get an reference to the asset that holds the list of the existing CoherenceSync configs.
public static CoherenceSyncConfigRegistry GetConfigRegistry()
Returns
- CoherenceSyncConfigRegistry
A reference to the CoherenceSyncConfigRegistry asset.
IsCoherenceSyncObject(string)
Query to know if a given Unity Object is a CoherenceSync Object.
public static bool IsCoherenceSyncObject(string assetGuid)
Parameters
assetGuid
stringThe GUID of the Unity Object.
Returns
- bool
Returns true if obj is a CoherenceSync object, false otherwise.
IsCoherenceSyncObject(Object)
Query to know if a given Unity Object is a CoherenceSync Object.
public static bool IsCoherenceSyncObject(Object obj)
Parameters
obj
ObjectThe Unity Object.
Returns
- bool
Returns true if obj is a CoherenceSync object, false otherwise.
IsValidSyncedMember(CoherenceSync, Binding, out string)
Check if an existing synced member is still valid.
public static bool IsValidSyncedMember(CoherenceSync sync, Binding binding, out string invalidReason)
Parameters
sync
CoherenceSyncThe CoherenceSync component from the CoherenceSync Object Prefab.
binding
BindingThe Binding instance that represents a synced member.
invalidReason
string
Returns
- bool
Reference true if the synced member is valid, false otherwise.
Remarks
A synced member is still valid if:
- The target MonoBehaviour instance still exists.
- The associated Descriptor for the given MonoBehaviour type still exists.
ProcessMissingConfig(CoherenceSyncConfig)
Deletes or fixes references that are no longer pointing to any Unity Object asset for the given entry.
public static void ProcessMissingConfig(CoherenceSyncConfig config)
Parameters
config
CoherenceSyncConfig
ProcessMissingConfigs()
Deletes or fixes references in all entries that are no longer pointing to any Unity Object asset.
public static void ProcessMissingConfigs()
Events
OnConfigAdded
public static event Action<CoherenceSyncConfig> OnConfigAdded
Event Type
OnConfigDeleted
public static event Action<Object, string> OnConfigDeleted
Event Type
OnObjectProviderChange
public static event Action<CoherenceSyncConfig, Type> OnObjectProviderChange
Event Type
OnSyncedMemberAdded
public static event Action<CoherenceSyncConfig, Binding> OnSyncedMemberAdded
Event Type
OnSyncedMemberDeleted
public static event Action<CoherenceSyncConfig, Binding> OnSyncedMemberDeleted