浏览代码

Scene editor: fix undo on group elements, and fix order of elements that were changed when grouped

lviguier 1 年之前
父节点
当前提交
ae272c1493
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      hide/comp/SceneEditor.hx

+ 11 - 5
hide/comp/SceneEditor.hx

@@ -3521,7 +3521,13 @@ class SceneEditor {
 			return;
         }
 
-		var elts = selectedPrefabs;
+		// Sort the selection to match the scene order
+		var elts : Array<hrt.prefab.Prefab> = [];
+		for (p in sceneData.flatten()) {
+			if (selectedPrefabs.contains(p))
+				elts.push(p);
+		}
+
 		var parent = elts[0].parent;
 		var parentMat = worldMat(parent);
 		var invParentMat = parentMat.clone();
@@ -3556,13 +3562,11 @@ class SceneEditor {
 		var effectFunc = reparentImpl(elts, group, 0);
 		undo.change(Custom(function(undo) {
 			if(undo) {
-				group.parent = null;
-				//context.shared.contexts.remove(group);
 				effectFunc(true);
+				group.parent = null;
 			}
 			else {
 				group.parent = parent;
-				//context.shared.contexts.set(group, groupCtx);
 				effectFunc(false);
 			}
 			if(undo)
@@ -4042,8 +4046,8 @@ class SceneEditor {
 				};
 			});
 		}
-		return function(undo) {
 
+		return function(undo) {
 			// Remove all the children from their parent before
 			// adding them back in. Makes the index of insert() correct
 			if (!undo) {
@@ -4051,6 +4055,7 @@ class SceneEditor {
 					elt.parent.children.remove(elt);
 				}
 			}
+
 			for(f in effects) {
 				f(undo);
 			}
@@ -4058,6 +4063,7 @@ class SceneEditor {
 			if (!removeInstance(toElt)) {
 				return true;
 			}
+
 			makePrefab(toElt);
 			return false;
 		}