Преглед на файлове

fix for huds on instances

Nicolas Cannasse преди 4 години
родител
ревизия
146292325b
променени са 1 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 7 3
      hrt/prefab/Object3D.hx

+ 7 - 3
hrt/prefab/Object3D.hx

@@ -212,8 +212,11 @@ class Object3D extends Prefab {
 						}
 						}
 						if( t.file != null ) {
 						if( t.file != null ) {
 							var t : cdb.Types.TilePos = t;
 							var t : cdb.Types.TilePos = t;
-							var bmp = cast(obj.getChildAt(0), h2d.Bitmap);
-							if( bmp == null ) bmp = new h2d.Bitmap(null, obj);
+							var bmp = Std.downcast(obj.getObjectByName("$huds"), h2d.Bitmap);
+							if( bmp == null ) {
+								bmp = new h2d.Bitmap(null, obj);
+								bmp.name = "$huds";
+							}
 							bmp.tile = h2d.Tile.fromTexture(ctx.loadTexture(t.file)).sub(
 							bmp.tile = h2d.Tile.fromTexture(ctx.loadTexture(t.file)).sub(
 								t.x * t.size,
 								t.x * t.size,
 								t.y * t.size,
 								t.y * t.size,
@@ -221,9 +224,10 @@ class Object3D extends Prefab {
 								(t.height == null ? 1 : t.height) * t.size
 								(t.height == null ? 1 : t.height) * t.size
 							);
 							);
 						} else {
 						} else {
-							var f = cast(obj.getChildAt(0), h2d.Flow);
+							var f = Std.downcast(obj.getObjectByName("$huds_f"), h2d.Flow);
 							if( f == null ) {
 							if( f == null ) {
 								f = new h2d.Flow(obj);
 								f = new h2d.Flow(obj);
+								f.name = "$huds_f";
 								f.padding = 3;
 								f.padding = 3;
 								f.paddingTop = 1;
 								f.paddingTop = 1;
 								f.backgroundTile = h2d.Tile.fromColor(0,1,1,0.5);
 								f.backgroundTile = h2d.Tile.fromColor(0,1,1,0.5);