- Home /
EntryPointNotFoundException when trying webgl browser communication jslib example
I'm following the webgl browser communication jslib tutorial at
http://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
and get the following error.
EntryPointNotFoundException: Hello
NewBehaviourScript.Start () (at Assets/NewBehaviourScript.cs:25)
The project compiles and works even with the error. How do I get rid of the error in the editor?
Also in the example [DllImport("**Internal")] private static extern void Hello();
should be __ instead of **
I'm having exactly the same problem. If I figure it out, I'll let you know...
hi, I met the same problem as you do....did you find a solution ?
Answer by moosefetcher · Sep 20, 2016 at 02:11 PM
I had a similar problem, and I've managed to completely dodge the issue!
I'd recommend using the first option from the page you link to.
Put your javascript file(s) in a folder, relative to the final build index.html.
Use a custom WebGL html template. This involves:
Creating a folder called 'WebGLTemplates' in your 'Assets' folder.
Create a folder with the name of your template in 'Assets/WebGLTemplates'.
Put your index.html file in that folder (an example can be found on this page: https://docs.unity3d.com/Manual/webgl-templates.html )
In Unity Editor select Edit > Project Settings > Player and select your new html template from the Web GL templates available
Your new index.html template should, of course, load in your external .js file(s), eg:
<script src="js/YourExternalFile.js"></script>
You can then call those external .js functions from your C# with, for eg:
Application.ExternalCall("functionName", "placeHolderParameter");
And, even cooler, you can call functions in your Unity code (by GameObject name) from your external .js,. with, for eg:
SendMessage ('GameObjectName', 'functionName', 'placeholderParameter');
And the GameObjectName can even be the name of a string variable.
Hopefully this is useful - I realise it's been 6 months since you asked...
Yeah it's still useful and I still have that problem, plus you had a few other good ideas. Thanks.
Your method is deprecated and will no longer work in a future version of Unity.
Any solutions using the current recommended method? The problem is exactly as the OP has said: EntryPointNotFoundException: Hello
Answer by LilGames · Jul 17, 2018 at 02:05 AM
Here is the real solution to the original problem:
The error is because the js lib can only work in WebGL. You must wrap your code with the following so that it does not execute in the editor :
#if UNITY_WEBGL
Hello();
#endif
source: https://forum.unity.com/threads/webgl-return-value-from-javascript-function.486095/#post-3193717
.
Also note, in the editor, you can click on the jslib file and view some options in the Inspector. Make sure "WebGL" is checked so that it will work in WebGL.
Actually it's more common to just replace the method definition in the sense of:
#if UNITY_WEBGL
[DllImport("__Internal")] private static extern void Hello();
#else
private static void Hello()
{
// maybe some replacement code for other build targets or just an empty method
}
#endif
This does not actually execute my javascript when I run WebGL in a browser, just throws a strange error (and yes, I enabled WebGL only on the jslib inside the editor). The accepted answer above might be deprecated, but at least it works.
hi, I'm trying to call browser js function from webgl jslib and it doesn't work. I tried converting the whole browser js to jslib then calling the function but still doesn't work. There are some html elements manipulation and those doesn't work. Is there a way to call the browser js function from webgl jslib. I can use Application.ExternCall() but its deprecated. i'm using unity 2018.3.0f2