On add component unity

C#
void Reset()
{
  //Your code here
}
Source

Also in C#: