Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEngine;
- public class GroupingTool : MonoBehaviour
- {
- private const string parentName = "New Parent";
- [MenuItem("Tools/Group Objects %g")]
- private static void GroupObjects()
- {
- GameObject newParent = new GameObject(parentName);
- GameObject[] selection = Selection.gameObjects;
- foreach(GameObject go in selection)
- {
- try
- {
- if (go.transform.parent)
- {
- continue;
- }
- go.transform.parent = newParent.transform;
- }
- catch(System.Exception e)
- {
- Debug.LogError(e.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement