瀏覽代碼

allow to set ContextShared.currentPath by passing res to Context.init

Nicolas Cannasse 5 年之前
父節點
當前提交
70c62a96d2
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 2 2
      hrt/prefab/Context.hx
  2. 2 1
      hrt/prefab/ContextShared.hx

+ 2 - 2
hrt/prefab/Context.hx

@@ -12,9 +12,9 @@ package hrt.prefab;
 	public function new() {
 	}
 
-	public function init() {
+	public function init( ?res : hxd.res.Resource ) {
 		if( shared == null )
-			shared = new ContextShared();
+			shared = new ContextShared(res);
 		local2d = shared.root2d;
 		local3d = shared.root3d;
 	}

+ 2 - 1
hrt/prefab/ContextShared.hx

@@ -19,13 +19,14 @@ class ContextShared {
 	var shaderCache : ShaderDefCache;
 	var bakedData : Map<String, haxe.io.Bytes>;
 
-	public function new() {
+	public function new( ?res : hxd.res.Resource ) {
 		root2d = new h2d.Object();
 		root3d = new h3d.scene.Object();
 		contexts = new Map();
 		references = new Map();
 		cache = new h3d.prim.ModelCache();
 		shaderCache = new ShaderDefCache();
+		if( res != null ) currentPath = res.entry.path;
 	}
 
 	public function onError( e : Dynamic ) {