絵文字などのリッチテキストタグでスプライトを使用するには、スプライトアセットが必要です。スプライトアセットは、一群のスプライトを含むアトラス テクスチャ から作成します。
好きなだけスプライトアトラスとアセットを使用できます。ただし、1 つのテキストオブジェクトに複数のアトラスを使用すると、そのオブジェクトに対して複数のドローコールが発生し、より多くのシステムリソースを消費します。原則として、複数のスプライトをインポートする場合は、1 つのアトラスにまとめてドローコールの数を減らしてください。スプライトアトラスがターゲットプラットフォームに対して適した解像度を持っていることを確認してください。
<sprite>
リッチテキストタグ を使って、テキストにスプライトを加えることができます。
すべての スプライトアセットプロパティ に関する情報を参照してください。
アトラステクスチャからスプライトアセットを作成します。スプライトアセットとそのソーステクスチャは別のものですが、スプライトアセットを作成した後も、ソーステクスチャをプロジェクトに残しておく必要があります。
リリースを作成するには以下を行います。
スプライトアトラスをインポート します。
アトラスを選択し、Inspector ウィンドウで以下のテクスチャオプションを変更します。
Sprite Editor を選択し、テクスチャを個々のスプライトに分割します。
スプライトを右クリックし、Create > Text > Sprite Asset を選択します。これで新しいスプライトアセットが作成されます。
Inspector ウィンドウから、各グリフの外観と名前をさらにカスタマイズできます。詳しくは スプライトアセットのプロパティ を参照してください。
スプライトアセットを Panel Text Settings で設定したパスに配置します。
スプライトアセットを作成したら、アトラステクスチャの Texture Type を元の設定に戻します。
リッチテキストタグでスプライトを使うには、スプライトアセット名とスプライト名を <sprite="assetName" name="spriteName">
、またはインデックスで <sprite="assetName" index=1>
のように参照します。
タグに tint=1
属性を追加すると、テキストオブジェクトの頂点色でスプライトを色付けすることができます。また、<sprite="assetName" index=1 color=#55FF55FF>
のように、タグに color 属性を追加することで、別の色を選択することもできます。
ランタイム UI の場合、Panel Text Settings でスプライトアセットをデフォルトに設定していれば、<sprite index=1>
(または省略形の <sprite=1>
)、または <sprite name="spriteName">
として`アセット名を省略できます。
スプライトに Unicode を割り当てて、<sprite>
タグの代わりにテキストオブジェクトで直接 Unicode を使うことができます。
例えば、笑顔の絵文字の Unicode は U+1F60A
です。これをスプライトアセットのスプライトに割り当てるには、以下を行います。
+1F60A
と入力します。0xF1F60A
に変更されます。テキストオブジェクトに笑顔の絵文字を使用するには、\\U00F1F60A
と入力してください。
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.