BindSpacePolicy (Unity)

- Declaration

public static IDisposable BindSpacePolicy(this CavrnusSpaceConnection conn, string policy, Action<bool> onValueChanged)

- Description

Binds an event to throw when a policy is/isn't allowed for the user in a given space.

Important: Cavrnus user accounts will always have an Organization Role which will apply to them as soon as they authenticate. They will also have a Space Role for each space they are able to join. The Organization Role generally governs things like creating spaces and uploading objects. The Space Role generally governs the ability to make updates/modifications to the space in question. All Roles and Policies are controlled via the Management Console.

BindSpacePolicy resolves by looking at the Organization Role and the Space Role. It will search for any Policies in those roles which apply to the passed-in policy parameter. If all Policies resolve to allow it then onValueChanged will return true. Otherwise it will return false.

If you wish to resolve a Policy based on the user’s role outside of any particular space space, use BindGlobalPolicy.

- Sample

using CavrnusSdk.API; using UnityEngine.UI; using UnityEngine; public class LimitCreateSpaceByOrgRole : MonoBehaviour { public Button CreatSpaceButton; void Start() { CavrnusFunctionLibrary.BindGlobalPolicy("canCreateSpaces", allowed => ButtonPermissionsChanged(allowed)); } public void ButtonPermissionsChanged(bool allowed) { CreatSpaceButton.gameObject.SetActive(allowed); } }