Hi,
I have spent most of the day trying to work out how to ‘copy’ the structure/hierarchy of a transform and all it’s children, grandchildren, etc, but to a different class (structure example below).
I have tried recursion but can’t maintain the order. A ‘flat’ list for example is easy to get but I just can’t get it how I need. Here is an example of the simple class structure I am experimenting with:
[Serializable]
public class BasicCopy
{
public string Name;
public List<Transform> Transforms;
}
public List<BasicCopy> Test;
public Transform Target;
void Start()
{
// Iterate through Target and ALL it's children and generate a matching hierarchy/structure using the BasicCopy class
}
The whole process keeps tying me in knots, and is now driving me insane lol! Any help will be much appreciated.
EDIT: I may have worded this badly. For clarity, I am looking to specify my ‘Target’ transform then recursively find all child transforms, as I find them, they are added to my BasicCopy class, maintaining the same hierarchy/structure as the children.