API
CBSProfileModule.UpdateDisplayName - Update player display name
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var newDisplayName = "My Nickname";
ProfileModule.UpdateDisplayName(newDisplayName);
}
private void OnUpdateDisplayName(CBSUpdateDisplayNameResult result)
{
if (result.IsSuccess)
{
var newName = result.DisplayName;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetAccountInfo - Get full information of current player account. Include all Playfab origin result
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.GetAccountInfo(OnGetInfo);
}
private void OnGetInfo(CBSGetAccountInfoResult result)
{
if (result.IsSuccess)
{
var displayName = result.DisplayName;
var avatarUrl = result.AvatarUrl;
var playFabResult = result.PlayFabResult;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileAccountInfo - Get full information of player account by id. Include all Playfab origin result.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileID = "Profile ID";
ProfileModule.GetProfileAccountInfo(profileID, OnGetInfo);
}
private void OnGetInfo(CBSGetAccountInfoResult result)
{
if (result.IsSuccess)
{
var displayName = result.DisplayName;
var avatarUrl = result.AvatarUrl;
var playFabResult = result.PlayFabResult;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.AddExpirienceToProfile - Adds N points of experience to the current state. In the response, you can get information whether the player has reached a new level and also information about the reward about the new level.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var expToAdd = 10;
ProfileModule.AddExpirienceToProfile(expToAdd, OnAddExp);
}
private void OnAddExp(CBSLevelDataResult result)
{
if (result.IsSuccess)
{
var levelInfo = result.LevelInfo;
var newLevel = result.IsNewLevel;
var newLevelReward = result.NewLevelReward;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileLevelDetail - Get information about current experience/level of profile
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
// get level info of current logined profile
ProfileModule.GetProfileLevelDetail(OnGetLevelInfo);
}
private void OnGetLevelInfo(CBSLevelDataResult result)
{
if (result.IsSuccess)
{
var levelInfo = result.LevelInfo;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
// get level info of profile by id
var profileID = "Some profile ID";
ProfileModule.GetProfileLevelDetail(profileID, OnGetLevelInfo);
}
private void OnGetLevelInfo(CBSLevelDataResult result)
{
if (result.IsSuccess)
{
var levelInfo = result.LevelInfo;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetLevelTable - Get an array with information about all profile levels in the game.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.GetLevelTable(OnGetLevelInfo);
}
private void OnGetLevelInfo(CBSGetLevelTableResult result)
{
if (result.IsSuccess)
{
var table = result.Table;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileDetail - Get general game information about a player, including profile ID, avatar url, display name, player level and clan information.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var detailRequest = new CBSGetProfileRequest
{
ProfileID = "some profile id",
Constraints = new CBSProfileConstraints
{
LoadAvatar = true,
LoadClan = true,
LoadLevel = true,
LoadOnlineStatus = true,
LoadProfileData = true,
LoadStatistics = true
}
};
ProfileModule.GetProfileDetail(detailRequest, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfileResult result)
{
if (result.IsSuccess)
{
var profileID = result.ProfileID;
var clanID = result.ClanID;
var displayName = result.DisplayName;
var levelInfo = result.Level;
var onlineStatus = result.OnlineStatus;
var clanEntity = result.ClanEntity;
var statistics = result.Statistics;
var profileData = result.ProfileData;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileDetailByDisplayName - Get general game information about a player by display name, including profile ID, avatar url, display name, player level and clan information.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var displayName = "profile display name";
var constraints = new CBSProfileConstraints
{
LoadAvatar = true,
LoadClan = true,
LoadLevel = true,
LoadOnlineStatus = true,
LoadProfileData = true,
LoadStatistics = true
};
ProfileModule.GetProfileDetailByDisplayName(displayName, constraints, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfileResult result)
{
if (result.IsSuccess)
{
var profileID = result.ProfileID;
var clanID = result.ClanID;
var displayName = result.DisplayName;
var levelInfo = result.Level;
var onlineStatus = result.OnlineStatus;
var clanEntity = result.ClanEntity;
var statistics = result.Statistics;
var profileData = result.ProfileData;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfilesDetails - Get general game information about group of players, including profile ID, avatar url or id, display name, player level and clan information.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var detailRequest = new CBSGetProfilesRequest
{
ProfilesIDs = new string[]
{
"ProfileID 1",
"ProfileID 2",
"ProfileID 3"
},
Constraints = new CBSProfileConstraints
{
LoadAvatar = true,
LoadClan = true,
LoadLevel = true,
LoadOnlineStatus = true,
LoadProfileData = true,
LoadStatistics = true
}
};
ProfileModule.GetProfilesDetails(detailRequest, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfilesResult result)
{
if (result.IsSuccess)
{
var profiles = result.Profiles;
foreach (var profilePair in profiles)
{
var profileID = profilePair.Key;
var clanID = profilePair.Value.ClanID;
var displayName = profilePair.Value.DisplayName;
var levelInfo = profilePair.Value.Level;
var onlineStatus = profilePair.Value.OnlineStatus;
var clanEntity = profilePair.Value.ClanEntity;
var statistics = profilePair.Value.Statistics;
var profileData = profilePair.Value.ProfileData;
}
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileData - Get the specific player data by unique key or keys.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileDataKey = "data key";
ProfileModule.GetProfileData(profileDataKey, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfileDataResult result)
{
if (result.IsSuccess)
{
var dataDictionaty = result.Data;
var profileDataValue = dataDictionaty["data key"].Value;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileDataKeys = new string[]
{
"data key 1",
"data key 2",
"data key 3",
};
ProfileModule.GetProfileData(profileDataKeys, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfileDataResult result)
{
if (result.IsSuccess)
{
var dataDictionaty = result.Data;
var profileDataValue1 = dataDictionaty["data key 1"].Value;
var profileDataValue2 = dataDictionaty["data key 2"].Value;
var profileDataValue3 = dataDictionaty["data key 3"].Value;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileDataByPlayerID - Get the custom player data by profile id
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileID = "some profile ID";
var profileDataKey = "data key 1";
ProfileModule.GetProfileDataByPlayerID(profileID, profileDataKey, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfileDataResult result)
{
if (result.IsSuccess)
{
var dataDictionaty = result.Data;
var profileDataValue1 = dataDictionaty["data key 1"].Value;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileID = "some profile ID";
var profileDataKeys = new string[]
{
"data key 1",
"data key 2",
"data key 3",
};
ProfileModule.GetProfileDataByPlayerID(profileID, profileDataKeys, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSGetProfileDataResult result)
{
if (result.IsSuccess)
{
var dataDictionaty = result.Data;
var profileDataValue1 = dataDictionaty["data key 1"].Value;
var profileDataValue2 = dataDictionaty["data key 2"].Value;
var profileDataValue3 = dataDictionaty["data key 3"].Value;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.SaveProfileData - Set/Save custom player data of current profile.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var dataKey = "some data key";
var dataValue = "some data value";
ProfileModule.SaveProfileData(dataKey, dataValue, OnGetProfileInfo);
}
private void OnGetProfileInfo(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.SaveProfileData - Set/Save custom player data of current profile.
using System.Collections.Generic;
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var dataSet = new Dictionary<string, string>();
dataSet["data1"] = "value1";
dataSet["data2"] = "value2";
dataSet["data3"] = "value3";
ProfileModule.SaveProfileData(dataSet, OnSave);
}
private void OnSave(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.UpdateAvatarUrl - Update the current player's profile photo.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var imageURL = "https://myimage.png";
ProfileModule.UpdateAvatarUrl(imageURL, OnUpdateAvatar);
}
private void OnUpdateAvatar(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.UpdateAvatarID - Update the current player avatar id.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var spriteID = "sprite1";
ProfileModule.UpdateAvatarID(spriteID, OnUpdateAvatar);
}
private void OnUpdateAvatar(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GrantAvatar - Grant an avatar if it has a price.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var spriteID = "avatar1";
ProfileModule.GrantAvatar(spriteID, OnGrantAvatar);
}
private void OnGrantAvatar(CBSGrantAvatarResult result)
{
if (result.IsSuccess)
{
var avatarID = result.GrantedAvatarID;
var updatedAvatarTable = result.UpdatedStates;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.PurchaseAvatar - Purchase an avatar if it has a price.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var spriteID = "avatar1";
ProfileModule.PurchaseAvatar(spriteID, OnPurchaseAvatar);
}
private void OnPurchaseAvatar(CBSPurchaseAvatarResult result)
{
if (result.IsSuccess)
{
var avatarID = result.PurchasedAvatarID;
var avatarPrice = result.AvatarPrice;
var updatedAvatarTable = result.UpdatedStates;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetAccountLinkedInfo - Get information abount linked accounts of profile
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.GetAccountLinkedInfo(OnGetLinkedInfo);
}
private void OnGetLinkedInfo(CBSGetAccountLinkedInfoResult result)
{
if (result.IsSuccess)
{
var facebookLinked = result.Info.FacebookLinked;
var googleLinked = result.Info.GoogleLinked;
var appleLinked = result.Info.AppleLinked;
var steamLinked = result.Info.SteamLinked;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.UpdateOnlineState - Call to update online status manually, you need to call it, then you have selected "OnlineBehavior" as "Custom" in your profile settings.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.UpdateOnlineState(OnGetLinkedInfo);
}
private void OnGetLinkedInfo(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.BanProfile - Ban the user for a while. During the ban, the player will not be able to log in.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var banRequest = new CBSBanProfileRequest
{
ProfileIDToBan = "profile id to ban",
BanHours = 12, // hours
Reason = "Some reason"
};
ProfileModule.BanProfile(banRequest, OnProfileBanned);
}
private void OnProfileBanned(CBSBanProfileResult result)
{
if (result.IsSuccess)
{
var banInfo = result.BanInfo;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.RevokeAllProfileBans - Revoke all active bans from the profile.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileID = "Profile ID to revoke";
ProfileModule.RevokeAllProfileBans(profileID, OnRevoke);
}
private void OnRevoke(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.RevokeProfileBan - Revoke individual ban using BanID for profile.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var banID = "ban ID";
ProfileModule.RevokeProfileBan(banID, OnRevoke);
}
private void OnRevoke(CBSBaseResult result)
{
if (result.IsSuccess)
{
Debug.Log("Success!");
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileBanList - Get information about all ban for profile.
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileID = "some profile ID";
ProfileModule.GetProfileBanList(profileID, OnGetBanList);
}
private void OnGetBanList(CBSBanListResult result)
{
if (result.IsSuccess)
{
var banList = result.BanList;
foreach (var ban in banList)
{
var banID = ban.BanId;
var active = ban.Active;
var expires = ban.Expires;
var created = ban.Created;
var reason = ban.Reason;
}
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileAvatarID - Get avatar id of current profile or by profile id
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.GetProfileAvatarID(OnGetAvatar);
}
private void OnGetAvatar(CBSGetProfileAvatarIDResult result)
{
if (result.IsSuccess)
{
var avatarID = result.AvatarID;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
var profileID = "some profile ID";
ProfileModule.GetProfileAvatarID(profileID, OnGetAvatar);
}
private void OnGetAvatar(CBSGetProfileAvatarIDResult result)
{
if (result.IsSuccess)
{
var avatarID = result.AvatarID;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileAvatarTable - Get all avatars available for profile
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.GetProfileAvatarTable(OnGetAvatarTable);
}
private void OnGetAvatarTable(CBSGetProfileAvatarTableResult result)
{
if (result.IsSuccess)
{
var table = result.Table;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
CBSProfileModule.GetProfileAvatarTableWithStates - Get all avatars available for profile with states (available, purchased)
using CBS;
using CBS.Models;
using UnityEngine;
public class ProfileExample : MonoBehaviour
{
private IProfile ProfileModule { get; set; }
void Start()
{
ProfileModule = CBSModule.Get<CBSProfileModule>();
ProfileModule.GetProfileAvatarTableWithStates(OnGetAvatarTable);
}
private void OnGetAvatarTable(CBSGetProfileAvatarTableWithStatesResult result)
{
if (result.IsSuccess)
{
var table = result.TableWithStates;
}
else
{
Debug.Log(result.Error.Message);
}
}
}
Last updated