Search code examples
htmlfacebookunity-game-enginefacebook-unity-sdk

Unity HTML banner within Facebook's canvas


So I'm trying to put a banner below a Unity app which is hosted on Facebook. I have the following code for injecting html elements above the app in the facebook canvas, taken from https://developers.facebook.com/docs/unity/reference/current/CUI/

string injection =
  "var headerElement = document.createElement('div');" +
  "headerElement.textContent = ('Check out our other great games: ...');" +
  "var body = document.getElementsByTagName('body')[0];" +
  "var insertionPoint = body.children[0]; " +
  "body.insertBefore(headerElement, insertionPoint);";
Application.ExternalEval(injection);

How would I go about displaying these elements BELOW the facebook app?


Solution

  • Just replace the line

    "var insertionPoint = body.children[0]; "
    

    for

    "var insertionPoint = body.lastChild;"
    

    I post tricks and tutorials on my blog, check it out also for facebook sdk tutorials!

    blog.bigfootgaming.net