2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UnityでMonaparty(WebGLとMpurse編)

Last updated at Posted at 2020-03-20

たいそうなタイトルですね、、、
#まずはこちらを
・公式doc
https://docs.unity3d.com/ja/current/Manual/webgl-interactingwithbrowserscripting.html

・UnityのWebGLで外部JavaScriptライブラリを使う
h ttps://qiita.com/void_vtuber/items/2aad097eac69771826fd

・モナ版MetaMask Mpurseプログラミング超入門
https://monappy.jp/memo_logs/view/Monacoin_Charts/4654

(qiitaのリンクを張るとリンク元にもこちらの記事が反映されてしまうのは恐れ多い)

#結論
・C#からJavaScriptを呼ぼうとする時にjslibファイルを作るが、そこに await/async を書くとビルドエラーになる(たぶん)
(同じような質問もあった??)→https://forum.unity.com/threads/unity-jslib-async-problem.809478/

・なのでJavaScriptからC#にメッセージを送ることに

Massageを送る.html
<head>
  <script>
      async function GetAddress()
          {
            const address = await window.mpurse.getAddress();
            gameInstance.SendMessage("MyGameObject", "MyFunction", address);   
          }
  </script>
</head>

これでやりとりが出来ました。

jslibファイルに await/async 書けるといいけども、、、

( ´∀`)<owari

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?