Storing transforms from objects in Array

Hi, I’m just messing around with Arrays in JavaScript in Unity and I had a question I can’t seem to find the answer to.

I have an array of GameObjects that I all move to the same specific position. Now I’m writing a function that returns them to their original position.

How would I store each GameObject’s original position? And how would I call on those positions again?

Thanks in advance!

If you only care about positions, you could just store the transform.position in an array at the same index as the gameobject in your other array and assign that back when resetting the objects. If you need scale and rotation as well, I would probably build some sort of small custom struct to store all the information you need and then save that in the array.

Or if you want it a bit more fancy, you could always attach a small script to the gameobjects that stores the values and then use some sort of custom save() and reset() function that sets and reassigns them.