Skip to content

Instantly share code, notes, and snippets.

@liveasnotes
Last active August 20, 2020 02:10
Show Gist options
  • Select an option

  • Save liveasnotes/1e086f9eb6d3c017760d9181d730ba45 to your computer and use it in GitHub Desktop.

Select an option

Save liveasnotes/1e086f9eb6d3c017760d9181d730ba45 to your computer and use it in GitHub Desktop.
VR4PE_20200223
// (c) 2019 liveasnotes
// https://gist.github.com/liveasnotes/1e086f9eb6d3c017760d9181d730ba45
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// ヒエラルキーウィンドウで、選択したオブジェクト(複数選択可)の直上の親オブジェクトを選択できるスクリプト
/// <summary>
public static class SelectDirectParents
{
[MenuItem("Edit/Select Direct Parents %&z")]
private static void SelectParents()
{
if (Selection.activeGameObject)
{
List<GameObject> targetParents = new List<GameObject>();
foreach (GameObject childrenObj in Selection.objects)
{
targetParents.Add(childrenObj.transform.parent.gameObject);
}
Selection.objects = targetParents.ToArray();
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment