Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Unresponsive buttons + general game slowdown

Discussion in 'Project Tiny' started by leeham9, Feb 2, 2019.

  1. leeham9

    leeham9

    Joined:
    Oct 25, 2015
    Posts:
    12
    Hi all,

    So I've been struggling really hard with trying to get my Tiny Unity game to run well on Mobile devices. It runs perfectly on desktop, and it actually does run well on quite a few mobile devices (tested well on a Galaxy S9), but a client I'm working for has been reporting that the game runs really poorly. Specifically on Galaxy S5/6 and also on Safari12 on iPhone 6.

    Their main concern is that a button the player has to click is very unresponsive. I currently have it setup in a System, and on the Update loop I do this:

    Code (JavaScript):
    1.                 ut.UIControls.UIControlsService.addOnDownCallback(this.world, HitButton, function() {
    2.                         //console.log("SHOOT");
    3.                         GameManager.playerShot=true;
    4.                    });
    Basically, the button triggers a bool which sets playerShot to true. There is another bit of code that runs in a different System, which will trigger a "shot" when playerShot is true, and set it to false.

    I realize this might be a weird way of doing things, but does anyone have ideas/suggestions for what might be causing this unresponsiveness? Is Tiny Unity known to be slow on certain devices/browsers?
     
  2. abeisgreat

    abeisgreat

    Joined:
    Nov 21, 2016
    Posts:
    45
    Try moving the code you shared out of the update loop. It should only run once per entity, the fact you're attaching thousands of click handlers may be your issue.
     
  3. leeham9

    leeham9

    Joined:
    Oct 25, 2015
    Posts:
    12
    That makes sense, and when I tried creating click handlers initially, I had them running during the game's "Initialization" state but the buttons didn't work when I did it that way. They only seemed to work when I had them constantly updating. I guess I will look into using Behaviours for the buttons instead, since I at least know that I can use EntityEnable with those.

    Thanks for the help, I think you've answered my questions quite a few times on these forums. I super appreciate it!