Community

  • Appnext and Unity (Facebook game) posted

    Hi

    I'm trying to integrate app next into my unity game, to be available on facebook. The game is using the Facebook SDK, soI have to use Inject in order to modify things around the canvas. I use the provided code to display an express bar. My code looks like this:

    Application.ExternalEval ("<iframe id="top_banner" src="//admin.appnext.com/htmlBar/index.html?id=707cd452-f8e0-483a-88c7-816fc5e814b8" align="center" width="760" height="72" marginwidth="0" marginheight="O" hspace="0" vspace="0" style="border:solid 1px;border-radius: 1opx" scrolling="no"></iframe>");

    I get an error: CS1525 Unexpected symbol 'top_banner'.

    Does anyone know how to fix this?

    Reply
  • Hi,
    So sorry for the late reply, I fixed a few things in your code, can you try using this:
    Application.ExternalEval ("<iframe id='top_banner' src='//admin.appnext.com/htmlBar/index.html?id=707cd452-f8e0-483a-88c7-816fc5e814b8' align='center' width='760' height='72' marginwidth='0' marginheight='0' hspace='0' vspace='0' style='border:solid 1px;border-radius:10px' scrolling='no'></iframe>");

    Please let me know if it solves your issue.
    Best regards,
    Vardit.

  • I've just done the same thing. However, I gave myself a bit more control by creating my injection as a link (as shown below) to the same site that hosts my game (Parse.com) and then injecting an iFrame to that page. That way, I can edit the content of my web page without the need to rebuild and upload a new version of the app. Obviously this will only work if you can create a page on the same host that's hosting the game (like Parse.com) and it MUST be https://

    using UnityEngine;
    using System.Collections;
    
    public class WebInjection:MonoBehaviour {
    
        void Start() {
            string injection =
                "ifrm = document.createElement('IFRAME');" +
                "ifrm.setAttribute('src', 'https://<domain/page>');" +
                "ifrm.style.width = '100%';" +
                "ifrm.style.height = '200px';" +
                "document.body.appendChild(ifrm);";
            Application.ExternalEval(injection);
        }
    }
    Reply
Loading ...