Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

- Description

Throws events whenever CavrnusUsers (TODO:LINK) enter/exit the given space.

...

This is the best way to maintain a list of users in, say, a UI panel. If you just want a snapshot of the current users for, say, debugging, consider calling GetCurrentSpaceUsers.

- Sample

TODO: WRITE
Code Block
languagec#
public class SpaceUserAudioController : MonoBehaviour
{
    [SerializeField] private AudioSource audioSource;
    [SerializeField] private AudioClip joinClip;
    [SerializeField] private AudioClip exitClip;
    
    public void Start()
    {
        CavrnusFunctionLibrary.AwaitAnySpaceConnection(spaceConn => {
            spaceConn.BindSpaceUsers(UserJoined, UserExited);
        });
    }
    
    private void UserJoined(CavrnusUser user) => audioSource.PlayOneShot(joinClip);

    private void UserExited(CavrnusUser user) => audioSource.PlayOneShot(exitClip);
}