Change name of Instantiate prefab

Dear unity community,

I am trying to give my newly generated prefab’s a unique name, they are generated on a collision and the code is placed between a OnCollisionEnter2D, the script is attached to my player,

I tried adding transform.name = ("New Name); after the last ; of the following code, but that just changes the name of my player. Here’s the original code:

Instantiate (prefeb [prefeb_num], teleport [tele_num].position = new Vector2 (XPosition, YPosition), teleport [tele_num].rotation);

I want the names to be something like, Prefab1, prefab2, prefab3 and so on…

I found this, (Change Name Of Prefab That Initiates - Unity Answers) , but it doesn’t seem to work for me. Could somebody help me?

Thanks in advance,

Marijn

Answered my own question haha! For others looking for this, just add var objName and then transform name.

Like this:

var newPrefab = Instantiate (prefeb [prefeb_num], teleport [tele_num].position = new Vector2 (XPosition, YPosition), teleport [tele_num].rotation);
		newPrefab.name = ("prefabName");

From here on you can create an int that does +1 every time it is used. Hope this helps!