Преглед изворни кода

Allows for shader graph refresh after refreshing a scene.

clementlandrin пре 11 месеци
родитељ
комит
637534f957
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      hrt/prefab/DynamicShader.hx

+ 7 - 1
hrt/prefab/DynamicShader.hx

@@ -78,10 +78,16 @@ class DynamicShader extends Shader {
 			fixSourcePath();
 			if (StringTools.endsWith(source, ".shgraph")) {
 				isShadergraph = true;
-				var shgraph = Std.downcast(hxd.res.Loader.currentInstance.load(source).toPrefab().load(), hrt.shgraph.ShaderGraph);
+				var res = hxd.res.Loader.currentInstance.load(source);
+				var shgraph = Std.downcast(res.toPrefab().load(), hrt.shgraph.ShaderGraph);
 				if (shgraph == null)
 					throw source + " is not a valid shadergraph";
 				shaderDef = shgraph.compile(null);
+				#if !editor
+				res.watch( function() {
+					@:privateAccess hxd.res.Loader.currentInstance.cache.remove(source);
+				});
+				#end
 			}
 			else if( isInstance && !isShadergraph ) {
 				shaderClass = loadShaderClass();