x


Renaming an Instantiated Prefab in C#

Hi there, Uniters, im currently working on a tile based building game, I thought the building would be simple, but i cant find a smart way of doing this.

Say, i have Instantiated a prefab at an position, and when i click the clone, another prefab is instantiated right above it(a relative position).

I have an array assigning all the positions. Instantiate lines reads it.

I cant just go : Instantiate(block, new Vector3(block.position.x,block.position.y+10,block.position.z),Quaternion.identity)

As it is now, all the clones are called the same thing, can i rename them, or are there a simpler, smarter solution?

I would prefer any code answers in C#, if possible.

Thanks for reading.

Gravn

[Not a minecraft clone]

more ▼

asked Apr 06 '12 at 12:22 AM

Gravn gravatar image

Gravn
62 3 6 8

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest
var clone =  Instantiate(block, new Vector3(block.position.x,block.position.y+10,block.position.z),Quaternion.identity);
clone.name = "new name";
more ▼

answered Apr 06 '12 at 12:23 AM

DaveA gravatar image

DaveA
26.4k 151 171 256

I feel so dumb right now...haha woops

thanks a lot for the quick answer

Gravn

Apr 06 '12 at 01:54 AM Gravn
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1670

asked: Apr 06 '12 at 12:22 AM

Seen: 524 times

Last Updated: Apr 06 '12 at 01:58 AM