Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by manolhsplaths46 · Oct 24, 2018 at 09:58 PM · unity3d

How to check if display name exists?

Using unity ,

So how can i check if display name exists?

What i am looking for is the first time the user signs enter his displayname but the next time the user tries to log in i want to say


Hey

if(Displayname == exists ){

then go to next page

}else{

let's add your DisplayName

}

my code so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine.UI;
using System;

public class PlayFabAccount : MonoBehaviour {

    public InputField inputPlayerName;
    public GameObject accountPanel;

    public void UpdatePlayerName()
    {
        // Hole Text aus dem InputFeld
        string text = inputPlayerName.text;

        // Wenn das Textfeld nicht leer ist, dann Spielernamen aktualisieren
        if (text != null)
        {
            // Request erstellen
            var request = new UpdateUserTitleDisplayNameRequest();
            request.DisplayName = text.ToString();
            // API Anfrage
            PlayFabClientAPI.UpdateUserTitleDisplayName(request, OnPlayerNameResult, OnPlayFabError);

        }
    }

    public void ChangePanel()
    {
        if (accountPanel.activeSelf)
        {
            accountPanel.SetActive(false);
        }
        else
        {
            accountPanel.SetActive(true);

        }

    }


    private void OnPlayFabError(PlayFabError obj)
    {
        print("Error: " + obj.Error);
    }

    private void OnPlayerNameResult(UpdateUserTitleDisplayNameResult obj)
    {
        print("Spielername wurde aktualsiert: " + obj.DisplayName);
    }
}
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Jay Zuo · Oct 25, 2018 at 02:49 AM

Once the user has logged in, you can use GetPlayerProfile to retrieve the DisplayName. And if it's null or empty, then the display name is not set, you will need to update player name. For example:

PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest { ProfileConstraints = new PlayerProfileViewConstraints { ShowDisplayName = true } },
    result =>
    {
        if (string.IsNullOrEmpty(result.PlayerProfile.DisplayName))
        {
            UpdatePlayerName();
        }
        else
        {
            //go to next page
        }
    },
    error => { Debug.LogError(error.GenerateErrorReport()); });
Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image manolhsplaths46 · Oct 25, 2018 at 12:36 PM 0
Share

i fixed in a different way i made it so that when someone register he had to register the username as well.

avatar image

Answer by Nisan Bahar · Oct 16, 2019 at 11:58 AM

@manolhsplaths46 This still may not solve your issue since the user can just close the application before submitting the username, and then opening it again, leading the username to be null.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    Setting up Playfab + Photon on Unity... which SDKs do I need? 1 Answer

    SDK for Unity 2017.4 LTS (probably 2018 too) has no Editor asmdef. Fails to build standalone. 2 Answers

    i want to save obj or mesh database in unity 2 Answers

    Collect data for multiple users 1 Answer

    Realtime multiplayer with private and public matches?,Multiplayer game with friends or random players 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges