Adopt
method in Coherence.Toolkit.CoherenceSync
Methods
public bool Adopt()
Requests authority over an orphaned entity.
Returns
| Type | Description |
|---|---|
| bool |
Remarks
This method is similar to Coherence.Toolkit.CoherenceSync.RequestAuthority(Coherence.AuthorityType), but is used for entities that are orphaned.
Adoption requests require IsOrphaned to be true.
A request being processed doesn't guarantee that the transfer succeeds.
Requires a valid CoherenceBridge instance to process the transfer request.
Examples
using UnityEngine;
using Coherence.Toolkit;
public class Example : MonoBehaviour
{
public CoherenceSync sync;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
TryToAdopt();
}
}
private void TryToAdopt()
{
if (!sync.EntityState.IsOrphaned)
{
Debug.LogWarning("Can't adopt an entity that is not orphaned.");
return;
}
if (sync.Adopt())
{
Debug.Log("Adoption requested");
}
else
{
Debug.LogWarning("Adoption request failed");
}
}
}
See Also
RequestAuthority(AuthorityType)