/
BindJoinableSpaces (Unity)
BindJoinableSpaces (Unity)
- Declaration
public static IDisposable BindJoinableSpaces(Action<CavrnusSpaceInfo> spaceAdded, Action<CavrnusSpaceInfo> spaceUpdated, Action<CavrnusSpaceInfo> spaceRemoved)
- Description
Triggers when joinable spaces become available, or when their metadata changes.
When called, you will immediately get spaceAdded
events for all spaces currently in your list.
- Sample
using CavrnusSdk.API;
using System.Collections.Generic;
using UnityEngine;
public class BindJoinableSpaces : MonoBehaviour
{
public SpaceOptionUI SpaceUiPrefab;
public Transform SpacesListParent;
private Dictionary<CavrnusSpaceInfo, SpaceOptionUI> instantiatedSpaceOptions = new Dictionary<CavrnusSpaceInfo, SpaceOptionUI>();
void Start()
{
CavrnusFunctionLibrary.BindJoinableSpaces(space => SpaceAdded(space),
space => SpaceUpdated(space),
space => SpaceRemoved(space));
}
private void SpaceAdded(CavrnusSpaceInfo space)
{
var spaceOption = GameObject.Instantiate(SpaceUiPrefab, SpacesListParent);
spaceOption.Setup(space);
}
private void SpaceUpdated(CavrnusSpaceInfo space)
{
var oldSpaceOption = instantiatedSpaceOptions[space];
GameObject.Destroy(oldSpaceOption);
var spaceOption = GameObject.Instantiate(SpaceUiPrefab, SpacesListParent);
spaceOption.Setup(space);
}
private void SpaceRemoved(CavrnusSpaceInfo space)
{
var oldSpaceOption = instantiatedSpaceOptions[space];
GameObject.Destroy(oldSpaceOption);
}
}
, multiple selections available,
Related content
BindJoinableSpaces (.NET)
BindJoinableSpaces (.NET)
More like this
BindJoinableSpaces (Unreal Engine)
BindJoinableSpaces (Unreal Engine)
More like this
bindJoinableSpaces (Javascript)
bindJoinableSpaces (Javascript)
More like this
FetchJoinableSpaces (Unity)
FetchJoinableSpaces (Unity)
More like this
AwaitAnySpaceBeginLoading (Unity)
AwaitAnySpaceBeginLoading (Unity)
More like this
JoinSpaceWithOptions (Unity)
JoinSpaceWithOptions (Unity)
More like this