Skip to content

Instantly share code, notes, and snippets.

@CheapDevotion
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheapDevotion/4e5296cd3e010d644931 to your computer and use it in GitHub Desktop.
Save CheapDevotion/4e5296cd3e010d644931 to your computer and use it in GitHub Desktop.
A UnityEditor script that provides a hotkey for quickly grouping GameObjects.
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