瀏覽代碼

Merge branch 'master' of https://github.com/HeapsIO/hide

Tom SPIRA 6 年之前
父節點
當前提交
46fa0ed2f0
共有 2 個文件被更改,包括 11 次插入3 次删除
  1. 7 3
      hide/comp/Scene.hx
  2. 4 0
      hrt/prefab/Model.hx

+ 7 - 3
hide/comp/Scene.hx

@@ -395,9 +395,13 @@ class Scene extends Component implements h3d.IDrawable {
 			hxd.res.Any.fromBytes(path, bytes);
 			hxd.res.Any.fromBytes(path, bytes);
 		};
 		};
 		if( onReady == null ) onReady = function(_) {};
 		if( onReady == null ) onReady = function(_) {};
-		t = loadTextureData(res.toImage(), onReady, t);
-		t.name = ide.makeRelative(path);
-		texCache.set(path, t);
+		try {
+			t = loadTextureData(res.toImage(), onReady, t);
+			t.name = ide.makeRelative(path);
+			texCache.set(path, t);
+		} catch( error : Dynamic ) {
+			throw "Could not load texure " + texturePath + ":\n" + Std.string(error);
+		};
 		return t;
 		return t;
 	}
 	}
 
 

+ 4 - 0
hrt/prefab/Model.hx

@@ -27,7 +27,9 @@ class Model extends Object3D {
 		if( source == null)
 		if( source == null)
 			return super.makeInstance(ctx);
 			return super.makeInstance(ctx);
 		ctx = ctx.clone(this);
 		ctx = ctx.clone(this);
+		#if editor
 		try {
 		try {
+		#end
 			var obj = ctx.loadModel(source);
 			var obj = ctx.loadModel(source);
 			if(obj.defaultTransform != null && children.length > 0) {
 			if(obj.defaultTransform != null && children.length > 0) {
 				obj.name = "root";
 				obj.name = "root";
@@ -49,10 +51,12 @@ class Model extends Object3D {
 				obj.playAnimation(ctx.loadAnimation(animation));
 				obj.playAnimation(ctx.loadAnimation(animation));
 
 
 			return ctx;
 			return ctx;
+		#if editor
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
 			e.message = "Could not load model " + source + ": " + e.message;
 			e.message = "Could not load model " + source + ": " + e.message;
 			ctx.shared.onError(e);
 			ctx.shared.onError(e);
 		}
 		}
+		#end
 		ctx.local3d = new h3d.scene.Object(ctx.local3d);
 		ctx.local3d = new h3d.scene.Object(ctx.local3d);
 		ctx.local3d.name = name;
 		ctx.local3d.name = name;
 		updateInstance(ctx);
 		updateInstance(ctx);