52
知って得する Unity 株式会社ハ・ン・ド プログラマ 馬場翔太 http://baba-s.hatenablog.com/

知って得するUnity

Embed Size (px)

Citation preview

Page 1: 知って得するUnity

知って得する Unity

株式会社ハ・ン・ド

プログラマ

馬場翔太

http://baba-s.hatenablog.com/

Page 2: 知って得するUnity

スライド内容

1. エディタの操作について

2. エディタの拡張について

3. アセットの活用について

Page 3: 知って得するUnity

エディタの操作

Page 4: 知って得するUnity

public class Character : MonoBehaviour

{

private int id = 1;

private string name = "Mike";

}

private変数の状態を確認したい

Page 5: 知って得するUnity

private変数をInspectorに表示する

Inspectorの右上のボタンからDebugを選択

http://terasur.blog.fc2.com/blog-entry-252.html

Page 6: 知って得するUnity

エディタ停止を忘れて作業をしてしまった

Page 7: 知って得するUnity

エディタ再生時の色を変える

1. 「Unity>Preference...」を選択する

2. 「Colors>Genreal>Playmode tint]の色を変更する

http://terasur.blog.fc2.com/blog-entry-252.html

Page 8: 知って得するUnity

ログを出力したオブジェクトを特定したい

private void Start()

{

Debug.Log("Start");

}

Page 9: 知って得するUnity

ログを出力したオブジェクトを選択

private void Start()

{

Debug.Log("Start", this);

}

第二引数にオブジェクトやコンポーネントを渡す

Page 10: 知って得するUnity

オブジェクトをキレイに配置したい

Page 11: 知って得するUnity

オブジェクトの移動や回転でスナップ

Ctrlキーを押しながら移動や回転をさせるとスナップ可能

スナップする量は「Edit>Snap Settings...」で設定可能

Page 12: 知って得するUnity

深い親子階層を一気に開きたい

Altキーを押しながらアイテムの親子関係を開く

Page 13: 知って得するUnity

Projectビューで特定のアセットのみ表示

検索欄の右のボタンで表示したいアセットの種類を選択

Page 14: 知って得するUnity

オブジェクトやアセットを複製したい

複製したいアイテムを選択してCtrl+D

(アセットなら連番の適用も可能)

Page 15: 知って得するUnity

エディタの拡張

Page 16: 知って得するUnity

• テクスチャの種類をGUIに

• AudioClipの3Dサウンドをオフに

アセットの設定変更を効率化したい

Page 17: 知って得するUnity

アセットインポート時に設定を自動変更

http://www.buildinsider.net/consumer/charmofunity/01 http://kan-kikuchi.hatenablog.com/entry/2013/11/25/000144

using UnityEditor;

public class AssetPreprocessor : AssetPostprocessor

{

private void OnPreprocessTexture()

{

var importer = assetImporter as TextureImporter;

importer.textureType = TextureImporterType.GUI;

}

private void OnPreprocessAudio()

{

var importer = assetImporter as AudioImporter;

importer.threeD = false;

}

}

Page 18: 知って得するUnity

アセットインポート時に設定を自動変更

http://www.buildinsider.net/consumer/charmofunity/01 http://kan-kikuchi.hatenablog.com/entry/2013/11/25/000144

using UnityEditor;

public class AssetPreprocessor : AssetPostprocessor

{

}

AssetPostprocessorクラス

継承してクラスを記述することで

アセット読み込み時の独自の処理を実装できます

Page 19: 知って得するUnity

アセットインポート時に設定を自動変更

http://www.buildinsider.net/consumer/charmofunity/01 http://kan-kikuchi.hatenablog.com/entry/2013/11/25/000144

private void OnPreprocessTexture()

{

var importer = assetImporter as TextureImporter;

importer.textureType = TextureImporterType.GUI;

}

OnPreprocessTexture関数

テクスチャがインポートされた時に呼び出されます

Page 20: 知って得するUnity

アセットインポート時に設定を自動変更

http://www.buildinsider.net/consumer/charmofunity/01 http://kan-kikuchi.hatenablog.com/entry/2013/11/25/000144

private void OnPreprocessAudio()

{

var importer = assetImporter as AudioImporter;

importer.threeD = false;

}

OnPreprocessAudio関数

AudioClipがインポートされた時に呼び出されます

Page 21: 知って得するUnity

再生中にスクリプトを編集してエラーに

再生中にスクリプトを編集して保存すると

コンパイル後にエラーが出力される

Page 22: 知って得するUnity

スクリプト編集後に実行を自動で停止

[InitializeOnLoad]

public static class PlaymodeStop

{

static PlaymodeStop()

{

EditorApplication.update += Update;

}

private static void Update()

{

if ( EditorApplication.isCompiling &&

EditorApplication.isPlaying)

{

EditorApplication.isPlaying = false;

}

}

}

http://masa795.hatenablog.jp/entry/2013/05/10/104033

Page 23: 知って得するUnity

スクリプト編集後に実行を自動で停止

[InitializeOnLoad]

public static class PlaymodeStop

{

static PlaymodeStop()

{

}

}

http://masa795.hatenablog.jp/entry/2013/05/10/104033

InitializeOnLoad属性

staticコンストラクタを持つクラスに記述すると

エディタ起動時に独自のスクリプトを実行できる

Page 24: 知って得するUnity

スクリプト編集後に実行を自動で停止

static PlaymodeStop()

{

EditorApplication.update += Update;

}

http://masa795.hatenablog.jp/entry/2013/05/10/104033

EditorApplication.update

エディタで再生中に毎秒約100回呼ばれるコールバック

Page 25: 知って得するUnity

スクリプト編集後に実行を自動で停止

private static void Update()

{

if ( EditorApplication.isCompiling &&

EditorApplication.isPlaying)

{

EditorApplication.isPlaying = false;

}

}

http://masa795.hatenablog.jp/entry/2013/05/10/104033

EditorApplicationクラス

スクリプトがコンパイルされたかどうかや

エディタが再生中かどうかを確認できるクラス

Page 26: 知って得するUnity

アセットの活用

Page 27: 知って得するUnity

• Project Settingsの設定

• ゲームオブジェクトの作成

手順を効率化したい

Page 28: 知って得するUnity

ショートカットを追加する

Extras Toolbar(無料)

http://masa795.hatenablog.jp/entry/2013/06/14/094537

Page 29: 知って得するUnity

ショートカットを追加する

「Window>Extras」を選択

http://masa795.hatenablog.jp/entry/2013/06/14/094537

Page 30: 知って得するUnity

配列をコンソールログに出力したい

// 標準のコンソール出力

var array = new []{ "1", "2", "3", “4", “5", };

Debug.Log(array);

Page 31: 知って得するUnity

配列をコンソールログに出力する

Quick Debugger(無料)

http://terasur.blog.fc2.com/blog-entry-211.html

Page 32: 知って得するUnity

配列をコンソールログに出力する

// Quick Debuggerのコンソール出力

var array = new []{ "1", "2", "3", “4", “5", };

Debugger.Array<string>(array);

http://terasur.blog.fc2.com/blog-entry-211.html

Page 33: 知って得するUnity

配列をコンソールログに出力する

// 二次元配列

Debugger.Array2D<string>(array);

// List型

Debugger.List<string>(list);

// Dictionary型

Debugger.Dictionary<int, string>(dict);

http://terasur.blog.fc2.com/blog-entry-211.html

二次元配列やコレクションも出力可能

Page 34: 知って得するUnity

オブジェクトのパラメータを間違って変更

Page 35: 知って得するUnity

GameObjectをロック

UnityLock(無料)

http://terasur.blog.fc2.com/blog-entry-487.html

Page 36: 知って得するUnity

GameObjectをロック

1. ロックしたいオブジェクトを選択

2. 「GameObject>UnityLock>Lock GameObject」を選択

http://terasur.blog.fc2.com/blog-entry-487.html

Page 37: 知って得するUnity

アプリサイズのボトルネックを見つけたい

テクスチャ AudioClip モデル

Page 38: 知って得するUnity

アプリサイズの内訳を確認

http://terasur.blog.fc2.com/blog-entry-472.html http://plaza.rakuten.co.jp/coronasdk/diary/201305230001/

Build Report Tool($5)

Page 39: 知って得するUnity

アプリサイズを確認

Page 40: 知って得するUnity

使用しているアセットの容量を確認

Page 41: 知って得するUnity

使用していないアセットの確認と削除

Page 42: 知って得するUnity

簡単に動きをつける

http://www40.atwiki.jp/spellbound/pages/1604.html

iTween(無料)

Page 43: 知って得するUnity

エディタ上でiTweenを設定する

http://www.cho-design-lab.com/2013/08/07/unity-itween-visual-editor-introduction/

iTween Visual Editor(無料)

Page 44: 知って得するUnity

アプリの解読や改ざんを防ぐ

http://masa795.hatenablog.jp/entry/2013/06/29/131336

CodeGuard($40)

Page 45: 知って得するUnity

フォトショのデータをNGUIにインポート

http://terasur.blog.fc2.com/blog-entry-337.html

FastGUI for NGUI($20)

Page 46: 知って得するUnity

エディタ再生中に変更した値を保持する

http://terasur.blog.fc2.com/blog-entry-578.html

PlayModePersist($20)

Page 47: 知って得するUnity

ドローコールを減らす

http://terasur.blog.fc2.com/blog-entry-214.html

Draw Call Minimizer(無料)

Page 48: 知って得するUnity

オススメのパーティクルシステム

"Shuriken Magic" Effect Pack($35)

http://memo.scri.me/entry/2013/02/09/002415

Page 49: 知って得するUnity

オススメの3Dモデル

First Fantasy for Mobile($20)

Page 50: 知って得するUnity

オススメの3Dモデル

Low Poly Fantasy Village Pack.01($20)

Page 51: 知って得するUnity

オススメの3Dモデル

Palace of Orinthalian(無料)

Page 52: 知って得するUnity

ありがとうございました