Slider (スライダー) を使うと、ユーザーがマウスをドラッグすることによって所定の範囲から数値を選択できます。これに似た スクロールバー は、数の値を選択するためでなく、スクロールするために使われます。身近な例にはゲームの難易度設定や、画像エディターで明るさを設定することなどがあります。
プロパティ | 機能 |
---|---|
Interactable | このコンポーネントが入力を受け付けるかどうか Selectable 基底クラス を参照してください。 |
Transition | ユーザーのアクションに対して視覚的な反応の仕方を決定するプロパティです。詳しくは 遷移オプション を参照してください。 |
Navigation | 制御の一連の流れを決定するプロパティです。詳しくは ナビゲーション操作 を参照してください。 |
Fill Rect | fill部分に使われるグラフィック |
Handle Rect | スライドする「ハンドル」部分に使われるグラフィック |
Direction | ハンドルをドラッグしたときスライダーの Value が増加する方向 オプションには Left To Right, Right To Left, Bottom To Top, Top To Bottom があります。 |
Min Value | ハンドルが( Direction プロパティで決まる)もっとも下端にあるときのスライダーの値 |
Max Value | ハンドルが( Direction プロパティで決まる)もっとも上端にあるときのスライダーの値 |
Whole Numbers | スライダーを整数の値に制限するかどうか |
Value | スライダーの現在の数値 インスペクターで値が設定されていれば、初期値として使用されますが、実行時に値が変わると変更されます。 |
プロパティ | 機能 |
---|---|
On Value Changed | スライダーの現在の値が変更されたときに実行される UnityEventです。イベントは float の値を引数として渡します。Whole Numbers プロパティが有効かどうかは関係なく、値は応答する関数に float 型として渡されます。 |
スライダーの値は、その長さに沿ったハンドルの位置によって決定されます。値はハンドルをドラッグする距離に比例して Min Value から Max Value まで増加します。スライダーのデフォルト動作は左から右への増加ですが、Direction プロパティを用いて動作を反転させることもできます。また、Direction プロパティで Bottom To Top か Top To Bottom を選択することで縦方向に増加するスライダーを設定することもできます。
スライダーはユーザーがハンドルをドラッグするのに反応するため On Value Changed というイベントが一つあります。スライダーの現在の数値は ‘float’ パラメーターとして関数に渡されます。典型的な使用例は次のようなものです。
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.