votetake/vue-unity-webgl

Calling JavaScript functions in Vue from Unity scripts

alexis-regnaud opened this issue · 3 comments

Hi,
I need to calling a function in my vue component from Unity scripts. What is the best way to do that?
Here, there is a exemple with React: https://npm.taobao.org/package/react-native-unity-webgl

If you know a solution to do the same thing in Vue ...

Thanks in advance.

anyone please?

  1. create 1 plain vanilla script's function in your public/index.html
  2. save the data that is sent from unity in js global variable under window object
    <script> function getUnityData(jsonObj) { window.jsonData = jsonObj; } </script>
  3. get the data using computed property in your vue component... or if you want to read it in interval, you can use setInterval() inside your mounted

unityData() { return window.jsonData; }

well, i hope you got the point. good luck..

I also wrote an example in #26