Last active
August 29, 2015 14:14
-
-
Save CheapDevotion/4e5296cd3e010d644931 to your computer and use it in GitHub Desktop.
A UnityEditor script that provides a hotkey for quickly grouping GameObjects.
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
using UnityEngine; | |
using System.Collections; | |
using UnityEditor; | |
public class ParentSelection : ScriptableObject { | |
[MenuItem("OffTheGrid/Group Objects %g")] | |
static void GroupObjects() | |
{ | |
GameObject[] objects = Selection.gameObjects; | |
GameObject parentObject = new GameObject("Grouped Objects"); | |
Undo.RegisterCreatedObjectUndo(parentObject, "Grouped Objects"); | |
foreach (GameObject ob in objects) | |
{ | |
Undo.SetTransformParent(ob.transform, parentObject.transform, ob.name + " Parent"); | |
} | |
Selection.activeGameObject = parentObject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment