Created
March 20, 2015 18:14
-
-
Save andykorth/375f9d699e33e71f6718 to your computer and use it in GitHub Desktop.
Move a parent to where the children are
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[MenuItem("Selection/Center on first child", false, 301)] | |
static void Center() { | |
Object[] objs = Selection.GetFiltered(typeof(GameObject), SelectionMode.Editable | SelectionMode.ExcludePrefab); | |
foreach (GameObject go in objs){ | |
Transform child = go.transform.GetChild(0); | |
Vector3 childPos = child.position; | |
Vector3 childChange = childPos - go.transform.position; | |
go.transform.position = child.position; | |
foreach (Transform chld in go.transform) { | |
chld.position -= childChange; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment