Hello Guest

Author Topic: Platform Settings - 1 Source Image  (Read 6025 times)

dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Platform Settings - 1 Source Image
« on: December 19, 2012, 11:20:38 pm »
I was just wondering if this was possible, because it seems entirely logical to me and less clutter:

I want to set up my platform settings, but only use 1 source image (the highest res possible) for all of them.
Then afterwards I can just resize the atlas textures to be shrunken down (with max texture size).
It seems that it doesn't support this because if it doesn't detect multiple source images it fails?

All I'm after is the resizing of the finished atlases, I'm not going to import 3 versions of every image if it only pulls the images from the atlases in the end anyways.

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #1 on: December 20, 2012, 03:08:47 am »
It doesn't support this right now for a few reasons.

1. You can't resize the atlas textures because textures may fall on 2/4 pixel boundaries, and when resizing will get turned into a mess of pixels. The only way to generate correct smaller textures is to regenerate with resized source textures. If you think this will be acceptable in your use case, just turn on mips and use TextureQuality to drop to a lower mipmap - that will give you the same result.

2. If you auto-scale the source textures, the source textures MUST be the correct size to start with. To scale down correctly from 4x -> 2x -> 1x, each texture dimension must be a multiple of 4. Otherwise the sprite sizes will be physically different, any less than 4 will then round down/up when scaling giving incorrect results.

3. The most error free way of creating a multi-resolution game is to start with 1x, design the game at 1x and then scale up. Scaling down will work, but you're losing data rather than adding it. You can loose to much data.

This is in the pipeline, but after 1.90. Handling all those cases properly will require quite a bit of work.


dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #2 on: January 02, 2013, 03:45:18 pm »
Thanks very much for the detailed response!

I got another quick question, does the project settings texture switch happen before the app is loaded in memory?
Reason I ask is because I set up @1x, @2x, @4x for all my collections, and set @1x in an initial scene that has no assets in it before it loads the first scene.

When loaded on an iPad 1, my thoughts was that it would switch to all the @1x textures, but it crashes on startup almost as if it was trying to load the bigger textures first. Just wondering if this is a bug or I'm missing some features?

Keep up the great work and support, and Happy New Year to you!

EDIT: Code Snippet
Code: [Select]
if (checkDevice()[0] == "iPad") {
int deviceNum = int.Parse(checkDevice()[1]);

//Texture Settings
if (deviceNum >= 3) {
platformQuality = "4x";
textureQuality = 4096;
} else if (deviceNum == 2) {
platformQuality = "2x";
textureQuality = 2048;
} else if (deviceNum == 1) {
platformQuality = "1x";
textureQuality = 1024;
}

tk2dSystem.CurrentPlatform = platformQuality;
}
« Last Edit: January 02, 2013, 03:50:57 pm by dustinbahr »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #3 on: January 02, 2013, 05:46:05 pm »
That should do it. You can check what is loaded by that point by writing a script to do Resources.FindObjectsOfTypeAll(...) and cataloging all materials/textures. There should be no reference to the 2x, 4x ones.

dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #4 on: January 02, 2013, 06:19:54 pm »
Alright, I gave that a shot and it says there's 238 Texture2D assets before it even loads the game?
I checked their sizes and it seems to be referencing a few different versions (1024, 2048, 4096 were all listed).

I have nothing set in the scene or script that would load assets I'm pretty sure, hmm...

Code: [Select]
foreach (Texture2D tex in Resources.FindObjectsOfTypeAll(typeof(Texture2D))) {
print (tex.width);
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #5 on: January 02, 2013, 07:02:17 pm »
Probably worth printing the texture names too, in case they are system textures. 238 does sound excessive though... I've definitely tested this, and NOTHING should be loaded unless somehow loaded explicitly. With these ones its even harder to accidentally load them as they're loaded using Resources.Load.

dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #6 on: January 02, 2013, 07:11:32 pm »
Yeah heres a little snippet with the names that show up so you can see.
These are what load near the end, which are the collections.

It looks as if it definitely is loading some 4x and 2x textures, but I have no idea why.
I can't find a pattern in the loading sequence of it, since it doesn't seem consistent.

Code: [Select]
ACA4x / 4096 / 300302
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

ACA1x / 1024 / 300276
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

ACB4x1 / 4096 / 303984
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

ACB4x2 / 2048 / 303996
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

ACB1x1 / 1024 / 309778
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

ACB1x2 / 1024 / 309790
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

BG14x / 2048 / 309852
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

BG11x / 512 / 309810
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

BG31x / 512 / 309972
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

BG41x / 512 / 309992
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

SCA1x / 128 / 310056
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

WC4x / 4096 / 310110
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

WC1x / 1024 / 310084
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

Worm4x / 512 / 317372
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)
 
(Filename: Assets/Scripts/InitialSetup.cs Line: 20)

Phil1x / 256 / 316942
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
UnityEngine.MonoBehaviour:print(Object)
InitialSetup:Start() (at Assets/Scripts/InitialSetup.cs:20)

dustinbahr

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #7 on: January 02, 2013, 11:26:49 pm »
Update:
Solved one part, and another issue came up.

1) So the initial loading problem must be a quirk with unity or the settings not refreshing, because a full reboot of unity cleared that right up.

2) A new issue has arisen though, and I'm not sure what it has to do with but I'm leaning towards the platform switching. When loading between scenes now, the load times have increased by quite a bit, and the app crashes at various scene loads, almost as if its got a huge memory spike while trying to find the correct texture maybe?

Thanks for your awesome help so far, appreciate it haha!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Platform Settings - 1 Source Image
« Reply #8 on: January 03, 2013, 11:35:24 am »
The platform switching stuff is different from normal loading in that the texture is loaded AFTER the scene is loaded, whereas with the normal method, the texture is loaded with the scene. It shouldn't take long to find stuff, it is a direct load which should be no different to any other Resources.Load call, and not THAT different to normal scene loading either.

Attach the profiler to the running game and try and work out exactly what is causing the slowdown. No use guessing :)