ParameterContainer
ParameterContainerはグラフ間でのデータ共有などを行うために使用するコンポーネントです。
GameObjectにParameterContainerを追加し、各種ある型のパラメータを設定します。
ParameterContainerの追加
GameObjectの作成
HierarchyのCreateボタンをクリックするか右クリックしたメニューの「Create」から、
「Arbor > ParameterContainer」を選択すると、ParameterContainerが追加された状態のGameObjectが作成できます。
GameObjectに追加
- 適用したいGameObjectを選択。
- 「メニュー > Component > Arbor > ParameterContainer」を選択 。
- あるいはInspectorの「Add Componentボタン > Arbor > ParameterContainer」を選択。
ParameterContainerの編集
パラメータの追加
- 「Parameters」の右下の+ボタンをクリック。
追加したい型を選択。
パラメータの編集
- 名前、値を選択し編集。
パラメータの削除
- パラメータを選択し、-ボタンをクリック。
パラメータの種類
| 種類 | Inspector | 説明 |
|---|---|---|
| Int |
|
符号付き32bit整数 |
| Float |
|
符号付き32bit浮動小数点数 |
| Bool |
|
ブール |
| GameObject |
|
GameObjectの参照 |
| String |
|
文字列 |
| Vector2 |
|
2次元ベクトル |
| Vector3 |
|
3次元ベクトル |
| Quaternion |
|
4元数 |
| Rect |
|
2次元の矩形 |
| Bounds |
|
3次元空間の範囲 |
| Color |
|
色 |
| Transform |
|
Transformコンポーネントの参照 |
| RectTransform |
|
RectTransformコンポーネントの参照 |
| Rigidbody |
|
Rigidbodyコンポーネントの参照 |
| Rigidbody2D |
|
Rigidbody2Dコンポーネントの参照 |
| Component |
|
コンポーネントの参照(型指定可能) |
| Long |
|
符号付き64bit整数 |
| Variable | 自作可能なパラメータ型 |
Variableについて
Variableを使用するとパラメータを自作することができます。
詳しくは、「Variableによるパラメータのカスタマイズ」を参照してください。
パラメータの参照
ParameterReference
ParameterReference関連クラスをフィールドに宣言することで、パラメータを参照できるようになります。
スクリプト例
|
|
このスクリプトをGameObjectに追加すると以下のようになります。
| フィールド名 | 説明 |
|---|---|
| Container | 参照するParameterContainer |
| Parameter | 参照するパラメータ |
取得したParameterについては、スクリプトリファレンスを参照してください。
ParameterReference関連クラス
- IntParameterReference
- FloatParameterReference
- BoolParameterReference
- GameObjectParameterReference
- StringParameterReference
- Vector2ParameterReference
- Vector3ParameterReference
- QuaternionParameterReference
- RectParameterReference
- BoundsParameterReference
- ColorParameterReference
- TransformParameterReference
- RectTransformParameterReference
- RigidbodyParameterReference
- Rigidbody2DParameterReference
- ComponentParameterReference
- LongParameterReference
- AnyParameterReference
(Variableパラメータの参照に使用します)
FlexibleField
FlexibleField関連クラスを使用すると、固定値の指定やパラメータ参照もしくはデータフローからの入力を切り替えて参照できます。
スクリプト例
|
|
このスクリプトをArborFSMのステートに追加すると以下のようになります。
フィールド右端にある
ボタンをクリックすると参照方法が変更できます。
「Parameter」に変更することで、ParameterReferenceと同じように参照できるようになります。
FlexibleField関連クラス
- FlexibleInt
- FlexibleFloat
- FlexibleBool
- FlexibleGameObject
- FlexibleString
- FlexibleVector2
- FlexibleVector3
- FlexibleQuaternion
- FlexibleRect
- FlexibleBounds
- FlexibleColor
- FlexibleTransform
- FlexibleRectTransform
- FlexibleRigidbody
- FlexibleRigidbody2D
- FlexibleComponent
- FlexibleLong
- FlexibleField
(Variableパラメータの参照に使用します)
参照する型の制約
AnyParameterReferenceやComponentParameterReferenceは属性を指定することで、参照する型を制約することができます。
スクリプト例
|
|
スクリプトを追加した例
ParameterContainer例
使用できる属性
| クラス | 属性 |
|---|---|
| AnyParameterReference | ClassTypeConstraintAttributeから派生したクラス SlotTypeAttribute |
| ComponentParameterReference | ClassTypeConstraintAttributeから派生したクラス SlotTypeAttribute 指定の他、Componentクラスに制約される。 |
| FlexibleComponent | ClassTypeConstraintAttributeから派生したクラス SlotTypeAttribute 指定の他、Componentクラスに制約される。 |
GlobalParameterContainerについて
GlobalParameterContainerはシーンを変更しても保持しておきたいパラメータがある場合に使用するコンポーネントです。
GlobalParameterContainerの追加
- 適用したいGameObjectを選択。 「メニュー > Component > Arbor > GlobalParameterContainer」を選択 。
- あるいはInspectorの「Add Componentボタン > Arbor > GlobalParameterContainer」を選択。
- また、HierarchyのCreateボタン「Arbor > GlobalParameterContainer」からGlobalParameterContainerがアタッチされた状態のGameObjectが作成できる。
GlobalParameterContainerの設定
- あらかじめシーン間で共有したいパラメータを設定したParameterContainerを作成し、Prefab化。
- GlobalParameterContainerが追加されているGameObjectを選択。
InspectorのPrefabに作成しておいたParameterContainerのPrefabを指定。
GlobalParameterContainer経由でパラメータを参照
ParameterReferenceのContainerフィールドにGlobalParameterContainerを指定するとパラメータが参照できるようになります。
関連する組み込みスクリプト
ここでは主にParameterContainerを参照する組み込みスクリプトを一部紹介します。
StateBehaviour
| スクリプト | 説明 |
|---|---|
| CalcParameter | Parameterの値を演算して変更する。 |
| SetBoolParameterFromUIToggle | Toggleの値をParameterに設定する。 |
| SetFloatParameterFromUISlider | Sliderの値をParameterに設定する。 |
| ParameterTransition | Parameterの値を判定して遷移する。 |
Decorator
| スクリプト | 説明 |
|---|---|
| ParameterCheck | Parameterのチェック |
| ParameterConditionalLoop | Parameterの条件によるループ。 |
他にも、FlexibleFieldを使用して値を取得する組み込みスクリプトが多数ありますのでリファレンスを参照してみてください。