BindGlobalPolicy (Unity)

- Declaration

public static IDisposable BindGlobalPolicy(string policy, Action<bool> onValueChanged)

- Description

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

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.

BindGlobalPolicy resolves by only looking at the Organization Role. It will search for any Policies in that role 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 inside a space, use BindSpacePolicy.

- 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); } }