Repository: FlaxEngine/FlaxEngine
File: Source/Editor/Viewport/MainEditorGizmoViewport.cs (C#)

Code before:
                            var controlParent = control.Parent;
                            while (controlParent != null && controlParent is not Scene)
                            {
                                if (controlParent is UICanvas uiCanvas)
                                {
                                    canvas = uiCanvas;
                                    break;
                                }
                                controlParent = controlParent.Parent;
                            }

                            if (canvas != null)
                            {
                                if (canvas.Is2D)
                                    continue;
                            }
                        }
                        else if (a is UICanvas uiCanvas)
                        {
                            if (uiCanvas.Is2D)
                                continue;
                        }

                        var containsAllPoints = true;
                        var fallBackToBox = false;
                        if (a is StaticModel sm)
                        {
                            if (sm.Model)
                            {
                                var m = sm.Model.LODs[0];
                                foreach (var mesh in m.Meshes)
                                {
                                    var points = mesh.GetCollisionProxyPoints();
                                    if (points.Length == 0)
                                    {
                                        fallBackToBox = true;
                                        break;
                                    }
                                    foreach (var point in points)
                                    {
                                        Viewport.ProjectPoint(a.Transform.LocalToWorld(point), out var loc);
                                        if (!adjustedRect.Contains(loc))
                                        {
                                            containsAllPoints = false;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else

Review comment (suggestion):
A little documentation comment would help to understand why we do this mesh-specific code. Also, it would be nice to make it virtual call to `SceneGraphNode` so other models could implement or customize it in future.

Code after:
            }

            return false;
        }

        private static bool ValidateDragActorType(ScriptType actorType)
        {
            return Level.IsAnySceneLoaded && Editor.Instance.CodeEditing.Actors.Get().Contains(actorType);
        }

        private static bool ValidateDragScriptItem(ScriptItem script)
        {
            return Level.IsAnySceneLoaded && Editor.Instance.CodeEditing.Actors.Get(script) != ScriptType.Null;
        }

        /// <inheritdoc />
        public override DragDropEffect OnDragMove(ref Float2 location, DragData data)
        {
            DragHandlers.ClearDragEffects();
            var result = base.OnDragMove(ref location, data);
            if (result != DragDropEffect.None)
                return result;
            return DragHandlers.DragEnter(ref location, data);
        }

        /// <inheritdoc />
        public override void OnDragLeave()
        {
            DragHandlers.ClearDragEffects();
            DragHandlers.OnDragLeave();
            base.OnDragLeave();
        }

        /// <inheritdoc />
        public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)
        {
            DragHandlers.ClearDragEffects();
            var result = base.OnDragDrop(ref location, data);
            if (result != DragDropEffect.None)
                return result;
            return DragHandlers.DragDrop(ref location, data);
        }

        /// <inheritdoc />
        public override void Select(List<SceneGraphNode> nodes)
        {
            _editor.SceneEditing.Select(nodes);
        }

        /// <inheritdoc />
        public override void Spawn(Actor actor)