- Home /
[SOLVED] How can I check what was the last instantiated object?
Hi.
How can I check what object (from variable OR prefab itself) was the last one instantiated? I am trying to instantiate two different objects, in this order: 1st, 2nd, 1st, 2nd,...
I'd suggest and other data structure for that, as you don't know the size. Go for an ArrayList or a List. Could you make it an answer tomekkie2, with my comment if you like ?
I used boolean that is turned on when the first object is instantiated and turns off when the second one is. Thanks for your help anyways.
Or check the sequence the Unity itself is storing the instantiated objects. I mean If you loop through the transforms of instances with the for each loop - possibly they are stored in the creation order.
Answer by tomekkie2 · Jun 18, 2012 at 02:50 PM
Put the instantiated objects into array or ArrayList on instantiating it, so the last one will have the last index in the array.
Your answer
Follow this Question
Related Questions
How to instantiate once when boolean changes 1 Answer
Instantiate prefab wihtout dragging prefab into gameObject script 9 Answers
Shoot 'Em Up: Best way to instantiate enemies 2 Answers
Copy animation process from Animator of an object and paste it on the instantiated object of itself 0 Answers
How to instantly move a newly instantiated prefab? 2 Answers