Hello Guest

Author Topic: multiplatform - simpler solution?  (Read 7772 times)

tom123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
multiplatform - simpler solution?
« on: June 23, 2013, 10:32:58 pm »
I'm in the middle of making a game with toolkit 2d, and I've done all my graphics for the iPad3 size, with the plan that I'll just scale them all down by half and use that for iPad2, and iPhone4+5

So I was hoping I could just go into the Data directory of each Sprite Collection and add another image that has half of the size, calling it atlas0Small.png. And then somehow switch between atlas0.png and atlas0Small.png
But by switching to the smaller one, the result comes out blurry on the iPhone5.. even though it now has the right amount of pixels according to the iPhone5's resolution.
Is there anything that I'm missing?

Then I've looked at the official way of how to handle the multiplatform thing on toolkit 2d:
http://www.unikronsoftware.com/2dtoolkit/docs/2.00/advanced/platform_specific_sprite_collections.html

but it doesn't seem logic to me why I have to scale down every single texture, rather than just the main one - meaning atlas0.png?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: multiplatform - simpler solution?
« Reply #1 on: June 23, 2013, 10:51:38 pm »
To correctly handle downscaling, each image has to be downscaled (right now, you have to do this manually) but we will be making it so you can downscale automatically in the toolkit in a future version. You can't downscale the atlases, as that would incorrectly merge pixels that shouldn't be merged. We supported manually downscaling first, as that produces the highest quality results, as photoshop downscale filters are far nicer than the ones built in to Unity, and you can also tweak them manually for better quality.

If you want a cheap and dirty solution to this right now, enable mipmaps and use QualitySettings to switch to a lower resolution for your other platforms. You can find some samples of how to do this on Unity Answers, but that seems to be down right now.

tom123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: multiplatform - simpler solution?
« Reply #2 on: June 25, 2013, 04:32:20 am »
ok, that's good to know - thanks!

got two more questions
1) Is it important that all my image files that I'm using for ipad3 (larger resolution) have a 2x after the name? Or would it be enough if I just use them in the sprite collection window and set the 'Current Platform' attribute there as 2x. And then have in all my lower resolution files 1x at the end of the name? I've tried this but then he didn't cut the sprites properly, like he used wrong uv values..

2) is there any recommended function where I call
tk2dSystem.CurrentPlatform = "2x"
The tutorial says, call it before loading anything - but I believe the sprites will all get loaded already before I call the first Awake function in any of my objects?
« Last Edit: June 25, 2013, 05:27:34 am by tom123 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: multiplatform - simpler solution?
« Reply #3 on: June 25, 2013, 12:43:27 pm »
1. That should work.
2. You should call it before loading anything, ideally in an empty scene, before loading your main game. Worst case, you can set the script execution order to run this as early as possible, before any tk2d scripts, and set it up in Awake.

tom123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: multiplatform - simpler solution?
« Reply #4 on: June 27, 2013, 05:53:46 pm »
thanks for your fast replies! I got it all working :)

There's just one more thing I'm a bit confused about and I can't find anything on google:
Later, when I publish the game (iPhone and iPad), should I do extra builts for each device resolution?
And if not - are the larger (2x) files also being published and copied onto the smaller devices, even though I only need the 1x files?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: multiplatform - simpler solution?
« Reply #5 on: June 27, 2013, 05:55:26 pm »
Yes they are and they will be in the build.
You can remove them from the build, but that will be a manual process - you will need to move the appropriate files out of Resources/tk2d for the assets you don't want included.

pagu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: multiplatform - simpler solution?
« Reply #6 on: July 24, 2013, 08:18:11 am »
I'm experimenting with all the options for handling different screen sizes, resolutions and aspect ratios for mobile (Android & iOS).

My scene is setup with resolution of 800x480 (landscape) using td2dCamera. I've added a resolution override with height = 768 and width = -1 with Autoscale = Pixel Perfect fit. I'm testing how the game will look on many of the Android devices out there. As expected, everything is smaller on the screen and bigger part of the scene is visible - this is what I've expected as the resolution of the device is almost double the scene resolution (800x480 vs 1280x768). After that I've added another spritesheet which is twice bigger than the first one and set it as x2 platform. The original one is x1. I've also set the current configuration to be x2. Launching the test on the Android device showed the sprites from the new spritesheet, however the physical size of the gameObject on the screen remained the same.

This is not pixel perfect. I've expected that setting the tk2dSystem.CurrentPlatform = "2x" and Autoscale = Pixel Perfect fit will result in twice bigger objects on the screen being pixel perfect. What actually happens is that the sprite is downscaled so that the physical dimension remains the same. Is this a bug or this is the expected behaviour?

P.S. Is there a way to get the actual size of the camera? Camera.mainCamera.pixelHeight and Camera.mainCamera.pixelRect.yMax on the device returned 768 but moving an object to the upper corner of the screen shows that the value on the border of the screen is about 600. I need to know the actual borders of the camera so that I could spawn and destroy GameObjects when they are outside of the camera.

Thank you!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: multiplatform - simpler solution?
« Reply #7 on: July 24, 2013, 09:42:34 am »
@pagu - Texture swaps and resolution scaling is independent to each other.
Think of it this way.

from 1024x768 -> 2048x1536 - the camera wants to make sure the sprites are the same size, but the sprites show 2x the detail. It is then pixel perfect.
With the platform stuff, the sprites are always exactly the same size, that mean you don't have to reposition anything, rescale anything - you're displaying 2x , 4x the detail. Now that you've got the detail, you just need to figure out what to do to your camera :)

pagu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: multiplatform - simpler solution?
« Reply #8 on: July 24, 2013, 10:08:35 am »
Ah... I see. Thanks!

pagu

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: multiplatform - simpler solution?
« Reply #9 on: July 24, 2013, 01:46:47 pm »
Ah, what about this one?

Quote
P.S. Is there a way to get the actual size of the camera? Camera.mainCamera.pixelHeight and Camera.mainCamera.pixelRect.yMax on the device returned 768 but moving an object to the upper corner of the screen shows that the value on the border of the screen is about 600. I need to know the actual borders of the camera so that I could spawn and destroy GameObjects when they are outside of the camera.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: multiplatform - simpler solution?
« Reply #10 on: July 24, 2013, 02:14:13 pm »
tk2dCamera.ScreenExtents / NativeScreenExtents should return the appropriate scaled and native rects.

tom123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: multiplatform - simpler solution?
« Reply #11 on: August 04, 2013, 07:01:54 am »
Yes they are and they will be in the build.
You can remove them from the build, but that will be a manual process - you will need to move the appropriate files out of Resources/tk2d for the assets you don't want included.

I did that and it seems to work - thanks a lot for the info!