Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity + Playtomic interaction

Discussion in 'Project Tiny' started by Maras, Jan 29, 2020.

  1. Maras

    Maras

    Joined:
    Dec 11, 2012
    Posts:
    131
    I am having some trouble with Unity + Playtomic browser interaction. If I have this script attached to the webpage and call it from Unity via js lib, it does not call the save function properly (no response). If I call the function via console/outside of unity, it does. The context is the same in both cases (window)

    Code (CSharp):
    1. var testFunction = function() {
    2.   console.log(this);
    3.  
    4.   console.log(ID.GameAPI.Leaderboards.save);
    5.   ID.GameAPI.Leaderboards.save(
    6.             {
    7.                 table: "Leaderboard",
    8.                 points: 2
    9.             },
    10.             (response)=> {console.log(response)});
    11. }
    Any ideas what might cause that? I noticed the game canvas is blocking some event propagation, but other than that it seemed that it should work the same way.

    Thanks!
     
  2. Maras

    Maras

    Joined:
    Dec 11, 2012
    Posts:
    131
    It seems that the issue is that the leaderboard (iframe overlay) is loaded during OnUpdate and the browser is canceling that request. Perhaps since it is considered no longer needed?

    It works correctly if I load the leaderboard OnStartRunning.

    What would be the correct approach to do something like this when I apparently can't trigger this action from OnUpdate?
     
  3. Maras

    Maras

    Joined:
    Dec 11, 2012
    Posts:
    131
    The issue is somewhere else, it works only during OnStartRunning while the game is initializing. (not from a custom system which I enable manually)