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で3Dツールを作って開発を加速する
Search
ueshita
September 03, 2017
Programming
3.7k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unityで3Dツールを作って開発を加速する
Unity LT大会 2017 で発表
ueshita
September 03, 2017
Transcript
18 slides
Unityで3Dツールを作って 開発を加速する Unity LT大会 2017 うえした (@ueshita)
同人ゲームを作っています こんな感じのSRPG
このゲーム Unity製ではないです。 OpenGLを直叩き!オレオレエンジン!俺がねねっちだ!
SRPGにはマップエディタが必要 うちは極小規模サークルのため、 マップの地形を3Dモデリングで作るとか、デザイナーパワーで殴ることができない 前作はExcelでマップを作成(つらい) デザイン&企画の人「今作は立体交差とかできるといいよね^^」
3Dのグラフィカルなツールを作る サクッとUnityで作ろう! 誰でも3Dマップが作れるようにする Unityが無くてもいいようにビルドする。
作ったマップエディタ マインクラフト風に ブロックを積み上げ るマップエディタ コピペ、アンドゥ機能 OBJ形式でエクス ポート可能
Unityが3Dツール開発に向いている理由 プログラム言語がC# ・ 実行速度はあまり気にせずガンガン書ける 3D機能がバリバリ使い放題 ・ シェーダ書けるし、アニメーションも付けられる マルチプラットフォーム ・ WinでもMacでも動くツール!
ツール開発で絶対に必要なもの アンドゥ、リドゥ機能 コピー&ペースト ファイルを開く、保存ダイアログ
アンドゥ、リドゥ機能 絶対必要。 でも作るのは結構大変。 開発初期からアンドゥ、リドゥを前提に作る必要がある。
アンドゥ機能を作る class Command { public delegate void Method(); public Method
Do {get; private set;} public Method Undo {get; private set;} public Command(Method doMethod, Method undoMethod) { this.Do = doMethod; this.Undo = undoMethod; } } 全ての操作をコマンド化 操作するたびにCommandをnewして ListにAddする。 実行するときは Do(); 元に戻す(アンドゥ)ときは Undo(); やり直す(リドゥ)するときは Do();
コマンド実装例①:ブロックを追加する public void AddBlock(Vector3 position, BlockDirection dir) { EditLayer layer
= this.CurrentLayer; Block block = new Block(position, dir); this.AddCommand(new Command( () => { // Do layer.AddBlock(block); }, () => { // Undo layer.RemoveBlock(block); })); } 現在のレイヤーに ブロックを作成して追加する 操作コマンドを作成 ・最初の引数がDo() ・次の引数がUndo() “実行”と”戻す”ときに必要な 変数はラムダ式にキャプチャされる
コマンド実装例②:ブロックを移動する public void MoveBlock(Block block, Vector3 moveOffset) { EditLayer layer
= this.CurrentLayer; Block removedBlock; this.AddCommand(new Command( () => { // Do layer.RemoveBlock(block); // レイヤーから一旦削除 block.position += moveOffset; // ブロックの位置を移動する removedBlock = layer.AddBlock(block); // 移動したブロックを追加。上書きしたブロックを保持しておく }, () => { // Undo layer.RemoveBlock(block); // レイヤーから一旦削除 block.position -= moveOffset; // ブロックの位置を戻す layer.AddBlock(block); // ブロックを戻す layer.AddBlock(removedBlock); // 上書きしたブロックを戻す })); }
C#のラムダ式は超便利 操作コマンドごとにクラスを作る必要がない 保持するべきデータはローカル変数に保存 ラムダ式で参照すると勝手にキャプチャされる データが不要になったらGCが解放してくれる
コピー&ペースト機能を作る EditorGUtility.systemCopyBufferを使う? → × UnityEditor名前空間なので、実行時に使えない! Windows.FormsのClipboardを使う? → Unityからは”通常”使えない System.Windows.Forms.dll を
Plugins/ に置けば使える!\(^o^)/ 場所: C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.5-api\
ファイルを開くダイアログを呼び出す System.Windows.Forms.dll を置いておくと、 各種コモンダイアログも使えるようになる。 - ファイルを開く: OpenFIleDialog - 名前を付けて保存: SaveFileDialog
ツールでは必須の機能
ダイアログのデザインがちがくね? System.Windows.Forms.dllが Windowsネイティブ実装ではなく、Mono実装なのが原因。 Windowsユーザー的にはデザインが違うので、ちょっと使いにくいかも?
Windowsネイティブなダイアログを呼び出す Win32APIを C# から 叩く [DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar
= true, CharSet = CharSet.Auto)] public static extern bool GetOpenFileName([In, Out] OpenFileName ofn); Windowsネイティブな ダイアログが使えるように →
ツールを作った結果 自分以外の人でもマップが作れるようになった! Githubに置いてあります。 https://github.com/ueshita/TsumikiEditor
More Decks by ueshita
See All by ueshita
こわくない!! たのしい!! GDExtension
ueshita
0
2.3k
Godot Engine完全に理解したかった
ueshita
1
680
UnmanagedThreadノススメ
ueshita
2
8.4k
EmscriptenのOpenGLと純粋なWebGLと共存させる黒魔術
ueshita
1
5.1k
asm.js 減量やってみた
ueshita
0
1k
Other Decks in Programming
See All in Programming
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.5k
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
370
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
460
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
240
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
3
220
正解の無い問題を 「できるだけ上手く」解く ヒューリスティックで感性を磨こう。〜現実課題をプログラミングで解きあうコミュニティについて〜
allegrogiken
0
110
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
130
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
210
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
240
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
170
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
120
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.5k
Code Review Best Practice
trishagee
74
20k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Facilitating Awesome Meetings
lara
57
7.2k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
430
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
820
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Raft: Consensus for Rubyists
vanstee
143
7.9k
Utilizing Notion as your number one productivity tool
mfonobong
4
650
How to train your dragon (web standard)
notwaldorf
96
6.9k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
2
4k