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

Running game inside a DIV

Discussion in 'Project Tiny' started by KeirREA, Jan 17, 2019.

  1. KeirREA

    KeirREA

    Joined:
    May 1, 2015
    Posts:
    7
    I want to place a game canvas inside a DIV so it can be positioned within a web page and made somewhat responsive for desktop/mobile.

    Seems like supplying your own UT_CANVAS might be a way to go, but it doesn't work. The size is overwritten regardless of its position/parent, so the game ends up displaying fullscreen anyway. Hacking the code somewhat further I can get it to drawn within the DIV, but the scale is wrong.

    I guess running inside an iFrame might work, but it would be nice to avoid that if possible.

    Anyone got a way to achieve this without hacking the runtime code too much?
     
  2. KeirREA

    KeirREA

    Joined:
    May 1, 2015
    Posts:
    7
    In case anyone else is interested, hacking the code inside
    Code (JavaScript):
    1. html.onDisplayUpdated
    and
    Code (JavaScript):
    1. html.setCanvasSize
    can more or less achieve what I want, but I'd love to hear if there's a cleaner way.