3D 向けの機能が有名ではありますが、Unity は 2D ゲームの制作にも活用することができます。使い慣れたエディターの機能をこれまで通り使用することもできますし、2D の開発を容易にする便利な追加機能もあります。
今すぐにでも注目しておきたい特徴は Scene view のツールバーにある 2D view mode ボタンです。2D モードが有効な時は、平行投影な(遠近法ではない)見た目が設定されます。具体的には、カメラは Y 軸が上向きに増加すると、Z 軸に沿ってシーンを見ます。これによってシーンと 2D オブジェクトの位置が簡単に可視化できます。
すべての 2D コンポーネントのリスト、2D と 3D 間の変換方法、2D と 3D の異なるモード設定などに関しては、2D/3Dプロジェクト を参照してください。
2D におけるグラフィックオブジェクトは Sprites です。Sprite は本来、単なる標準的なテクスチャですが、開発中の効率や便利さのために、Sprite テクスチャの組み合わせや管理には特別な技術が使われています。Unity は大きな画像から Sprite グラフィックを取り出して使えるように、組み込み済みの スプライトエディター を提供します。これにより、画像エディター内の一枚のテクスチャ内にある大量の画像コンポーネントを編集することができます。これを使うことで例えば、一枚の画像内で、あるキャラクターの腕、脚や体を分離された要素として保有しておくことなどができます。
スプライトは 3D のオブジェクトで使用される Mesh Renderer ではなく、Sprite Renderer コンポーネントによって描画されます。このコンポーネントを Components メニューから (Component > Rendering > Sprite Renderer を選択、または Sprite Renderer を設定したゲームオブジェクトを直接作成することもできます (GameObject > 2D Object > Sprite)。
さらに、Sprite Creator ツールを 2D 画像のプレースホルダーを作るために使用できます。
Unity には 2D のみで利用可能となる最適化のために、2D の物理演算を扱う独立した物理エンジンがあります。コンポーネントは Rigidbody、Box Collider や Hinge Joint といった標準的な 3D の物理コンポーネントは「 2D 」と名前に追加されたものにも対応します。ですので、Sprite は Rigidbody 2D、Box Collider 2D そして Hinge Joint 2D といったものを使用できます。ほとんどの 2D 物理演算コンポーネントは、3D で同じ性質を持つものを単に「平面化」したものです。(例えば、Box Collider はキューブ型である一方で、Box Collider 2D は正方形です)しかし、いくつかの例外もあります。
2D Physics コンポーネントの一覧は 2D/3Dプロジェクト を参照してください。マニュアルの Physics セクションを見て、2D 物理演算の概念やコンポーネントに関するより多くのことを学ぶことができます。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.