示例#1
0
            /// <inheritdoc />
            public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
            {
                var result = base.OnDragDrop(ref location, data);

                if (result == DragDropEffect.None)
                {
                    // Drag assets
                    if (_dragAssets != null && _dragAssets.HasValidDrag)
                    {
                        for (int i = 0; i < _dragAssets.Objects.Count; i++)
                        {
                            var item  = _dragAssets.Objects[i];
                            var actor = item.OnEditorDrop(this);
                            actor.Name = item.ShortName;
                            _window.Spawn(actor);
                        }
                        result = DragDropEffect.Move;
                    }
                    // Drag actor type
                    else if (_dragActorType != null && _dragActorType.HasValidDrag)
                    {
                        for (int i = 0; i < _dragActorType.Objects.Count; i++)
                        {
                            var item  = _dragActorType.Objects[i];
                            var actor = item.CreateInstance() as Actor;
                            if (actor == null)
                            {
                                Editor.LogWarning("Failed to spawn actor of type " + item.TypeName);
                                continue;
                            }
                            actor.Name = item.Name;
                            _window.Spawn(actor);
                        }
                        result = DragDropEffect.Move;
                    }

                    _dragHandlers.OnDragDrop(null);
                }
                return(result);
            }
示例#2
0
 /// <inheritdoc />
 public override void Spawn(Actor actor, Actor parent)
 {
     _window.Spawn(actor, parent);
 }