CanvasScaler コンポーネントは Canvas 内の UI 要素の全体的なスケールとピクセル密度を制御するために使用されます。このスケーリングはフォントのサイズと画像のボーダーを含め、Canvas のすべてに影響を与えます。
プロパティ | 機能 |
---|---|
UI Scale Mode | Canvas 内の UI 要素をどのようにスケーリングするかを決めます。 |
Constant Pixel Size | UI 要素を画面サイズによらずピクセル単位で同様のサイズに保ちます。 |
Scale With Screen Size | 画面サイズが大きいほどに、UI 要素を大きくします。 |
Constant Physical Size | UI 要素を画面サイズや解像度によらず、物理的に同様のサイズに保ちます。 |
Constant Pixel Size の設定
プロパティ | 機能 |
---|---|
Scale Factor | このファクターで Canvas 内のすべての UI 要素をスケーリングします |
Reference Pixels Per Unit | スプライトが ‘Pixels Per Unit’ 設定を持つ場合、スプライトの 1 ピクセルは UI の 1 ユニットをカバーします。 |
Scale With Screen Size の設定
プロパティ | 機能 |
---|---|
Reference Resolution | UI レイアウトが設計されている解像度。もし画面解像度が大きければ、UI はスケールアップし、小さければ、UI はスケールダウンします。 |
Screen Match Mode | 現在の解像度のアスペクト比が基準解像度にフィットしない場合は、モードは Canvas 空間をスケールするのに使用されます |
Match Width or Height | 基準値となる幅、基準値となる高さや、何かの間となる Canvas の空間をスケールします |
Expand | Canvas 空間を水平や垂直に展開するので、Canvas のサイズは基準値よりも小さくなることはありません |
Shrink | Canvas 空間を水平や垂直にトリミングするので、Canvas のサイズは基準値よりも大きくなることはありません。 |
Match | スケーリングが width か height 、それらを混ぜ合わせたものを参照として使用するかを決定します。 |
Reference Pixels Per Unit | スプライトが ‘Pixels Per Unit’ 設定を持つ場合、スプライトの 1 ピクセルは UI の 1 ユニットをカバーします。 |
Constant Physical Size の設定
プロパティ | 機能 |
---|---|
Physical Unit | 位置とサイズを指定するための物理ユニット |
Fallback Screen DPI | 画面の DPI が不明な場合は、DPI と仮定します |
Default Sprite DPI | 1 インチあたりのピクセルは ‘Reference Pixels Per Unit’ 設定にマッチする ‘Pixels Per Unit’ 設定を持つスプライトのために使用されます |
Reference Pixels Per Unit | スプライトが ‘Pixels Per Unit’ 設定を有していれば、その DPI は ‘Default Sprite DPI’ 設定に当てはまります。 |
World Space Canvas の設定 (Canvas コンポーネントが ワールド空間に設定されている場合に表示されます)
プロパティ | 機能 |
---|---|
Dynamic Pixels Per Unit | Text など UI に動的にビットマップを作成するために使用する 1 ユニットあたりのピクセル量 |
Reference Pixels Per Unit | スプライトがこの ‘Pixels Per Unit’ 設定を有していれば、スプライトの 1 ピクセルはワールドの 1 ユニットをカバーします。‘Reference Pixels Per Unit’ が 1 に設定されていれば、スプライトの ‘Pixels Per Unit’ 設定は同様に使用されます。 |
‘Screen Space - Overlay’ や ‘Screen Space - Camera’ に設定した Canvas の、Canvas Scaler UI Scale Mode は Constant Pixel Size、Scale With Screen Size、Constant Physical Size に設定することができます。
Constant Pixel Size モードを使用すると、UI 要素の位置とサイズは画面上のピクセルに指定されます。また、これは CanvasScaler がアタッチされていないときの Canvas のデフォルトの機能です。しかし、CanvasScaler の Scale Factor の設定で、一定のスケーリングを Canvas 内のすべての UI 要素に適用することができます。
Scale With Screen Size モードを用いることで、指定された Reference Resolution のピクセルに応じて位置とサイズが明確になります。現在の画面解像度が Reference Resolution より大きければ、Canvas は Reference Resolution の解像度だけは維持し続けますが、画面に合うためにスケールアップします。もし現在のスクリーン解像度が Reference Resolution より小さければ、Canvas は画面に合わせるために同様にスケールダウンします。
現在の解像度が Reference Resolution と異なるアスペクト比率である場合、画面に合わせるためにそれぞれの軸をスケールすると、統一のとれないスケーリングになります。それは、一般的に望ましくありません。この代わりに、Reference Resolution コンポーネントは、画面のアスペクト比率を考慮して Canvas の解像度を Reference Resolution から逸脱させます。Screen Match Mode 設定を使用して、この逸脱した値を制御することが可能です。
ConstantPhysicalSize モードを使用すると、UI 要素の位置とサイズはミリメートル、ポイント、パイカなどの物理単位で指定されます。このモードは正しく画面の DPI を報告するデバイスに依存します。DPI を報告しないデバイスはフォールバック DPI を指定して使用することができます。
‘World Space’ に設定した Canvas の CanvasScaler は、Canvas 内の UI 要素のピクセル密度を制御するのに使用されます。
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.