Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Interger Parameter :Number type expected, but not found

Discussion in 'Unity Analytics' started by BigGameCompany, Mar 11, 2024.

  1. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    112
    so here is my code:

    public void TotalMatchesPlayedEvent()
    {
    int matchesPlayed = profileManager.matchesPlayed;
    Debug.Log("Total Matches played event: " + profileManager.matchesPlayed);
    // Define Custom Parameters
    Dictionary<string, object> parameters = new Dictionary<string, object>()
    {
    { "totalMatchesPlayed", "totalmatchesPlyed" + matchesPlayed.ToString()}//parameter name
    };
    // The ‘levelCompleted’ event will get cached locally
    //and sent during the next scheduled upload, within 1 minute
    AnalyticsService.Instance.CustomData("MatchesTotalPlayed", parameters);//event name
    // You can call Events.Flush() to send the event immediately
    AnalyticsService.Instance.Flush();
    }

    In the Analytics dasboard the event is listed as Invalid with the error:

    Number type expected, but not found, for field - totalMatchesPlayed

    I cant work out why?

    profileManager.matchesPlayed is an int as shown below:

    public class ProfileManager : MonoBehaviour
    {

    public int matchesPlayed = 0;
    public int wins = 0;
    public int losses = 0;

    Any suggestions?
     

    Attached Files:

  2. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    515
    You add a string ("totalMatchesPlyed") to the value and concatenate the value onto it (again as a string). The system then tries to parse that string to a number, which it cannot. You should only add the matchesPlayed variable, like this:
    { "totalMatchesPlayed", matchedPlayed } // parameter name
     
  3. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    112
    Fixed...thanks heaps!