Naming Instantiatet prefabs

I’m having some trouble with naming the prefabs I Instantiate. Most of the time it works fine and they get the right name but some of them get added “(Clone)” to the name and sometimes they get named after the variable that holds them.

My code looks like this

	Instantiate(Sun, Vector3 (100, 100, 100), Quaternion.identity);
	Sun.name = "Sun1";
	Sun.GetComponent(PlanetSetup).planetScale = Vector3(50,50,50);
	Sun.GetComponent(PlanetSetup).planetName = "Sun1";

So this prefab can come out named “Sun”, “Sun1” or “Sun1(Clone)”.

Any idea why? (or if some ones a better way to get access to the prefabs afterwards without using the GameObject.Find)

Instantiate() will return an object of the same type as the one you pass in. You need to store a reference to this new object in a variable to modify it.

Try:

yes ofc - that seems to work - thanks