2
0
Nicolas Cannasse 7 жил өмнө
parent
commit
7b5e923010

+ 2 - 0
hide/prefab/Context.hx

@@ -4,6 +4,7 @@ class ContextShared {
 	public var root2d : h2d.Sprite;
 	public var root3d : h3d.scene.Object;
 	public var contexts : Map<Prefab,Context>;
+	public var cleanups : Array<Void->Void>;
 	var cache : h3d.prim.ModelCache;
 
 	public function new() {
@@ -11,6 +12,7 @@ class ContextShared {
 		root3d = new h3d.scene.Object();
 		contexts = new Map();
 		cache = new h3d.prim.ModelCache();
+		cleanups = [];
 	}
 
 }

+ 3 - 0
hide/view/Prefab.hx

@@ -57,8 +57,11 @@ class Prefab extends FileView {
 		var sh = context.shared;
 		sh.root2d.remove();
 		sh.root3d.remove();
+		for( f in sh.cleanups )
+			f();
 		sh.root2d = new h2d.Sprite();
 		sh.root3d = new h3d.scene.Object();
+		sh.cleanups = [];
 		context.init();
 		data.makeInstance(context);
 		scene.s2d.addChild(sh.root2d);