소스 검색

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 ) {