Hello Guest

Author Topic: Difficulty with Multi-Resolution and CurrentPlatform  (Read 3455 times)

ricke

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Difficulty with Multi-Resolution and CurrentPlatform
« on: August 13, 2016, 10:24:31 pm »
So I'm working on a space shooter game with 2D Toolkit 2.5.6 and I'm trying to setup multi-resolution sprite collections as the docs below explain.  I initially tried to setup in my game, but due to my issues, I created a test project to hammer it out.  Unfortunately, I've gotten the same results in both projects.  :(

http://www.2dtoolkit.com/doc/2.5/advanced/platform_specific_sprite_collections.html

I want my game to run natively at 1920 x 1080, so I set my Current Platform to 4x and then added 1x and 2x platforms in the sprite collection settings.  My sprite sizes are 64 x 64 (4x), 32 x 32 (2x), and 16 x 16 (1x).  It appears to be generating the proper 1x, 2x, and 4x atlases in the Project directory, so that looks good.  However, I always seem to be getting the 1x version of the sprites, no matter which resolution I select on the Game screen.  I've looked around on the forums and it seems like I'm doing the right thing, but I've got to be missing something. :) 

In the example project, I'm spinning up a GameController object that sets the CurrentPlatform in the Awake method, then I create an instance of a prefab of my Ship, Enemy, and Shot in the Start method.  Here's the code for my GameController:

Code: [Select]
using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour
{
    public GameObject playerPrefab;
    public GameObject enemyPrefab;
    public GameObject shotPrefab;

    private GameObject _player;
    private GameObject _enemy;
    private GameObject _shot;

    void Awake()
    {
        if (Screen.height >= 900)
        {
            tk2dSystem.CurrentPlatform = "4x";
        }
        else if (Screen.height >= 480)
        {
            tk2dSystem.CurrentPlatform = "2x";
        }
        else
            tk2dSystem.CurrentPlatform = "1x";
    }

    void Start()
    {
        // Create new instances of sprites
        _player = Instantiate<GameObject>(playerPrefab);
        _enemy = Instantiate<GameObject>(enemyPrefab);
        _shot = Instantiate<GameObject>(shotPrefab);

        Debug.Log("Current Platform: " + tk2dSystem.CurrentPlatform);
        Debug.Log("Screen Resolution: " + Screen.width + " x " + Screen.height);
    }

}

Here's a screenshot with my enemy texture at 1x, 2x, and 4x respectively above my ship, enemy, and shot sprite prefabs to show the difference.  No matter what Preview resolution I use in the Game window, the sprites are always the 1x size.



I can send my example project along if that would be helpful.  Any thoughts would be appreciated.  Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Difficulty with Multi-Resolution and CurrentPlatform
« Reply #1 on: August 20, 2016, 11:54:46 am »
Yes please post a repro in the private support forum.