基準解像度や組み合わせによる幅や高さにマッチするように Canvas のスケールを設定します
0 を設定した場合、Canvas は現在のスクリーン解像度の幅と基準解像度の幅の差に応じでスケーリングされます。1 を設定した場合、Canvas は現在のスクリーン解像度の高さと基準解像度の高さの差に応じてスケーリングされます。
値は 0 から 1 の間で、スケーリングは相対的な幅と高さの組み合わせに基づいています。
640x480 の基準解像度と現在のスクリーン解像度が Landscape モードの 480x640 の例を考えてみます。
scaleWidthOrHeight が 0 に設定されている場合、現在の解像度の幅は 480 で、基準解像度の幅 640 の 0.75 倍であることから Canvas が 0.75 にスケーリングされます。Canvas の解像度は 640x853.33 の解像度になります。この解像度は基準解像度の幅と同じ幅になりますが、現在のスクリーン解像度のアスペクト比を持ちます。640x853.33 の Canvas 解像度は 0.75 のスケールファクタでスクリーン解像度を割ったものです。
scaleWidthOrHeight が 1 に設定されている場合、現在の解像度の高さは 640 で、基準解像度の高さ 480 の 1.33 倍であることから Canvas が 1.33 にスケーリングされます。Canvas の解像度は 360x480 の解像度になります。この解像度は基準解像度の幅と同じ高さになりますが、現在のスクリーン解像度のアスペクト比を持ちます。360x480 の Canvas 解像度は 1.33 のスケールファクタでスクリーン解像度を割ったものです。
scaleWidthOrHeight が 0.5 に設定されている場合、必要に応じで水平方向のスケーリング(0.75)や、垂直方向のスケーリング(1.33)を行い、その平均値を求めます。けれども、対数空間で平均値を求めます。0.75 と 1.33 の標準の平均は 1.04 になるでしょう。しかし、1.33 を掛けてから 0.75 で割るのと同じであって、2 つのスケールファクタは 0.75 を掛けるのに対して、0.75 で割るのと一致し、それらの 2 つの平均値は一致する必要があり、当然の結果として提供されなければいけません。0.75 と 1.33 の対数空間の平均は私達が望む通りの 1.0 になります。したがって、Canvas の解像度は現在の解像度を 1.0 のスケールファクタで割った 480x640 になります。
ロジックはすべての値に対して同じように働きます。水平と垂直間のスケールファクタの平均は、matchWidthOrHeight の値に基いて加重平均されます。
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.