(ref Float2 location, DragData data)
| 475 | |
| 476 | /// <inheritdoc /> |
| 477 | public override DragDropEffect OnDragDrop(ref Float2 location, DragData data) |
| 478 | { |
| 479 | var result = base.OnDragDrop(ref location, data); |
| 480 | if (result == DragDropEffect.None) |
| 481 | { |
| 482 | _isDropping = true; |
| 483 | |
| 484 | // Drag assets |
| 485 | if (_dragAssets != null && _dragAssets.HasValidDrag) |
| 486 | { |
| 487 | List<SceneGraphNode> graphNodes = new List<SceneGraphNode>(); |
| 488 | for (int i = 0; i < _dragAssets.Objects.Count; i++) |
| 489 | { |
| 490 | var item = _dragAssets.Objects[i]; |
| 491 | if (item.IsOfType<SceneAsset>()) |
| 492 | { |
| 493 | Editor.Instance.Scene.OpenScene(item.ID, true); |
| 494 | continue; |
| 495 | } |
| 496 | var actor = item.OnEditorDrop(this); |
| 497 | actor.Name = item.ShortName; |
| 498 | Editor.SceneEditing.Spawn(actor); |
| 499 | var graphNode = Editor.Scene.GetActorNode(actor.ID); |
| 500 | if (graphNode != null) |
| 501 | graphNodes.Add(graphNode); |
| 502 | Editor.Scene.MarkSceneEdited(actor.Scene); |
| 503 | } |
| 504 | if (graphNodes.Count > 0) |
| 505 | Editor.SceneEditing.Select(graphNodes); |
| 506 | result = DragDropEffect.Move; |
| 507 | } |
| 508 | // Drag actor type |
| 509 | else if (_dragActorType != null && _dragActorType.HasValidDrag) |
| 510 | { |
| 511 | for (int i = 0; i < _dragActorType.Objects.Count; i++) |
| 512 | { |
| 513 | var item = _dragActorType.Objects[i]; |
| 514 | var actor = item.CreateInstance() as Actor; |
| 515 | if (actor == null) |
| 516 | { |
| 517 | Editor.LogWarning("Failed to spawn actor of type " + item.TypeName); |
| 518 | continue; |
| 519 | } |
| 520 | actor.Name = item.Name; |
| 521 | Editor.SceneEditing.Spawn(actor); |
| 522 | Editor.Scene.MarkSceneEdited(actor.Scene); |
| 523 | } |
| 524 | result = DragDropEffect.Move; |
| 525 | } |
| 526 | // Drag control type |
| 527 | else if (_dragControlType != null && _dragControlType.HasValidDrag) |
| 528 | { |
| 529 | for (int i = 0; i < _dragControlType.Objects.Count; i++) |
| 530 | { |
| 531 | var item = _dragControlType.Objects[i]; |
| 532 | var control = item.CreateInstance() as Control; |
| 533 | if (control == null) |
| 534 | { |
nothing calls this directly
no test coverage detected