Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.