48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
public class ParentChildSelectionTool : EditorWindow
|
|
{
|
|
[MenuItem("Tools/Select Parent %q")] // Q 키 (Ctrl/Command+Q)로 상위 오브젝트 선택
|
|
private static void SelectParent()
|
|
{
|
|
if (Selection.activeGameObject != null)
|
|
{
|
|
Transform selectedTransform = Selection.activeGameObject.transform;
|
|
if (selectedTransform.parent != null)
|
|
{
|
|
Selection.activeGameObject = selectedTransform.parent.gameObject;
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("No parent object found.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("No object selected.");
|
|
}
|
|
}
|
|
|
|
[MenuItem("Tools/Select Child %a")] // A 키 (Ctrl/Command+A)로 하위 오브젝트 선택
|
|
private static void SelectChild()
|
|
{
|
|
if (Selection.activeGameObject != null)
|
|
{
|
|
Transform selectedTransform = Selection.activeGameObject.transform;
|
|
if (selectedTransform.childCount > 0)
|
|
{
|
|
Selection.activeGameObject = selectedTransform.GetChild(0).gameObject;
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("No child object found.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("No object selected.");
|
|
}
|
|
}
|
|
}
|