Search Unity

Facebook external eval ?

Discussion in 'Scripting' started by uv, Mar 10, 2014.

  1. uv

    uv

    Joined:
    Feb 15, 2013
    Posts:
    7
    Hi, I have a unity web game which uses a external .js plugin which I source in the unity html ...But facebook uses the .unity3d file directly and I am not able to source in the .js plugin or the html file...on the facebook developer page they say...


    Injecting your own HTML/JS

    You may wish to add HTML or Javascript code around the Unity object. You can do this using Unity Web Player's DOM mutation/JS execution functions, such as Application.ExternalEval().

    Example

    Add a div element to the top of the iframe containing the game, which might contain a header for cross-promotion or related uses.

    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);

    ..I dont know how to or where to put in the code to get it work...here is what i put in the unity html file to reference the .js plugin...
    </script>
    <script type="text/javascript" src="JAVAPLUGIN.js">
    </script>

    Can you tell me how we can achieve this...reference the html and js plugin ?
    Please Help !