I've got a very large tileset with over 200 different 64x64 tiles. It would be practical to load them in a C# script, I've tried the following (for-loop):
tileset[x] = Resources.Load<Sprite>("Sprites/Tileset/Tileset_" + x);
Where in my asset folder, Sprites is the folder where Tileset.png is. Tileset.png is sliced in a grid (64x64) in I see Unity has sliced all the tiles correctly.
Is there a way I can load them, and put them in a Sprite array (Sprite[]) in code? What would be the correct path?
Looking for correctness? Then batching is caring...
If loaded individually, each tile will cost you a draw call. I would recommend that you look at creating spritesheets to batch the loading and rendering or these tiles. We have been using TexturePacker to load images for our apps and displaying 200+ images at once with one load call, one draw call and great performance. Alongside the app to create the spritesheets, there's a Unity Plugin on the asset store to load and manage them.
Note: we use the pro version.
Otherwise you can just load all the resources at a given path with Resources.LoadAll
Related
I use Mapbox Tileset API and generated a custom tileset (it's a huge 400MB of GeoJSON data) uploaded to Mapbox servers, and added to our style in the studio as a custom fill layer.
This way I can show our custom areas (as polygons) of the world with green (visited) and red (remaining) locations with using expressions only.
I would like to tell if a point (GPS coordinate) is within a polygon of the tileset source/layer and which one, even if the app is in the background (GPS tracking is running in the background and I would like to notify the user when they are within a polygon).
Using queryRenderedFeatures would be great, but unfortunately, it doesn't work when the app is in the background or the user's position is outside of the current viewport.
Is there any solution to get the list of the features at a GPS coordinate even if it's outside of the viewport?
Another requirement is that, it should work when the device is offline, so the Tilequery API won't help.
Downloading the offline data of our style with a limited zoom range working perfectly, I can see my custom source-layer (polygons) even if the device is offline.
So I think there should be a way to query the tileset-source when the device is offline too.
Currently, I generate a simplified GeoJSON file and use it with turf#points-within-polygon when the device is offline, but there're gaps, sometimes polygons are covering each other (due to the simplifying) etc... if I make the tolerance level lower the file is going to be too large to download and store it offline, so this is not really a solution just a poor workaround.
Can I make a PIP (point-in-polygon) query for a custom Tileset source even outside of the viewport, when the app is in the background and the device is offline?
Assuming this is your actual question:
Can I make a PIP (point-in-polygon) query for a custom Tileset source even outside of the viewport, when the app is in the background and the device is offline?
If the device is offline, then any solution that requires fetching tiles on demand (like a tileset in Mapbox-GL or TileQuery) is out.
You said storing the whole GeoJSON is out, because it's too big.
I think the remaining solution is to generate a single-zoom-level tileset and store it locally, then query it with something like query-mbtiles.
I’m trying to create an AR image to project on a wall from a Gigapixel image. Obviously Xcode crashes if I try to load the image as a material. Is there an efficient way to load only parts of the image that the user is looking at?
I'm using Swift 4.
This may not do exactly what you want, and you might need to roll-your-own way of parsing and passing data between Core Animation and SceneKit, but this is native, and is designed to handle large images and texture data sources, and feed them out asynchronously, and/or on a demand based basis:
https://developer.apple.com/documentation/quartzcore/catiledlayer
Does unity have any limits when it comes to .tmx files? I am creating a .tmx map on tiled and each tile is 16x16 pixels. I am making a game and I would like to make it fairly universal and make sure most graphics cards can handle it but I'm not sure whether I should divide my map in to chunks that will load when the boarder is crossed or just load the whole map, as I'm not sure if I would be able to program the game to only load say a 50x50 texture and render more of the map as the player moves. So does unity have a maximum number of tiles it can render? Thanks in advance
Open statistics window and see performance stats of your game. Mostly and basicly, Draw Calls is defined your game's parformance. For example FPS decreases under 60 for more than 2500 draw calls on most of PCs.
Assume that your map is 128x128, if you use 16x16 tiles you need 64 nodes otherwise if you use 32x32 tiles you need 16 nodes. More nodes means more loading.
Just check stats and get visuals under control for better performance.
I'm trying to learn spritekit and I'm a little confused by something. I know that I need to have #2 image files which need to be double the size of the standard ones and that once I name them properly xcode will deal with the rest. But, when dealing with tiled, do I need tiled files that are level1.tmx and level1#2.tmx
So here is what I did as a test today:
created two tilesheets, one was 32x32 and the other is 64x64 (the 2x).
create two levels in tiled, one was 64x64 tile sizes and the level size was 2048x1536 (the 2x one). I used the 64x64 tiles on that one. The other level I created was the exact same, but I created it with 32x32 tile size, which made the level size 1024x768 and I used the tilesheet that was 32x32 on it.
So now I have two tmx files and two spritesheets, for one level, on the ipad.
Am I doing this correctly? Once I start doing the iphone I will have 4 or maybe 6 sets for each level?
I assume xcode won't work the same way with tmx files if I name them level1#2x.tmx, right? If not and assuming everything I'm doing above is correct, how to do load the correct tmx file? Do I need to check for device type, then resolution and load my map file based on that for each level?
I think maybe I'm not doing this right so I wanted to stop here and ask before I get any further.
TMX files are not loaded automatically in iOS so I am guessing you are either using the SKAToolKit or the JSTileMap one of the two most popular to my knowledge. Myself and other Sprite Kit Alliance members put together the SKAToolKit so I think I can answer your questions from that point of view because it should be similar for JSTileMap too.
The short answer is build your map using 1x assets, but provide images for standard and retina in Xcode.
First you create your map using 1x assets. When the map is loaded it uses points not pixels. So for example if you make a 32x32 pixel tile map it will be treated as a 32x32 point map. When the sprites are created it pulls in the correct image based on device. If an image is named tree.png and is 32x32 it will take up the space of a 32x32(point) tile. If you have an image called tree#2x.png 64x64 iOS will use that for retina devices. Because it is an #2x image it will take up 32x32(points) but will be 64x64 pixels.
Hopefully that makes some sense. If not let me know.
I am using easeljs library. I created a sprite sheet using sprite generator with all the assets(buttons,background images,icons, etc). I got a sprite sheet and a css file (contains co-ordinates, dimensions). I need to load every images in the sprite sheet.
I answered this here on the CreateJS site:
The best way is to preload the images using PreloadJS (http://preloadjs.com). There are a bunch of examples in the PreloadJS GitHub that should help with that. Additionally, 3 of the EaselJS demos use PreloadJS (Game, SpriteSheet, and Transform).
Note that the images will automatically load one they are used - and they will show up once loaded, as long as you are updating the stage.