Sign In Register

How can we help you today?

Start a new topic

LogEventRequest losing the data when exit

Hi, my name is Víctor Martínez and I'm having a problem with LogEventRequest

In the following image:

I'm calling a LogEventRequest that returns me information about the player.

From this information I get the playerPercentages that gaves me the information that I want. 

The problem is that outside the call of the LogEventRequest my "playerPercentage" is losing the data so i'm being forced to call the next functions inside the LogEventRequest call.

Is there any way to solve it ? I would like to get my " playerPercentage" data during all the program execution, not only in the LogEventRequest call.

That's because you have messed the idea of async function and sync function.

In your code, where the 

//print(playerPercentages.basicPercentage); --> HERE I DONT GET THE REAL DATA

 is running before LogEventRequest got the response.

So the actual execution order is :

call logEventRequest -> second print() -> logEventRequest got response, called the callback -> first print().

Check the following link out to get a better understanding of it:


    This is the function that is giving me the problems.
    On the LogEventRequest call I get into playerPercentages the value that I want ( playerPercentage.basicPercentage=95)
Outside the call, I'm printing again and I get (playerPercentage.basicPercentage=0), the real value disappears after the logeventrequest.
I had this values stored in PrivateData but I changed it to ScriptData and it still not working.

     //Function: getPrecentages
    //Updates de playerPercentage Instance
    private void getPercentages()
        List<float> percentages = new List<float>();
        string json=null;
        new LogEventRequest().SetEventKey("LOAD_PLAYER_DATA").Send((response) => {
            if (!response.HasErrors)
                GSData data = response.ScriptData.GetGSData("player_Data");
                json = percentagesData.JSON;
                playerPercentages = JsonUtility.FromJson<playerPercentages>(json);
                //print(playerPercentages.basicPercentage); --> HERE WORKS


                Debug.Log("Error Loading Player Data...");
        //print(playerPercentages.basicPercentage); --> HERE I DONT GET THE REAL DATA



Login to post a comment