- Home /
SpriteManager2 and Universal Apps
Is anyone using SpriteManager2 with a universal app (iPad/iPhone)? If so, how are you supporting multiple texture assets optimized for each device?
I was thinking I could create two prefabs (one using the iPad texture, one for the iPhone texture). Attach both prefabs to my GameManager script. For example "BackgroundPrefabiPad" and "BackgroundPrefabiPhone". Expose a single property on the GameManager called "Background" and return either the "BackgroundPrefabiPad" or "BackgroundPrefabiPhone" depending on the device. So when I instantiate the background its something like...
MonoBehaviour.Instantiate(GameManager.Background, [position], [rotation])
Would this make sense? My concern would be a ballooned file size on the .app because both prefabs are technically being used, granted at runtime only 1 of the materials would be loaded. Is their any "native" way of supporting this?
Thanks!
Answer by Tetrad · Jun 10, 2010 at 03:27 PM
I would suggest investigating using two different scenes that are basically clones of each other with different materials depending on if it's the high res or low res scene, and having an initial loading scene decide which of your two near-duplicate scenes to load depending on the user's device.
Maintenance will probably be a pain, though.
I've been thinking about this same thing recently. All of my assets are big enough for any platform, it would just be a matter of choosing a different import option. However, I don't think you can select per-prefab texture resolution settings. I can't make a unique iPhone and iPad prefab that reference the same texture asset, but at different resolution. Duplicating the source asset to get around this kills the entire idea of Unity's asset pipeline and would make upkeep hell and that's all before any sort of scene implementation.
Spoke a little too soon, I guess. I went and checked the Texture2D class, which has functions for resizing/packing/compressing/etc texture assets at runtime. Detect device and resize as appropriate and you're set for materials. For GUI, you could do the same check and initialize different scripts or stick to proportional layout.
I ended up creating two versions of the scene. All my render logic is in script/code so maintenance is fairly easy. I just load with a SceneSelector.cs script which redirects to the correct version of the scene. I then have iPad and iPhone specific prefabs that leverage Sprite$$anonymous$$anager2 and are attached to the Game$$anonymous$$anager script running the scene. The only thing I don't care for is the increased output app size.
Your answer
![](https://koobas.hobune.stream/wayback/20220613061819im_/https://answers.unity.com/themes/thub/images/avi.jpg)