How would i make a script that displays 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
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.
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();
}
21 People are following this question.