|
Hi I have a variable count that keeps count of the objects i am creating and giving them a name based on it. There is a small bug somewhere that makes it keep the last number it had from the last run of the script, alas it don't reset to 0;
(comments are locked)
|
|
You're setting the name of the prefab rather than the name of the object you just instantiated. Changes to prefabs like this are saved with your project, therefore the next instance created of the prefab (even if it's after you stopped and replayed your app) comes out with the new name. Also it seems as though you're incrementing your 'count' variable twice, in two different ways (using ++count and also count=count+1). You just need one of these. You need to change your code so that you get back the reference to the instance you just created, and rename that. Something like this:
(the last line also shows how you can combine a string and the count number so your objects are named "cube 1", "cube 2" etc)
(comments are locked)
|

So, it remembers
count, is that it? Can you clarify what you mean by "the last run of the script"?