Call function when prefab is collided

Hello, I have a game with a spaceship travelling between 2Dprefabs.
This is the code that generates the prefabs:

Material material = new Material(Shader.Find("Sprites/Default"));
material.SetTexture("_MainTex", textures2D*);*

GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
quad.name = textures2D*.name;*
quad.transform.position = Vector3.zero;
quad.transform.localScale *= 20;

MeshRenderer meshRenderer = quad.GetComponent();
meshRenderer.sharedMaterial = material;
GameObject prefab = PrefabUtility.CreatePrefab(prefabPath + textures2D*.name + “.prefab”, quad, ReplacePrefabOptions.Default);*
I want something to happen when the spaceship is collided with the prefab.
I’ve tried to add a script, with the function : onCollisonEnter, and attach it the the prefab, in the inspector. (I added the script component to the prefab). However, it didn’t work, and the function was not called. I tried to use the function onTriggerEnter but it also didn’t work.
Does someone no what I should do?
All I want is to call a function when the prefab is collided.
Attached a screenshot of the defined prefab.
Thanks!

[78268-prefab.png|78268]

At least one of your object need to have a rigidbody attached for oncollisionEnter to happen