Esempio n. 1
0
        private void DragBeginAction(DragEventArgs e)
        {
            DataObject data         = e.Data as DataObject;
            var        dragObjQuery = new ConvertOperation(data, ConvertOperation.Operation.All).Perform <GameObject>();

            if (dragObjQuery != null)
            {
                List <GameObject> dragObj = dragObjQuery.ToList();

                bool    lockZ      = this.CameraComponent.FocusDist <= 0.0f;
                Point   mouseLoc   = this.PointToClient(new Point(e.X, e.Y));
                Vector3 spaceCoord = this.GetSpaceCoord(new Vector3(
                                                            mouseLoc.X,
                                                            mouseLoc.Y,
                                                            lockZ ? 0.0f : this.CameraObj.Transform.Pos.Z + MathF.Abs(this.CameraComponent.FocusDist)));

                // Setup GameObjects
                CreateGameObjectAction      createAction = new CreateGameObjectAction(null, dragObj);
                DropGameObjectInSceneAction dropAction   = new DropGameObjectInSceneAction(dragObj, spaceCoord, this.CameraObj.Transform.Angle);
                UndoRedoManager.BeginMacro(dropAction.Name);
                UndoRedoManager.Do(createAction);
                UndoRedoManager.Do(dropAction);

                // Select them & begin action
                this.selBeforeDrag = DualityEditorApp.Selection;
                this.SelectObjects(createAction.Result.Select(g => new SelGameObj(g) as SelObj));
                this.BeginAction(ObjectAction.Move);

                // Get focused
                this.Focus();

                e.Effect = e.AllowedEffect;
            }
        }
Esempio n. 2
0
 public override void Perform(Prefab prefab)
 {
     try
     {
         CreateGameObjectAction undoRedoAction = new CreateGameObjectAction(null, prefab.Instantiate());
         UndoRedoManager.Do(undoRedoAction);
         DualityEditorApp.Select(this, new ObjectSelection(undoRedoAction.Result));
     }
     catch (Exception exception)
     {
         Log.Editor.WriteError("An error occurred instanciating Prefab {1}: {0}",
                               Log.Exception(exception),
                               prefab != null ? prefab.Path : "null");
     }
 }