One of the new features of Unity 4:
How do you do so? And is it any different when porting to Android?
One of the new features of Unity 4:
How do you do so? And is it any different when porting to Android?
Thanks, but that’s the old Unity 3 command, it sets the screen resolution, not the render resolution. What I want is what’s promised in the quote up above, where you render the game at a low resolution, and it gets upscaled to the screen resolution. This way your game can display at 1080p while only being rendered at 720p for better performance.
Yes, in 4.0 Screen.SetResolution has been changed… try it.
I did, in Android it makes it so my game runs in a small Window in the corner of the screen if I set the resolution to less than native resolution.
Even when fullscreen is set to “true”?
Might be a bug. Although I see no reference to this working with Android. All references are for iOS. I can’t imagine why it would only be implemented for iOS and not Android, but that is a possibility. I’ve used this several times on a retina iPad without issue.
Could be, though yeah it’d be strange. Maybe it just hasn’t been implemented in Android yet (it is still beta). Yeah, passed in true for full screen (and I tried manually setting Screen.fullscreen to true as well, didn’t help).
I tried this on windows 8 and it didn’t upscale it just made the screen smaller with black around it
I tried a resolution of 60x40 with no luck(The res was not that low with the black around it) Its a shame as I wanted to try this cool graphics style that used to only work with render texture.
This has been fixed in the new Beta 4, hooray! I can get some of my sweet, sweet framerate back by setting the resolution to like 720p on my 1080p Android tablet. The scaling is really nice, I had to look closely to see it with my 480p test on the 1080p screen (it’d be easily noticable expanded to a TV, though).
And I tried a resolution of 9 by 16, it works! I wonder if there’s any cool effects we can do by altering this in realtime…
Old thread, but it’s high up on Google. SetResolution doesn’t seem to do what the poster was asking.
You have to use a render texture:
It’s working for me a Galaxy S4 and an old Nexus 7 tablet. No render texture, just using SetResolution as described.
Hello I found the main problem…
in unity 5.3 (5.4,5.5) and onwards you need to uncheck ‘Protect Graphics Memory’ from PlayerSettings>OtherSettings
by the way, here is my script where I manage the screen resolution, it works perfect with unityUI and also MobileFPSUI
this code is from FPScounter.cs from the Frameratecounter prefab in the util assets. I just modified for this purpose
namespace UnityStandardAssets.Utility
{
[RequireComponent(typeof (Text))]
public class FPSCounter : MonoBehaviour
{
const float fpsMeasurePeriod = 0.5f;
private int m_FpsAccumulator = 0;
private float m_FpsNextPeriod = 0;
private int m_CurrentFps;
const string display = "{0} FPS";
private Text m_Text;
public int scene = 0;
public int originalwidth;
public int originalheight;
bool downsized = false;
bool repeat_one = false;
bool repeat_two = false;
public GameObject cam;
private void Start()
{
downsized = false;
originalwidth = Screen.width;
originalheight = Screen.height;
m_FpsNextPeriod = Time.realtimeSinceStartup + fpsMeasurePeriod;
m_Text = GetComponent<Text>();
Invoke ("refresh", 5.0f);
//Invoke ("refresh", 20.0f);
}
private void Update()
{
// measure average frames per second
m_FpsAccumulator++;
if (Time.realtimeSinceStartup > m_FpsNextPeriod)
{
m_CurrentFps = (int) (m_FpsAccumulator/fpsMeasurePeriod);
m_FpsAccumulator = 0;
m_FpsNextPeriod += fpsMeasurePeriod;
m_Text.text = string.Format(display, m_CurrentFps);
}
}
public void refresh(){
if (scene == 0) {
if (repeat_one == false || repeat_one == false) {
if (m_CurrentFps <= 30) {
//2560*1440
if (originalwidth == 2560 && originalheight == 1440 && downsized == false) {
//yield return new WaitForEndOfFrame ();
Screen.SetResolution (2304, 1296, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 2560 && originalheight == 1440 && downsized == true) {
Screen.SetResolution (1920, 1080, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
//1920*1080
else if (originalwidth == 1920 && originalheight == 1080 && downsized == false) {
Screen.SetResolution (1164, 936, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 1920 && originalheight == 1080 && downsized == true) {
Screen.SetResolution (1280, 720, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
//1280*720
else if (originalwidth == 1280 && originalheight == 720 && downsized == false) {
Screen.SetResolution (1152, 648, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 1280 && originalheight == 720 && downsized == true) {
Screen.SetResolution (1024, 576, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
//special resolutions
else if (originalwidth == 2048 && originalheight == 1536 && downsized == false) {
Screen.SetResolution (1600, 1200, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 2048 && originalheight == 1536 && downsized == true) {
Screen.SetResolution (1600, 1200, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
//pixel c
else if (originalwidth == 2560 && originalheight == 1800 && downsized == false) {
Screen.SetResolution (2048, 1536, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 2560 && originalheight == 1800 && downsized == true) {
Screen.SetResolution (2048, 1536, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
}
Invoke ("refresh", 10.0f);
}
} else {
if (repeat_one == false || repeat_two == false) {
if (m_CurrentFps <= 45) {
//2560*1440
if (originalwidth == 2560 && originalheight == 1440 && downsized == false) {
Screen.SetResolution (2304, 1296, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 2560 && originalheight == 1440 && downsized == true) {
Screen.SetResolution (1920, 1080, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
//1920*1080
else if (originalwidth == 1920 && originalheight == 1080 && downsized == false) {
Screen.SetResolution (1164, 936, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 1920 && originalheight == 1080 && downsized == true) {
Screen.SetResolution (1280, 720, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
//1280*720
else if (originalwidth == 1280 && originalheight == 720 && downsized == false) {
Screen.SetResolution (1152, 648, true, 60);
cam.SetActive (false);
cam.SetActive (true);
downsized = true;
repeat_one = true;
}
else if (originalwidth == 1280 && originalheight == 720 && downsized == true) {
Screen.SetResolution (1024, 576, true, 60);
cam.SetActive (false);
cam.SetActive (true);
repeat_two = true;
}
}
Invoke ("refresh", 10.0f);
}
}
}
}
}