Type constraints of slots

For some slots, you can use attributes to constrain the connectable types.

Example script

Create TestConstraintSlotBehaviour script file and write the following code.

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

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

	[ClassExtends(typeof(AudioClip))]
	public InputSlotUnityObject audioClip = new InputSlotUnityObject();

	public override void OnStateBegin()
	{
		AudioSource source_ = audioSource.GetValue<AudioSource>();
		if (source_ != null)
		{
			source_.clip = audioClip.GetValue<AudioClip>();
		}
	}
}

Available Attributes

Class Attribute
OutputSlotAny SlotTypeAttribute
InputSlotAny Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
InputSlotComponent Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
It is also constrained to the Component class.
InputSlotUnityObject Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
It is also constrained to the UnityEngine.Object class.
FlexibleComponent Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
It is also constrained to the Component class.