浏览代码

hot reload : fix hot reload for textures & hmd

lviguier 1 年之前
父节点
当前提交
acafbd7268
共有 2 个文件被更改,包括 16 次插入1 次删除
  1. 1 0
      hxd/fs/FileEntry.hx
  2. 15 1
      hxd/fs/LocalFileSystem.hx

+ 1 - 0
hxd/fs/FileEntry.hx

@@ -9,6 +9,7 @@ class FileEntry {
 	public var size(get, never) : Int;
 	public var isDirectory(get, never) : Bool;
 	public var isAvailable(get, never) : Bool;
+	var watchOnChangedHistory : Array<Null<Void -> Void>>;
 
 	public function getBytes() : haxe.io.Bytes return null;
 	public function readBytes( out : haxe.io.Bytes, outPos : Int, pos : Int, len : Int ) : Int { throw "readBytes() not implemented"; }

+ 15 - 1
hxd/fs/LocalFileSystem.hx

@@ -217,7 +217,21 @@ class LocalEntry extends FileEntry {
 		#else
 		watchTime = getModifTime();
 		#end
-		watchCallback = function() { fs.convert.run(this); onChanged(); }
+
+		if (watchOnChangedHistory == null)
+			watchOnChangedHistory = new Array<Null<Void -> Void>>();
+
+		watchOnChangedHistory.push(onChanged);
+		watchCallback = function() {
+			fs.convert.run(this);
+
+			var idx = watchOnChangedHistory.length -1;
+			while (idx >= 0) {
+				if (watchOnChangedHistory[idx] != null)
+					watchOnChangedHistory[idx]();
+				idx--;
+			}
+		}
 	}
 
 }