Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Unity WebGL向けにjsでネイティブプラグイン書いた話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
あるど
May 28, 2021
Technology
530
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unity WebGL向けにjsでネイティブプラグイン書いた話
あるど
May 28, 2021
More Decks by あるど
See All by あるど
OSSをゆるっとやるだけでも 楽しいなって話
mizotake
2
4.4k
手軽なトラッキング技術で遊んでみた
mizotake
0
3.9k
GitHub_Actionsをセルフホストランナーで導入する
mizotake
0
4.1k
Kotlin/Native With Unity
mizotake
1
310
Unity開発でCI/CDを使おうと思った時
mizotake
0
1.2k
Other Decks in Technology
See All in Technology
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
150
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
130
オンラインゲームのシステム全体像 - コロプラ 2026年度 新卒研修
colopl
0
840
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
870
インバスケット試験対策アプリを 作って見えたAIエージェント構築 ナレッジ2選
shichijoyuhi
1
130
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
0
100
AI時代だからこそ推したい!Gitコマンド再入門
munakata
0
150
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
310
AI時代のAPI開発を加速する品質ガードレール / API Quality Guardrails in the AI Era
yokawasa
0
160
[2026 Oracle Technical Deep Dive] Apache Iceberg × Oracle AI Database -Oracle Autonomous AI Lakehouseが実現するAI時代のデータ基盤- (2026年9月17日開催)
oracle4engineer
PRO
0
120
全人類(ほぼ)AWS Organizations の上でAWSを利用している、その世界を知る話
htan
0
120
予測不能な実行エージェントを安全にサクッと試せるサンドボックス環境の話
sansantech
PRO
0
130
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
What's in a price? How to price your products and services
michaelherold
247
13k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
490
Designing for Timeless Needs
cassininazir
1
520
Everyday Curiosity
cassininazir
0
350
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
520
A better future with KSS
kneath
240
18k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
400
Transcript
Unity WebGL向けにjsで ネイティブプラグイン書いた話
UnityでWeb周り触ったこと ないので触ってみたい
ネタで作ったサイト
PartyParrotVRM
PartyParrot
そのVRM版
PartyParrotVRM
というgifが作れるサイト
どうやって作ったか
要素 - gifダウンロード - 顔のトラッキング - VRM読み込み
要素 - gifダウンロード - UnityのWebGLビルドでgif撮影/保存する - 顔のトラッキング - tensorflow facemesh
(当時) → mediapipe facemesh (現行) - VRM読み込み - UnityのWebGLで作ったサイトにドラッグ&ドロップでVRMを出現させる
要素 - gifダウンロード - UnityのWebGLビルドでgif撮影/保存する - 顔のトラッキング - tensorflow facemesh
(当時) → mediapipe facemesh (現行) - VRM読み込み - UnityのWebGLで作ったサイトにドラッグ&ドロップでVRMを出現させる
WebGL対応ライブラリ探すのが めんどくさかったのでjs書いてました
顔のトラッキング
基本画面が目に毒
顔のトラッキング - tensorflow/tfjs-models (一部アーカイブされてmediapipeへ移行) - サンプルコードを少し書くだけで簡単に顔のパーツ取得可能 - VRMへの適応はVRMBlendShapeProxyを使用
https://github.com/tensorflow/tfjs-models/blob/master/facemesh/mesh_map.jpg
顔のトラッキング - 画像を拡大すると顔パーツごとに配列のindexが確認できる - 顔パーツの配列で位置などが返ってくる - 顔パーツの位置はわかるので一定距離近づいたら瞬きなどをVRMへ適応
簡易的なトラッキングでも 案外それっぽく見える
jsネイティブプラグインとの やりとりで気づいたこと
ネイティブプラグインとのやり取り - jsの関数を定義、必要な引数を用意する - C#側で呼び出したい関数の定義、引数とかをネイティブとそろえる - ネイティブからコールバックなどをSendMessageで受け取る - GameObject名や関数を指定する必要がある -
引数に入れて設定しても良いが引数が多くなって増減がめんどくさい
ネイティブプラグインとのやり取り - jsの関数を定義、引数を文字列のみにする - C#側で呼び出したい関数の定義、引数を文字列のみにする - C#で呼び出す際、渡したいパラメーターをjsonにして関数に渡す - js側でjsonをparseして取り扱う(SendMessageの時も同様) -
引数が増減しても受け取る関数を変えなくてよくなる - 言語の違いによるデータ型を合わせる意識が必要ない
ネイティブプラグイン書く時の 選択肢として結構よさそう
まとめ - 基本画面は落ち着いた画面にしておけばよかった - ネタもの作るだけでも学びが案外ある - 簡易トラッキングでも案外それっぽくなって楽しい - ネイティブプラグインのやり取りをjsonでやるのよさそう