How to execute a script each time I add a certain prefab to the scene?

I want to do a prefab that gets randomized components each time I draw an instance of it into the scene.

The aspect that gives me trouble is the “each time i draw an instance of it into the scene”.
There seems to be some unspecific “dragAndDrop”-event for editor-scripts, but I am not sure if this is the way to go - since I would need it only for prefabs specificly made for that purpose.

Try this

Thank you very much, that helped indeed. I combined this with a view lines awake()-method (the constructor and the start()-method were of no use in this case).

For anybody who has a simular problem, the (essential) code is this:

using UnityEngine;
using System.Collections;


public class RandomAtCreation : MonoBehaviour {

	public string myRandomString;

	void Awake(){
		int myRandomNumber = Random.Range(0,10);
		myRandomString = ("Different number each time: " + myRandomNumber + "!");

Whatever the rest of the script is, it’s parameter “myRandomString” will be randomized each time an object with this script is added to the scene.

(I guess the strings will be randomized again when start the game. I will include a boolean switch to prevent that.)

Very simple - no drag’n drop was needed after all. Thank’s a lot!