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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

webGL issue with Application.ExternalCall issue

Discussion in 'WebGL' started by amyHelloWorld, Jun 5, 2015.

  1. amyHelloWorld

    amyHelloWorld

    Joined:
    Jun 5, 2015
    Posts:
    3
    I am trying to communicate with the browser with webGL, using

    Code (CSharp):
    1. Application.ExternalCall
    But i get a reference issue saying that my

    Code (CSharp):
    1. ReferenceError: testCommsWebGl is not defined
    The code is embedded into the generated index file like this:
    Code (CSharp):
    1. <script type='text/javascript'>
    2.  
    3.      function testScript()
    4.  
    5.     {
    6.  
    7.         alert("test");
    8.  
    9.     }
    10.  
    11.     </script>
    In my unity code i do call another function that calls the Application.ExternalCal. So for example i call webGLComms, which calls webGLAppCalls.

    Any help appreciated
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Are you missing some code there? It should be executed as:

    Code (csharp):
    1.  
    2. Application.ExternalCall("testScript");
    3.  
    That should execute the testScript function.
     
  3. amyHelloWorld

    amyHelloWorld

    Joined:
    Jun 5, 2015
    Posts:
    3
    The Application.ExternalCall was just an example, :)
     
  4. jimjim

    jimjim

    Joined:
    Nov 11, 2009
    Posts:
    127
    I made a direct call in unity Application.ExternalCall and it worked. not sure why a direct call to the function worked though