/// <inheritdoc />
        public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
        {
            var result = base.OnDragEnter(ref location, data);

            if (result != DragDropEffect.None)
            {
                return(result);
            }

            // Check if drop file(s)
            if (data is DragDataFiles)
            {
                _validDragOver = true;
                return(DragDropEffect.Copy);
            }

            // Check if drop actor(s)
            if (_dragActors == null)
            {
                _dragActors = new DragActors(ValidateDragActors);
            }
            if (_dragActors.OnDragEnter(data))
            {
                _validDragOver = true;
                return(DragDropEffect.Move);
            }

            return(DragDropEffect.None);
        }
Example #2
0
        /// <inheritdoc />
        protected override void DoDragDrop()
        {
            DragData data;
            var      tree = ParentTree;

            // Check if this node is selected
            if (tree.Selection.Contains(this))
            {
                // Get selected actors
                var actors = new List <ActorNode>();
                for (var i = 0; i < tree.Selection.Count; i++)
                {
                    var e = tree.Selection[i];
                    if (e is ActorTreeNode node && node.ActorNode.CanDrag)
                    {
                        actors.Add(node.ActorNode);
                    }
                }
                data = DragActors.GetDragData(actors);
            }
            else
            {
                data = DragActors.GetDragData(ActorNode);
            }

            // Start drag operation
            DoDragDrop(data);
        }
Example #3
0
        /// <inheritdoc />
        protected override DragDropEffect OnDragEnterHeader(DragData data)
        {
            // Check if cannot edit scene or there is no scene loaded (handle case for actors in prefab editor)
            if (_actorNode?.ParentScene != null)
            {
                if (!Editor.Instance.StateMachine.CurrentState.CanEditScene || !Level.IsAnySceneLoaded)
                {
                    return(DragDropEffect.None);
                }
            }
            else
            {
                if (!Editor.Instance.StateMachine.CurrentState.CanEditContent)
                {
                    return(DragDropEffect.None);
                }
            }

            if (_dragHandlers == null)
            {
                _dragHandlers = new DragHandlers();
            }

            // Check if drop actors
            if (_dragActors == null)
            {
                _dragActors = new DragActors(ValidateDragActor);
                _dragHandlers.Add(_dragActors);
            }
            if (_dragActors.OnDragEnter(data))
            {
                return(_dragActors.Effect);
            }

            // Check if drag assets
            if (_dragAssets == null)
            {
                _dragAssets = new DragAssets(ValidateDragAsset);
                _dragHandlers.Add(_dragAssets);
            }
            if (_dragAssets.OnDragEnter(data))
            {
                return(_dragAssets.Effect);
            }

            // Check if drag actor type
            if (_dragActorType == null)
            {
                _dragActorType = new DragActorType(ValidateDragActorType);
                _dragHandlers.Add(_dragActorType);
            }
            if (_dragActorType.OnDragEnter(data))
            {
                return(_dragActorType.Effect);
            }

            return(DragDropEffect.None);
        }
Example #4
0
        /// <inheritdoc />
        public override void OnDestroy()
        {
            _dragActors    = null;
            _dragAssets    = null;
            _dragActorType = null;
            _dragHandlers?.Clear();
            _dragHandlers = null;
            _highlights   = null;

            base.OnDestroy();
        }
Example #5
0
        /// <inheritdoc />
        protected override DragDropEffect OnDragEnterHeader(DragData data)
        {
            // Check if cannot edit scene or there is no scene loaded
            if (!Editor.Instance.StateMachine.CurrentState.CanEditScene || !SceneManager.IsAnySceneLoaded)
            {
                return(DragDropEffect.None);
            }

            // Check if drop actors
            if (_dragActors == null)
            {
                _dragActors = new DragActors();
            }
            if (_dragActors.OnDragEnter(data, ValidateDragActor))
            {
                return(_dragActors.Effect);
            }

            // Check if drag assets
            if (_dragAssets == null)
            {
                _dragAssets = new DragAssets();
            }
            if (_dragAssets.OnDragEnter(data, ValidateDragAsset))
            {
                return(_dragAssets.Effect);
            }

            // Check if drag actor type
            if (_dragActorType == null)
            {
                _dragActorType = new DragActorType();
            }
            if (_dragActorType.OnDragEnter(data, ValidateDragActorType))
            {
                return(_dragActorType.Effect);
            }

            return(DragDropEffect.None);
        }
 private void ImportActors(DragActors actors, ContentFolder location)
 {
     // Use only the first actor
     Editor.Instance.Prefabs.CreatePrefab(actors.Objects[0].Actor);
 }
Example #7
0
 /// <inheritdoc />
 public VisualScriptSurface(IVisjectSurfaceOwner owner, Action onSave, FlaxEditor.Undo undo)
     : base(owner, onSave, undo, null, null, true)
 {
     _supportsImplicitCastFromObjectToBoolean = true;
     DragHandlers.Add(_dragActors             = new DragActors(ValidateDragActor));
 }