You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/Tools/HierarchyFolder.cs

35 lines
1.0 KiB
C#

using UnityEngine;
using D2D.Utilities;
using UnityEditor;
namespace D2D
{
public class HierarchyFolder : SmartScript
{
[SerializeField] private bool _forceToClose = true;
#if UNITY_EDITOR
private void OnDrawGizmos()
{
return;
if (Selection.activeGameObject == null || Selection.activeGameObject.transform.parent == null || !_forceToClose)
return;
var folder = Selection.activeGameObject.GetComponentInParent<HierarchyFolder>();
if (folder != null)
{
Selection.activeGameObject = folder.gameObject;
EditorApplication.ExecuteMenuItem("GameObject/Collapse All");
// EditorGUIUtility.PingObject(folder.gameObject);
}
/*var selection = Selection.GetFiltered(typeof(GameObject), SelectionMode.TopLevel);
foreach(var go in selection)
Collapse(go, true);*/
}
#endif
}
}