Search Unity

Pressing of keys does not work on vk.com app (vk - it is like facebook)

Discussion in 'Web' started by 8Observer8, Aug 25, 2015.

  1. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    Hello,

    I built the Snake Game from this tutorial in WebGL --> link. It works correctly.

    But when I create application for vk.com like this than the input does not work --> link

    But If you will press W and will click on scene when the game is loading it sometimes works.
     
  2. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    Please, test it. If you in during loading of game will press W and will click on scene it will be working.
     
    Last edited: Aug 25, 2015
  3. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    I can't test it because I don't have a VK account, but, probably this is a known issue, where the WebGL content will not focus the iframe when clicked on it correctly. This will be fixed in an upcoming release (I believe 5.2), but it is also possible to work around it by calling: Application.ExternalCall("window.focus();"); to force the iframe to be focused.
     
  4. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    Thank you! A added in my code:

    Code (CSharp):
    1.     void Awake ()
    2.     {
    3.         // Focus on the Frame
    4.         Application.ExternalCall("window.focus();");
    5.  
    6.         collisionState = GetComponent<CollisionState>();
    7.         animator = GetComponent<Animator>();
    8.         inputState = GetComponent<InputState>();
    9.     }
    But focus on iFrame doesn't set. I will use Web Player and I will wait 5.2.
     
  5. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Oh, sorry - it should be ExternalEval, not ExternalCall.
     
  6. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I replaced ExternalCall on ExternalEval but focus doesn't set on iFrame for WebGL again.

    I see in documentation that ExternalEval is for Web Player only.

    You can test another problems. It is direct links on my apps (not VK)
    Super Mario 2D (Web Player)
    Super Mario 2D (WebGL)

    I set Fastest (very slow builds) option for WebGL. You can see problems with freezing and sounds. Is it because WebGL in Unity is in Preview version?
     
    Last edited: Aug 27, 2015
  7. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    When I add ExternalEval to WebGL apps I receive this message:
    I save the console information in the log file.

    Now you can test my apps above.
     

    Attached Files:

    • log.txt
      File size:
      3.3 KB
      Views:
      915
    Last edited: Aug 27, 2015
  8. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Application.ExternalEval is actually supported on WebGL. We just need to update the docs.

    The audio is indeed a bit strange... could you please submit a bug report ?
     
  9. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I submited a bug report about Application.ExternalEval (in documentation) and about audio bug in WebGL.
     
  10. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    thanks!
     
  11. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    The problem with keyboard focus (in iFrame) was solved in 5.2. Thank you very much!

    But the game is freezing a little if you will compare with WebPlayer version. I see that the game looks better in WebPlayer. I hope it will be solved it next versions of Unity WebGL:
     
  12. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    what do you mean by "freezing" ?
     
  13. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    99
    I mean that the objects are moving more smoothly in WebPlayer