miepzerino
2025-03-30 d2ab30e7a69bfe7efda63ae75812207377917bd3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using UnityEditor;
using UnityEngine;
 
namespace Flexalon.Editor
{
    [CustomEditor(typeof(FlexalonDragTarget)), CanEditMultipleObjects]
    public class FlexalonDragTargetEditor : FlexalonComponentEditor
    {
        void OnSceneGUI()
        {
            // Draw a box at the transforms position
            var script = target as FlexalonDragTarget;
            var node = Flexalon.GetNode(script.gameObject);
            if (node == null || node.Result == null)
            {
                return;
            }
 
            var r = node.Result;
 
            // Draw hit box for drag target if margin is not zero.
            Handles.color = Color.green;
            var worldBoxScale = node.GetWorldBoxScale(true);
            Handles.matrix = Matrix4x4.TRS(node.GetWorldBoxPosition(worldBoxScale, false), script.transform.rotation, worldBoxScale);
            Handles.DrawWireCube(Vector3.zero, r.AdapterBounds.size + script.Margin * 2);
        }
    }
}