# Parameter Reference

## ParameterReference

By declaring the ParameterReference association class in the field, you can refer to the parameter.

### Example script

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    using UnityEngine;
    using Arbor;

    public class TestParameterReference : MonoBehaviour
    {
    	public IntParameterReference intParameter;

    	void Start ()
    	{
    		if (intParameter.parameter != null)
    		{
    			Debug.Log(intParameter.parameter.name + " : " + intParameter.parameter.intValue);
    		}
    	}
    }

When you add this script to GameObject, it becomes as follows.

Field Name | Description
--- | ---
Container | Reference ParameterContainer By clicking button you can select Constant or DataSlot.
Parameter | Parameters to be referred to When Container type is DataSlot, name designation by character string.

For the getted Parameter, refer to the script reference.

Script Reference : Parameter

### ParameterReference related class

- IntParameterReference
- FloatParameterReference
- BoolParameterReference
- GameObjectParameterReference
- StringParameterReference
- Vector2ParameterReference
- Vector3ParameterReference
- QuaternionParameterReference
- RectParameterReference
- BoundsParameterReference
- ColorParameterReference
- TransformParameterReference
- RectTransformParameterReference
- RigidbodyParameterReference
- Rigidbody2DParameterReference
- ComponentParameterReference
- LongParameterReference
- AnyParameterReference
  (Used to refer to Variable parameter)

## FlexibleField

Using the FlexibleField association class, you can select and reference constant values, parameter reference, or data flow input.

### Example script

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    using UnityEngine;
    using Arbor;

    [AddComponentMenu("")]
    public class TestFlexibleFieldBehaviour : StateBehaviour
    {
    	public FlexibleInt flexibleInt;

    	public override void OnStateBegin()
    	{
    		Debug.Log("flexibleInt : " + flexibleInt.value);
    	}
    }

When this script is added to the state of ArborFSM, it becomes as follows.

You can change the reference method by clicking the button at the right end of the field.

By selecting “Parameter”, you can refer to it like Parameter Reference.

### FlexibleField related class

- FlexibleInt
- FlexibleFloat
- FlexibleBool
- FlexibleGameObject
- FlexibleString
- FlexibleEnumAny
- FlexibleVector2
- FlexibleVector3
- FlexibleQuaternion
- FlexibleRect
- FlexibleBounds
- FlexibleColor
- FlexibleTransform
- FlexibleRectTransform
- FlexibleRigidbody
- FlexibleRigidbody2D
- FlexibleComponent
- FlexibleLong
- FlexibleField
  (Used to refer to Variable parameter)

## Type of constraints that reference

AnyParameterReference and ComponentParameterReference can constrain referencing types by specifying attributes.

### Example script

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    using UnityEngine;
    using Arbor;

    [AddComponentMenu("")]
    public class TestConstraintReferenceBehaviour : StateBehaviour
    {
    	[ClassExtends(typeof(AudioSource))]
    	public ComponentParameterReference audioSource = new ComponentParameterReference();

    	[ClassExtends(typeof(AudioSourceCurveType))]
    	public AnyParameterReference audioSourceCurveType = new AnyParameterReference();

    	public FlexibleAnimationCurve curve = new FlexibleAnimationCurve(AnimationCurve.Linear(0, 0, 1, 1));

    	// Use this for enter state
    	public override void OnStateBegin()
    	{
    		AudioSource source_ = null;
    		Parameter audioSourceParameter = audioSource.parameter;
    		if (audioSourceParameter != null)
    		{
    			source_ = audioSourceParameter.objectReferenceValue as AudioSource;
    		}

    		AudioSourceCurveType curveType_ = AudioSourceCurveType.CustomRolloff;
    		Parameter curveTypeParameter = audioSourceCurveType.parameter;
    		if (curveTypeParameter != null)
    		{
    			curveTypeParameter.GetVariable<AudioSourceCurveType>(ref curveType_);
    		}

    		AnimationCurve curve_ = curve.value;

    		if (source_ == null)
    		{
    			return;
    		}

    		source_.SetCustomCurve(curveType_, curve_);
    	}
    }

Example of adding a script

Example ParameterContainer

(AudioSourceCurveType created Variable and registered it)

### Available Attributes

Class | Attributes
--- | ---
AnyParameterReference | Class derived from ClassTypeConstraintAttribute SlotTypeAttribute
ComponentParameterReference | Class derived from ClassTypeConstraintAttribute SlotTypeAttribute It is also constrained to the Component class.
FlexibleComponent | Class derived from ClassTypeConstraintAttribute SlotTypeAttribute It is also constrained to the Component class.