question

goatlil79 avatar image
goatlil79 asked

How Do I Display Ban Reason And Time Left Using Unity Text Mesh Pro

I Need A C# Script For Unity That I Can Use Text Mesh Pro To Display Ban Reason And Hours Left Of Ban.

sdks
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

If the Text Mesh Pro you mean the “Text -TextMeshPro” component under the Unity Editor UI section, here is the code example you can refer to:

 //TextMeshPro text component, set the value in the Unity Editor
     public TMP_Text text;
    
     void Login()
     {
         PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest
         {
             CustomId = "test"
    
         }, re =>
         {
             Debug.Log("Login Success!");
         }, er =>
         {
             if (er.Error == PlayFabErrorCode.AccountBanned)
             {
                 foreach (var item in er.ErrorDetails)
                 {
                     Debug.Log("Reason : " + item.Key + "\t" + "Expires : " + item.Value[0]);
    
                     //use TextMeshPro text component to display text
                     text.text += item.Value[0].ToString();
                 }
             }
             Debug.Log(er.GenerateErrorReport());
         });
     }

Please remember to check Allow client to view ban reason and duration in Game Manager-> Title settings-> API Features.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.