question

cameronmunday1 avatar image
cameronmunday1 asked

Display Virtual Currency On A Text Mesh Pro Object in Unity 3D

How would i make a script that displays virtual currency on a text mesh pro object in Unity 3D

unity3d
10 |1200

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

Simon Cui avatar image
Simon Cui answered

If you want to know how to get virtual currency balance of a user, you can use GetUserInventory of client API.

If you want to know how to use “Text Mesh Pro” in Unity 3D, you may need to ask Unity Support or check Unity Documentation.

There are some general PlayFab samples that you can refer to.

10 |1200

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

maria-1 avatar image
maria-1 answered

To have my virtual currency displayed in my unity game, I used fungus flowcharts and made a custom script that called "MycurrencynamePlayFabTextUpdate.cs" that looks like the following

using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI; using Fungus; // Updates glimmers and Alignment Meter Text [CommandInfo("My Custom Commands", "Update Glimmers PlayFab Text", "Update amount of the glimmers variable to glimmersText variable")] [AddComponentMenu("")]

public class GlimmersPlayFabTextUpdate : Command { public Flowchart flowchart; //public TextMeshProUGUI glimmersText;

 public override void OnEnter()
 {
     //flowchart.GetIntegerVariable("glimmers");
     flowchart.SetIntegerVariable("glimmersValue", UserProfile.glimmers);
     Debug.Log(UserProfile.glimmers);
     flowchart.SetStringVariable("playFabGlimmersText", flowchart.GetIntegerVariable("glimmersValue").ToString());
     Continue();
 }

Then in my UserProfile.cs class I have when this:

void OnEnable(ModifyUserVirtualCurrencyResult result) { Debug.Log("Game started!"); instance.GetVirtualCurrencies(); }

 private void SignIn()
 {
     GetVirtualCurrencies();
 }
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.