浏览代码

Fix duplicate crash and gizmo freeze on duplicate (#180)

Duplicating while moving the gizmo would raise lock the gizmo for the
scene, and duplicating too quickly would raise an error.
Leonardo Jeanteur 4 年之前
父节点
当前提交
e18750cbf9
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      hide/comp/SceneEditor.hx

+ 9 - 1
hide/comp/SceneEditor.hx

@@ -490,7 +490,7 @@ class SceneEditor {
 			var actionItems : Array<hide.comp.ContextMenu.ContextMenuItem> = [
 				{ label : "Rename", enabled : current != null, click : function() tree.editNode(current), keys : view.config.get("key.rename") },
 				{ label : "Delete", enabled : current != null, click : function() deleteElements(curEdit.rootElements), keys : view.config.get("key.delete") },
-				{ label : "Duplicate", enabled : current != null, click : duplicate.bind(false), keys : view.config.get("key.duplicate") },
+				{ label : "Duplicate", enabled : current != null, click : duplicate.bind(false), keys : view.config.get("key.duplicateInPlace") },
 			];
 
 			var isObj = current != null && (current.to(Object3D) != null || current.to(Object2D) != null);
@@ -1912,11 +1912,18 @@ class SceneEditor {
 		setVisible(toHide, false);
 	}
 
+	var isDuplicating = false;
 	function duplicate(thenMove: Bool) {
 		if(curEdit == null) return;
 		var elements = curEdit.rootElements;
 		if(elements == null || elements.length == 0)
 			return;
+		if( isDuplicating )
+			return;
+		isDuplicating = true;
+		if( gizmo.moving ) {
+			@:privateAccess gizmo.finishMove();
+		}
 		var undoes = [];
 		var newElements = [];
 		for(elt in elements) {
@@ -1944,6 +1951,7 @@ class SceneEditor {
 					refreshProps();
 				}
 			}
+			isDuplicating = false;
 		});
 
 		undo.change(Custom(function(undo) {