A player profile contains information on a user account that's unrelated to their performance on a leaderboard. If no PlayerId is passed, the current user is returned.
GalaxyClientAPI.GetPlayerProfile(new GalaxySDK.ClientModels.GetPlayerProfileRequest { }, result => {
var clan = result.Clan; //Clan object, if the player is in one
var playerProfile = result.PlayerProfile; //PlayerProfile result
var notifications = result.Notifications; //# of unread messages in clan
}, error => { });
window.galaxy.ClientAPI.GetPlayerProfile((result, error) => {
var clan = result.clan; //Clan object, if the player is in one
var playerId = result.player_profile; //PlayerProfile result
var notifications = result.notifications; //# of unread messages in clan
});
GalaxySDK.shared.getPlayerProfile(playerId: "string or nil") { profile in
let playerProfile: PlayerProfile = profile
}
Galaxy_GetPlayerProfile(player_id?, function(response) {
show_message_async(response.notifications) //Show # of notifications
})
Player Profile Objects
GetPlayerProfileResponse
/// Details for the clan this user is a part of.
public Clan Clan;
/// The profile of the player. This profile is not guaranteed to be up-to-date. For a new player, this profile will not
/// exist.
public PlayerProfileModel PlayerProfile;
/// If the user has notifications, like unread messages in a clan
public int Notifications;
Use the following functions to get and display avatars. If you don't pass a PlayerID, the current player's avatar will be returned.
GalaxyClientAPI.Controller.GetPlayerAvatarTexture((imageTexture) => {
//Example use for imageTexture
avatarImage.sprite = Sprite.Create(
imageTexture,
new Rect(0.0f, 0.0f, imageTexture.width, imageTexture.height),
Vector2.one * 0.5f);
}, PlayerId); //PlayerId is optional
var imageUrl = "https://api.galaxysdk.com/api/v1/users/{galaxy player id}/avatar.png"
GalaxySDK.shared.getPlayerAvatarTexture { image in
let avatarImage: UIImage = image
}
Galaxy_GetPlayerAvatarTexture(player_id?)
Edit the player's nickname (username). This will have no effect if the user has set their username themselves.
GalaxyClientAPI.UpdatePlayerProfile(new GalaxySDK.ClientModels.UpdatePlayerProfileRequest {
Nickname = "NewUsername"
}, result => {
var playerId = result.PlayerProfile; //PlayerProfile result
}, error => { });
window.galaxy.ClientAPI.UpdatePlayerProfile({
nickname: 'NewNickname',
}, (result, error) => {
var clan = result.Clan; //Clan object, if the player is in one
var playerId = result.PlayerProfile; //PlayerProfile result
var notifications = result.Notifications; //# of unread messages in clan
});
GalaxySDK.shared.updatePlayerProfile(nickname: "new nickname") { success in
if(success){
print("Success!")
} else{
print("Error")
}
}
Galaxy_UpdatePlayerProfile(new_nickname)
This is only available in the Unity SDK for now. Either set Texture or ImageBytes. ImageBytes will take priority over Texture if they are both provided.
This endpoint will return a 400 error if you have not added Custom Avatar Images to your plan
GalaxyClientAPI.SetCustomAvatar(new GalaxySDK.ClientModels.SetCustomAvatarRequest {
//Set one or the other
Texture = imageTexture, //imageTexture is of type Texture2D
ImageBytes = byteArray //byteArray is of type byte[]
}, result => { }, error => { });
Directly open a player's profile. If no PlayerId is passed, the current user is shown.
//Show this player's profile
GalaxyClientAPI.Controller.OpenProfile();
//Show another player's profile
GalaxyClientAPI.Controller.OpenProfile(PlayerId: "player_id", Options: ViewOptions);
window.galaxy.ShowProfile({player_id: "player_id"}); //player_id is optional
GalaxySDK.shared.showProfile(playerId: nil)
Galaxy_ShowProfile(player_id?) //player_id is optional
You can easily show the avatar editor by calling:
//Full screen with close button
GalaxyClientAPI.Controller.OpenAvatarEditor();
window.galaxy.ShowAvatarEditor();
GalaxySDK.shared.showAvatarEditor()
Galaxy_ShowAvatarEditor()
Assign the infoDidChange(GalaxySDK.ClientModels.PlayerProfileModel playerProfile) delegate to listen for info updates.