Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var unityWrapper = new UnityWrapper();
  2.  
  3. function UnityWrapper()
  4. {
  5.     console.log(`UnityWrapper created`);
  6.     this.gameInitialised = false;
  7.     this.gameConfig = null;
  8.  
  9.     var apiSystem = new ApiSystemOnPenpal();
  10.     apiSystem.setDefaultGameState(new CommonGameState())
  11.     .setOnInitCallBack(this.Start)
  12.     .sendReady();
  13. }
  14.  
  15. UnityWrapper.prototype.Start = function(data)
  16. {
  17.     console.log(`GameData received`);
  18.     console.log(`parent iframe data `, data);
  19.     console.log(data.params.params.someName);
  20.     this.gameConfig = data;
  21.     unityInstance.SendMessage("VimBoxAPI", "TestFunction", data.params.params.someName);
  22. };
  23.  
  24. UnityWrapper.prototype.CallJSReady = function()
  25. {
  26.     console.log(`Unity Game JS Call`);
  27.     this.gameInitialised = true;
  28.     SendConfig();
  29. };
  30.  
  31. UnityWrapper.prototype.SendDataToGame = function()
  32. {
  33.     console.log(this.gameInitialised);
  34.     console.log(this.gameConfig);
  35.     if (this.gameInitialised && this.gameConfig != null)
  36.     unityInstance.SendMessage("VimBoxAPI", "TestFunction", this.gameConfig.params.params.someName);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement