Add two components of the same type using RequireComponent attribute

Hi, I’ve been wondering whether is it possible to add two components of the same type in my game object when I add my script to it. I would like to add two edge colliders 2D to my gameObject when I assign my script to this same gameObject. Something like this:

[RequireComponent(typeof(EdgeCollider2D))]
[RequireComponent(typeof(EdgeCollider2D))]
public class Foo
{
   ...
}

I know there is a way of adding these two components via script by using AddComponent, but how about adding at the moment I assign my script?

You could use the Reset() method from MonoBehaviour. It gets called the first time the script is added to a GameObject and whenever the user selects the ‘Reset’ option from the context menu.

void Reset()
{
	int numColliders = GetComponents<EdgeCollider2D>().Length;
	for (int i = 0; i < 2 - numColliders; i++)
		gameObject.AddComponent<EdgeCollider2D>();
}