LongField は、ユーザーがアプリケーションに数値の長整数値 (long integer) を入力するためのものです。テキスト入力を受け付け、表示します。プレースホルダーのテキストを設定することで、ユーザーに入力のヒントや指示を与えることができます。また、バリデーション関数を追加して、入力されたデータが特定の要件を満たしていることを確認することもできます。
LongField を Inspector ウィンドウ内の他のフィールドに揃えるには、.unity-base-field__aligned
USS クラスを適用してください。詳細は BaseField
を参照してください。
UI Builder、UXML、C# を使用して LongField を作成できます。
C# で LongField を作成するには、LongField オブジェクトの新しいインスタンスを作成します。以下はその例です。
LongField myElement = new LongField("Label text");
入力テキストはデフォルトで選択可能です。selectAllOnMouseUP
や selectAllOnFocus
など、選択時の動作はカスタム化可能です。
C#では textSelection
を通じて設定します。
myElement.textSelection.selectAllOnMouseUp = false;
myElement.textSelection.selectAllOnFocus = false;
C# クラス: LongField
名前空間: UnityEngine.UIElements
基本クラス: TextValueField_1
この要素は基本クラスから以下の属性を継承します。
名前 | 型 | 説明 |
---|---|---|
binding-path |
string |
バインドされるべきターゲットプロパティのパス。 |
focusable |
boolean |
要素がフォーカス可能である場合は true。 |
is-delayed |
boolean |
true に設定すると、ユーザーが Enter キーを押すか、テキストフィールドのフォーカスが失われるまで、value プロパティは更新されません。 |
label |
string |
フィールドの横に表示されるラベルを表す文字列。 |
tabindex |
int |
フォーカスリング内でフォーカス可能なものをソートするために使用される整数。0 以上であることが必要です。 |
value |
long |
これは、フィールドの値です。 |
この要素は、VisualElement
から以下の属性も継承します。
名前 | 型 | 説明 |
---|---|---|
content-container |
string |
子要素はそれに追加されますが、通常は要素自体と同じです。 |
name |
string |
この VisualElement の名前。 このプロパティを使用して、特定の要素を対象とする USS セレクターを記述します。要素には一意の名前を付けるのが標準的です。 |
picking-mode |
UIElements.PickingMode |
mouseEvents または IPanel.Pick クエリの間にこの要素を選択 (ピック) できるかどうかを決定します。 |
style |
string |
この要素のスタイルオブジェクトへの参照。 C# でこのオブジェクトに書き込まれた USS ファイルまたはインラインスタイルから計算されたデータが含まれます。 |
toolbar |
string |
ユーザーが要素をマウスオーバーした後、わずかな時間、情報ボックス内に表示するテキスト。これはエディター UI でのみサポートされます。 |
usage-hints |
UIElements.UsageHints |
VisualElement の高レベルの使用パターンを指定するヒント値の組み合わせ。このプロパティは、VisualElement がまだ Panel の一部でない場合にのみ設定できます。Panel の一部になると、このプロパティは事実上読み取り専用となり、変更しようとすると例外がスローされます。適切な UsageHints を指定することで、予想される使用パターンに基づいて、特定の操作をどのように処理するか、または高速化するかについて、システムがより適切な判断を下すようになります。これらのヒントは動作や視覚的な結果には影響しませんが、パネルとその中の要素の全体的なパフォーマンスにのみ影響することに注意してください。常に適切なUsageHints を指定することを考慮することをお勧めしますが、特定の条件下 (例えば、ターゲットプラットフォームのハードウェア制限など) では、いくつかの UsageHints が内部的に無視される可能性があることに留意してください。 |
view-data-key |
string |
ビューデータの永続性 (ツリーの展開状態、スクロール位置、ズームレベルなど) に使用されます。 これは、ビューデータストアからビューデータを保存/ロードするために使用されるキーです。このキーを設定しないと、この VisualElement の永続性が無効になります。 |
以下の表は、すべての C# パブリックプロパティ名と、それに関連する USS セレクターのリストです。
C# プロパティ | USS セレクター | 説明 |
---|---|---|
ussClassName |
.unity-long-field |
この型の要素の USS クラス名。 |
labelUssClassName |
.unity-long-field__label |
この型の要素のラベルの USS クラス名。 |
inputUssClassName |
.unity-long-field__input |
この型の要素の入力要素の USS クラス名。 |
ussClassName |
.unity-base-text-field |
この型の要素の USS クラス名。 |
labelUssClassName |
.unity-base-text-field__label |
この型の要素のラベルの USS クラス名。 |
inputUssClassName |
.unity-base-text-field__input |
この型の要素の入力要素の USS クラス名。 |
singleLineInputUssClassName |
.unity-base-text-field__input--single-line |
このタイプの要素の 1 行入力要素の USS クラス名。 |
multilineInputUssClassName |
.unity-base-text-field__input--multiline |
このタイプの要素の複数行入力要素の USS クラス名。 |
ussClassName |
.unity-base-field |
この型の要素の USS クラス名。 |
labelUssClassName |
.unity-base-field__label |
この型の要素のラベルの USS クラス名。 |
inputUssClassName |
.unity-base-field__input |
この型の要素の入力要素の USS クラス名。 |
noLabelVariantUssClassName |
.unity-base-field--no-label |
ラベルがない場合の、この型の要素の USS クラス名。 |
labelDraggerVariantUssClassName |
.unity-base-field__label--with-dragger |
この型の要素にドラッガーがアタッチされている場合のラベルの USS クラス名。 |
mixedValueLabelUssClassName |
.unity-base-field__label--mixed-value |
混合値を示す要素の USS クラス名 |
alignedFieldUssClassName |
.unity-base-field__aligned |
インスペクター要素で整列される要素の USS クラス名 |
disabledUssClassName |
.unity-disabled |
ローカルで無効にされた要素の USS クラス名。 |
また、Inspector や UI Toolkit Debugger の Matching Selectors セクション を使用して、どの USS セレクターが VisualElement
のコンポーネントに影響するかを、階層のすべてのレベルで確認することもできます。
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.