modular-avatar/Editor/ScaleAdjuster/SelectionHack.cs
bd_ f7b12d7f82
fix: ScaleAdjuster breaks scene view selection (#718)
... fixed by reimplementing ScaleAdjuster (again!)
2024-03-03 17:26:23 +09:00

28 lines
759 B
C#

using UnityEditor;
namespace nadena.dev.modular_avatar.core.editor.ScaleAdjuster
{
#if !UNITY_2022_3_OR_NEWER
internal static class SelectionHack
{
[InitializeOnLoadMethod]
static void Init()
{
Selection.selectionChanged += OnSelectionChanged;
}
static void OnSelectionChanged()
{
var gameObject = Selection.activeGameObject;
if (gameObject != null && gameObject.GetComponent<ScaleAdjusterRenderer>() != null)
{
EditorApplication.delayCall += () =>
{
Selection.activeGameObject = gameObject.transform.parent.gameObject;
};
}
}
}
#endif
}