Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How can I make an embed code that looks exactly like on play.unity

Discussion in 'WebGL' started by NickoG, Apr 22, 2021.

  1. NickoG

    NickoG

    Joined:
    Apr 19, 2015
    Posts:
    8
    It seems like I can't choose the dimensions of the embed code because of this part
    <div class="game-wrapper_3FW7WRHI" style="height:580px">
    That is instantiated with the embed code. I try to access it in css.
     
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    "game-wrapper_3FW7WRHI" does not look like a div that the Unity WebGL export would generate. Are you uploading the content to some hosting service, maybe that is generating the div?
     
  3. NickoG

    NickoG

    Joined:
    Apr 19, 2015
    Posts:
    8
    The game is uploaded on play.unity3duserconent and I use the iframe to embed it on my site.
    That is one of the divs that get their style from this css
    https://play-static.unity.com/public/assets/Webgl/commons.153d7cf89c73b80f3fb4.css
    Not sure if that came with my game or if I can edit it.
    I should be able to solve this since, if I untick some of the styling in the browser console, the embed looks fine.
    But my css can't find it, so it must be a load order thing?
     
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    I am not sure if Unity Play supports third party embedding of Unity content. I'll forward this question to the Play team, and see what they think.
     
  5. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Talking with the Play team, they mentioned that there is a Shared -> Embed option that can be used, and the width & height should be configurable there. See the attached image.

    The also offered the following embedding code that does not have the use of the game-wrapper field:

    Code (JavaScript):
    1. <iframe id='webgl_iframe' frameborder="0" allow="autoplay; fullscreen; vr" allowfullscreen="" allowvr=""
    2.     mozallowfullscreen="true" src="https://play.unity3dusercontent.com/webgl/8629cd43-bea1-4abc-85c6-35ab00254adc?screenshot=false&embedType=embed"  width="810"
    3.     height="640" onmousewheel="" webkitallowfullscreen="true"></iframe>
    Hopefully that helps!
     

    Attached Files: