- Home /
Way to scale all assets in a scene
Does anyone know of a component or a way to scale multiple objects in a scene, including hierarchies of objects and objects created externally as well as internally ? It I want to be able to set an arbitrary scale amount, then scale the specified objects and colliders while keeping all the objects in the same relative place.
runtime or edit time? If at runtime, is this a one time event or something that happens through out the game?
Answer by Jessy · Nov 27, 2013 at 10:58 PM
Vector3 center, scale;
foreach ( var root in FindObjectsOfType<Transform>().Where(t => t == t.root) )
{
root.position = Vector3.Scale(root.position - center, scale) + center;
root.localScale = Vector3.Scale(root.localScale, scale);
}
Your answer
Follow this Question
Related Questions
Is there a way to detect "On Component Attach" and "On Component Remove"?? 2 Answers
Targeting parts of a Prefab more than 1 level down? 1 Answer
How to add a script to an imported object 2 Answers
Custom Inspector, Access built-in component icons? 2 Answers
Finding a component of an editor-defined type and setting an editor-defined value 1 Answer