I am trying to scale up an object without scaling it's children. The original scale vectors for both parent and children are (1, 1, 1). The parent is named and tagged differently than the children, but all children are named and tagged the same.
This code works to scale everything (including children) up:
var largeSize : float; // exposed in inspector
function ScaleUp ()
{
var velocity = Vector3.zero;
var targetScale = Vector3(largeSize, largeSize, largeSize);
while (transform.localScale != targetScale)
{
transform.localScale = Vector3.SmoothDamp(transform.localScale, targetScale, velocity, 0.5);
yield;
}
}
But I don't want everything scaled up, so I tried to differentiate the children and offset the scaling by scaling them back down. Since `for (var child : Transform in transform)` does include the parent transform, I tried to differentiate the children by name or by tag, as follows:
function ScaleUp ()
{
var velocity = Vector3.zero;
var targetScale = Vector3(largeSize, largeSize, largeSize);
var childScale = Vector3(largeSize/2, largeSize/2, largeSize/2);
while (transform.localScale != targetScale)
{
transform.localScale = Vector3.SmoothDamp(transform.localScale, targetScale, velocity, 0.5);
for (var child : Transform in transform)
{
if (child.gameObject.tag == "ChildSpecificTag")
child.localScale = Vector3.SmoothDamp(child.localScale, childScale, velocity, 0.5);
}
yield;
}
}
This... apparently works, but also catches the parent transform in an if statement it shouldn't be caught in? The result of this code is that no scaling occurs, everything stays the same as it was. But the parent is definitely tagged differently than the children. And also named differently, and the same thing happens (no scaling - or, everything is scaled up and immediately scaled back down) if the if statement is: `if (child.gameObject.name != this.gameObject.name)`
How can I apply scaling to the parent without scaling the children, or, how can I effectively differentiate the children to offset the scaling?
ETA: I have not tried `GetComponent(s)InChildren` because that apparently also returns the same component in the parent, and if the parent can evade an if statement designed to weed it out when returned through `Transform in transform`, will it be any different using `GetComponent(s)InChildren`?