Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
4画面出力とレシート印刷で作る体験型デジタルサイネージ / Unity signage
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
KSK
September 26, 2018
Programming
3.2k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
4画面出力とレシート印刷で作る体験型デジタルサイネージ / Unity signage
KSK
September 26, 2018
More Decks by KSK
See All by KSK
Supernova Studio 使いはじめてみたら割と良さそう / supernova_studio
ksk1030m
1
900
CSV出力 - Viewからやるか? 他からやるか? / How to output CSV
ksk1030m
1
670
実録リファラル採用-僕と副社長の1827日- / my referral
ksk1030m
0
1.2k
GitLabを仕事で使っていた私が思うことをつらつらと / about GitLab
ksk1030m
1
1.1k
エンジニア目線で考えるPR戦略 / PR by Engineer
ksk1030m
1
1.5k
Metabase ライブ環境構築 / metabase_live_coding
ksk1030m
0
370
昔の自分に伝えたい容量回復のためのDockerの仕組み / docker_tips
ksk1030m
1
580
Capistranoの罠と他人がハマった事例を見て思うこと / capistrano-trap
ksk1030m
0
350
ガチャを巡る闘い / War of Gacha
ksk1030m
0
130
Other Decks in Programming
See All in Programming
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.8k
The NotImplementedError Problem in Ruby
koic
1
1.1k
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
AIエージェントで 変わるAndroid開発環境
takahirom
1
240
1B+ /day規模のログを管理する技術
broadleaf
0
120
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
230
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
0
260
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
110
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
290
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
130
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
Vite+ Unified Toolchain for the Web
naokihaba
0
420
Featured
See All Featured
KATA
mclloyd
PRO
35
15k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
760
Skip the Path - Find Your Career Trail
mkilby
1
160
Facilitating Awesome Meetings
lara
57
7k
Side Projects
sachag
455
43k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
460
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
250
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
How to Talk to Developers About Accessibility
jct
2
280
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
220
Transcript
4画面出力とレシート印刷で作る 体験型デジタルサイネージ @ksk1030 Gotanda.unity #8 / 2018.09.26
話します ・どんな物を作ったか ・機能の話ざっくり 話しません ・ハードウェア側の細かい設定の話
どんな物を作ったか?
None
作ったもの
作ったもの 北海道大学博物館内のサイネージ ・クイズゲームで色々学ぼう的な Windows10 上で動作 ・マルチディスプレイ(4画面) ・レシート印刷(施設内で使えるクーポン発行) ・Flicker API(インスタは審査落ちた...) ・csvファイルでのデータ更新
マルチディスプレイ ② ②’ ① ③ プロジェクタ x 3 + 手元のタッチパネル
真ん中とタッチパネルは同じ画面を表示 しているので、実質3つのカメラを用意
マルチディスプレイ using UnityEngine; public class MultiDisplayManager : SingletonMonoBehaviour<MultiDisplayManager> { void
Start() { int maxDisplayCount = 3; #if SINGLE_DISPLAY maxDisplayCount = 1; #endif for (int i = 0; i < maxDisplayCount && i < Display.displays.Length; i++) { Display.displays[i].Activate(); } } }
マルチディスプレイ using UnityEngine; public class MultiDisplayManager : SingletonMonoBehaviour<MultiDisplayManager> { void
Start() { int maxDisplayCount = 3; #if SINGLE_DISPLAY maxDisplayCount = 1; #endif for (int i = 0; i < maxDisplayCount && i < Display.displays.Length; i++) { Display.displays[i].Activate(); } } } Display.displays に接続中のディスプレイが 格納されている Length で取得した台数分 Activate() する (手元で確認するときに1画面出力できる よう環境変数 SINGLE_DISPLAY を用意) 公式:https://docs.unity3d.com/ja/current/Manual/MultiDisplay.html
実装はこれで良いのだが、やってみると... ディスプレイごとの設定でハマる ・リフレッシュレート ・アスペクト比 ・Unity上の Index と OS上の番号が一致しない - PCに物理的に接続した順で判定されている?
- https://gist.github.com/keijiro/a898b77fa06ee7c83cffc263419b32e3 - 詳細情報求ム... マルチディスプレイ
専用のプリンタを設置 クイズで一定以上のスコアを達成すると 博物館内のカフェで使えるクーポン発行 レシート印刷 EPSON TM-m10 https://www.epson.jp/products/receiptprinter/tmm10/
※レシートとは言っても通常の印刷と同じ レシート印刷 signage ┣━ Assets : ┣━ Plugins : ┣━ System.Drawing.dll :
①System.Drawing.dll を Plugins ディレクトリに設置 場所:C:\Windows\Microsoft.NET\Framework\ {バージョン} \System.Drawing.dll ②Other Settings の Api Compatibility Level を “.NET2.0” に
レシート印刷 void PrintExec() { PrintDocument printDocument = new PrintDocument(); //
オブジェクトの作成 printDocument.PrintPage += new PrintPageEventHandler(PrintPage); // イベントハンドラの追加 printDocument.Print(); // 印刷開始 } void PrintPage(object sender, PrintPageEventArgs eventPrintPage) { drawFont = new System.Drawing.Font("Arial", 10); // Arial フォントのサイズ10 drawBrush = new SolidBrush(System.Drawing.Color.Black); // 色は黒 drawFormat.Alignment = StringAlignment.Center; // センタリング string text = "印刷したい文字列"; eventPrintPage.Graphics.DrawString(text, drawFont, drawBrush, drawRect, drawFormat); Image image = Image.FromFile("画像のパス"); eventPrintPage.Graphics.DrawImage(image, new Rectangle(offsetX, offsetY, width, height)); image.Dispose(); //後始末 eventPrintPage.HasMorePages = false; //次のページがないことを通知する }
レシート印刷 void PrintExec() { PrintDocument printDocument = new PrintDocument(); //
オブジェクトの作成 printDocument.PrintPage += new PrintPageEventHandler(PrintPage); // イベントハンドラの追加 printDocument.Print(); // 印刷開始 } void PrintPage(object sender, PrintPageEventArgs eventPrintPage) { drawFont = new System.Drawing.Font("Arial", 10); // Arial フォントのサイズ10 drawBrush = new SolidBrush(System.Drawing.Color.Black); // 色は黒 drawFormat.Alignment = StringAlignment.Center; // センタリング string text = "印刷したい文字列"; eventPrintPage.Graphics.DrawString(text, drawFont, drawBrush, drawRect, drawFormat); Image image = Image.FromFile("画像のパス"); eventPrintPage.Graphics.DrawImage(image, new Rectangle(offsetX, offsetY, width, height)); image.Dispose(); //後始末 eventPrintPage.HasMorePages = false; //次のページがないことを通知する } メインの処理 PrintDocument のオブジェクトを作成して PrintPage イベントハンドラを追加してやる (この辺は .NET の領域)
レシート印刷 void PrintExec() { PrintDocument printDocument = new PrintDocument(); //
オブジェクトの作成 printDocument.PrintPage += new PrintPageEventHandler(PrintPage); // イベントハンドラの追加 printDocument.Print(); // 印刷開始 } void PrintPage(object sender, PrintPageEventArgs eventPrintPage) { drawFont = new System.Drawing.Font("Arial", 10); // Arial フォントのサイズ10 drawBrush = new SolidBrush(System.Drawing.Color.Black); // 色は黒 drawFormat.Alignment = StringAlignment.Center; // センタリング string text = "印刷したい文字列"; eventPrintPage.Graphics.DrawString(text, drawFont, drawBrush, drawRect, drawFormat); Image image = Image.FromFile("画像のパス"); eventPrintPage.Graphics.DrawImage(image, new Rectangle(offsetX, offsetY, width, height)); image.Dispose(); //後始末 eventPrintPage.HasMorePages = false; //次のページがないことを通知する } DrawString に文字列を渡すと印刷できる フォントや色、レイアウトもオプションで 渡せば細かく指定することが可能
レシート印刷 void PrintExec() { PrintDocument printDocument = new PrintDocument(); //
オブジェクトの作成 printDocument.PrintPage += new PrintPageEventHandler(PrintPage); // イベントハンドラの追加 printDocument.Print(); // 印刷開始 } void PrintPage(object sender, PrintPageEventArgs eventPrintPage) { drawFont = new System.Drawing.Font("Arial", 10); // Arial フォントのサイズ10 drawBrush = new SolidBrush(System.Drawing.Color.Black); // 色は黒 drawFormat.Alignment = StringAlignment.Center; // センタリング string text = "印刷したい文字列"; eventPrintPage.Graphics.DrawString(text, drawFont, drawBrush, drawRect, drawFormat); Image image = Image.FromFile("画像のパス"); eventPrintPage.Graphics.DrawImage(image, new Rectangle(offsetX, offsetY, width, height)); image.Dispose(); //後始末 eventPrintPage.HasMorePages = false; //次のページがないことを通知する } DrawImage に画像と表示領域を Rectangle で渡してやると画像も印刷できる
レシートもこれで印刷できるが、これもやってみると... やはりハマる ・System.Drawing.dll なんて知らんかった ・Api Compatibility Level の設定も知らんぞ ・画像とテキストで細かく offset
を指定する必要あり ・別途プリンタのドライバの設定が必要 ・情報が出てこない(→最近は結構情報がある) - https://qiita.com/koukiwf/items/e91067e95c2a64af54d6 - http://madgenius.hateblo.jp/entry/2018/01/30/172740 レシート印刷
その他にも 色々ハマる ・そもそも端末/OS側を色々いじる必要 →3画面出力できるようグラボ取り付け →自動起動/終了のためにタスクスケジューラとか BIOS の設定 ・インスタAPI使いたい →ご当地写真を表示するんだ!審査が必要か! →英文の説明入り動画まで作ったのにリジェクト
→Flicker API で妥協してやった に救われる ・Windows10 だとエッジスワイプで通知が出る →物理的にスワイプできないようフレームをつける
こんだけ色々出てくる → Unityが何でもできるからこそ! ゲームや今回のサイネージ以外でも ・UIの自由度 ・インタラクティブな機能 を活かせるフィールドなら応用できる! 最近だと xR(VR /
AR)なんかが好例 それでも...
Unity盛り上げていきましょう! (そしてマルチディスプレイの順番の詳細を教えてください...)
中谷 圭佑 (@ksk1030) 任天堂株式会社(2011/04〜2013/12) ・人事 株式会社ORSO(2014/01〜) ・エンジニア(Node.js / Ruby がメイン)
・経営企画 ◆Speaker Deck ・https://speakerdeck.com/ksk1030m 自己紹介
We are hiring! ARコンテンツとかも作ってます!
Thank you for listening !!