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(newGalaxySDK.ClientModels.GetPlayerProfileRequest { }, result => { var clan =result.Clan; //Clan object, if the player is in onevar playerProfile =result.PlayerProfile; //PlayerProfile resultvar 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 onevar playerId =result.player_profile; //PlayerProfile resultvar notifications =result.notifications; //# of unread messages in clan});
GalaxySDK.shared.getPlayerProfile(playerId:"string or nil") { profile inlet 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.publicClan 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.publicPlayerProfileModel PlayerProfile;/// If the user has notifications, like unread messages in a clanpublicint 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 imageTextureavatarImage.sprite=Sprite.Create( imageTexture,newRect(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"
Edit the player's nickname (username). This will have no effect if the user has set their username themselves.
GalaxyClientAPI.UpdatePlayerProfile(newGalaxySDK.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 onevar playerId =result.PlayerProfile; //PlayerProfile resultvar notifications =result.Notifications; //# of unread messages in clan});
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(newGalaxySDK.ClientModels.SetCustomAvatarRequest { //Set one or the other Texture = imageTexture,//imageTexture is of type Texture2D ImageBytes = byteArray //byteArray is of type byte[]}, result => { }, error => { });
✨ Show profile
Directly open a player's profile. If no PlayerId is passed, the current user is shown.
//Show this player's profileGalaxyClientAPI.Controller.OpenProfile();//Show another player's profileGalaxyClientAPI.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
✨ Show editor
You can easily show the avatar editor by calling:
//Full screen with close buttonGalaxyClientAPI.Controller.OpenAvatarEditor();
window.galaxy.ShowAvatarEditor();
GalaxySDK.shared.showAvatarEditor()
Galaxy_ShowAvatarEditor()
↕️Profile Delegate
Assign the infoDidChange(GalaxySDK.ClientModels.PlayerProfileModel playerProfile) delegate to listen for info updates.