- Home /
The question is answered, right answer was accepted
Interact across browser javascipt and unity webgl
Hi all, I have a scenario where i have a website in which user registration,signup and signin processes are done.And then user clicks a button in that website and my webgl gets loaded in another tab.now i want to know the user details that he had entered in that other webpage in unity webgl loaded scene.How do I communicate.Please suggest or point me in right direction.Iam new to unity webgl. Thanks in advance. -Nsks
Answer by sandeepsmartest · May 10, 2017 at 12:52 PM
I manged to solve the issue easily by simple adding sendMessage ('MyGameObject', 'MyFunction', 'example');
in the script "unityloader.js". Also i called javascript methods from unity by simply calling Application.ExternalCall("MethosinJavaScript") ;
Thank you guys.
It 's been a long time, but can you give me more details if you can?
I do not know where to use send$$anonymous$$essage.
Answer by Deathdefy · May 01, 2017 at 05:36 PM
Calling between JavaScript code from Unity
You can use the Application.ExternalCall() and Application.ExternalEval() functions to invoke JavaScript code on the embedding web page. To call methods on GameObjects in your content from browser JavaScript, you can use the following code:
sendMessage ('MyGameObject', 'MyFunction', 'example');
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
Yeah i saw Unity docs.Is there any by chance you have unity tutorial or better explanation blogs etc??