generating unique names for prefabs within an array

Hi there,

I'm currently having some trouble creating unique names for my prefabs.

I have instantiated all my prefabs within an array.

Below is the code that I have used to Instantiate my prefabs.

I'm trying to build a scene using different types of tiles.

So what your seeing are a combination of neutral tiles and tiles that have arrows on them.

for (var j: int = 0; j < tileArrayList*.Count; j++){*
 _if (tileArrayList*[j] == 0) {*_
 _*//tile appears*_
 _*//Debug.Log("Start instantiating tiles");*_
 _*//newTile=Instantiate (tileEmpty,Vector3(tilePosX,0,tilePosZ), Quaternion(0,0,0,0));*_
 _*//newTile.name="TileEmpty";*_
 <em>_} else if (tileArrayList*[j] == 1) {*_</em>
 <em>_*//tile appears*_</em>
 <em>_*newTile=Instantiate (tileNeutral,Vector3(tilePosX,0,tilePosZ), Quaternion(0,0,0,0));*_</em>
 <em>_*newTile.name="TileNeutral";*_</em>
 <em><em><em>} else if (tileArrayList<em>[j] == 2 || tileArrayList<em>[j] == 3 || tileArrayList_[j] == 4 || tileArrayList*[j] == 5 ) {*_</em></em></em></em></em>
 <em><em><em><em><em>_*newTile=Instantiate (tileSingle,Vector3(tilePosX,0,tilePosZ), Quaternion(0,0,0,0));*_</em></em></em></em></em>
 <em><em><em><em><em><em>_if(tileArrayList*[j] == 2){*_</em></em></em></em></em></em>
 <em><em><em><em><em><em>_*newTile.name="TileSingleUp";*_</em></em></em></em></em></em>
 <em><em><em><em><em><em><em>_}else if(tileArrayList*[j] == 3){*_</em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em>_*newTile.name="TileSingleDown";*_</em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em>_*newTile.transform.eulerAngles.y-=90;*_</em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em>_}else if(tileArrayList*[j] == 4){*_</em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em>_*newTile.name="TileSingleLeft";*_</em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em>_*newTile.transform.eulerAngles.y-=180;*_</em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em><em>_}else if(tileArrayList*[j] == 5){*_</em></em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em><em>_*newTile.name="TileSingleRight";*_</em></em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em><em>_*newTile.transform.eulerAngles.y-=270;*_</em></em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em><em>_*}*_</em></em></em></em></em></em></em></em></em>
 <em><em><em><em><em><em><em><em><em>_*}*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*```*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p>Below is how the tiles are layed out after previewing in the game mode</p>*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p><a href="http://www.freeimagehosting.net/image.php?76bc922e1a.jpg" rel="nofollow">Array Image Preview</a></p>*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p>What will happen here is that our robot will walk on to the tile that is pointing to the right and the tile will move to the right.</p>*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p>Now the problem that we're encountering here is that if we walk on the next arrowed tile, the first arrowed tile will still continue to move and that isn't what I want.</p>*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p>There is a post here in answer unity3d that has a similar problem*_</em></em></em></em></em></em></em></em></em> 
<em><em><em><em><em><em><em><em><em>_*<a href="http://answers.unity3d.com/questions/8885/affecting-only-one-prefab-in-code-script" rel="nofollow">http://answers.unity3d.com/questions/8885/affecting-only-one-prefab-in-code-script</a></p>*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p>and the solution was to use something called GenerateUniquename();</p>*_</em></em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_*<p>but I can't seem to find any reference on this term.</p>*_</em></em></em></em></em></em></em></em></em>

As a general rule, you can always use System.Guid (MSDN documentation) and append your names with a unique value using the Guid's ToString() method. I use this a lot when I need to uniquely identify resources at run time. These will not be very human readable.

I don't think the function mentioned in that other answer actually exists--I think it was just meant as an example. If you just want unique names, you could just append the index you're using, e.g.

newTile.name = "TileSingleRight_" + i + "_" + j;

It may even help when you're debugging.