- Home /
moving child objects in hierarchy and keep stacks/sorting? Help needed
Hello, so I really need help with this one. How I move all child objects from "fem1" to "character" and keep stacks,
my script does it like this(3rd pic) and 2 pic is how it should be.. :(
https://gyazo.com/13234bfcb44fb06f46ebcdda1fb9f36e
script:
#pragma strict
//This script must be attached to clothing or body and functions can be used by UI buttons
var selected : boolean;
private var newParent : GameObject;
private var parentOBJ : Transform;
function Start () {
newParent = GameObject.Find("character");
parentOBJ = transform.parent;
}
function Update () {
var renderers = GetComponentsInChildren(Renderer);
var transforms = GetComponentsInChildren(Transform);
if (selected)
{
gameObject.tag = "active";
for (var r : Renderer in renderers) { r.enabled = true; }
for (var child : Transform in transforms) { child.transform.parent = newParent.transform; }
}
else
{
gameObject.tag = "de_active";
for (var r : Renderer in renderers) { r.enabled = false; }
this.transform.parent = parentOBJ.transform;
}
}
function MAKE_OBJ_ACTIVE ()
{
selected = !selected;
}
Comment