EDIT :
If you don't understand code , UI / Canvas is your last option
what i suggest that is your main idea is to make your picture / game object look in same position and look same big as if at other resolution , i have the script ( i tell you how to install it at the bottom of the page ) for it but unfortunally , i can't make it automatically scale all your game object ( one by one ) , the script still scale at aspect ratio but you can't use the script if you build the game using aspect ratio resolution ( must be fixed resolution , because the script itself , explained later) .
this is the script for 2D version ( because your game is 2D ) :
using UnityEngine;
using System.Collections;
public class calculateresolution : MonoBehaviour {
void CalculateResolution(string theobjectm , float resolutionwidthyouusetobuild , float resolutionheightyouusetobuild ) {
GameObject objecttocalculate = GameObject.Find(theobjectm);
float desiredscreenheight = resolutionheightyouusetobuild;
float desiredscreenwidth = resolutionwidthyouusetobuild;
float desiredaspectratio = desiredscreenwidth / desiredscreenheight;
float desiredaspectratioheight = desiredscreenheight / desiredscreenwidth;
float screenheight = Screen.height;
float screenwidth = Screen.width;
float aspectratioheight = screenheight / screenwidth;
float aspectratiowidth = screenwidth / screenheight;
float objectsizex = objecttocalculate.transform.localScale.x;
float objectsizey = objecttocalculate.transform.localScale.y;
float objectsizez = objecttocalculate.transform.localScale.z;
float objectcoordx = objecttocalculate.transform.localPosition.x;
float objectcoordy = objecttocalculate.transform.localPosition.y;
float objectcoordz = objecttocalculate.transform.localPosition.z;
float newobjectsizex = aspectratiowidth / desiredaspectratiowidth * objectsizex;
float newobjectsizey = objectsizey;
float newobjectsizez = objectsizez;
float newobjectcoordx = aspectratiowidth / desiredaspectratiowidth * objectcoordx;
float newobjectcoordy = aspectratioheight / desiredaspectratioheight * objectcoordy;
float newobjectcoordz = objectcoordz;
objecttocalculate.transform.localScale = new Vector3(newobjectsizex,newobjectsizey,newobjectsizez);
objecttocalculate.transform.localPosition = new Vector3(newobjectcoordx,newobjectcoordy,newobjectcoordz);
}
void Start() {
// Example i build my game at fixed resolution 1366 x 768
// 1366 is resolution width , and 768 is resolution height
// and i have GameObject ( such as picture , ect ) named pictureone in the hierarcy
// put this magical command inside Start() { }
// if you don't know where is the inside , just remove the 2 backslash and change the pictureone into your object name
// don't forget to change 1366 and 768 with your screen width and screen height !
// \/ the magical command \/
// CalculateResolution("pictureone",1366f,768f);
// /\ the magical command /\
}
void Update() {
}
}
The how-to-use the script is explained inside function Start() , now :
Installation :
1. Create any object ( or just put another picture if you don't understand how to create object )
2. Create new C# script by Assets menu at top part ( beside GameObject and Edit ) , Create > , C# Script , and then name the script with name calculateresolution .
3. add the script component ( not working yet ) to object , if you don't understand , drag the script into the object you created at step one from hierarchy .
4. Open and edit the script
5. Copy all the script above
6. paste the code to the editor
7. then test it ( without modifying it ) , if its give error , then you have done wrong in previous step , go back and take a look where you are wrong .
8. If the script give no error , then edit the script as i explained in the Start() .
9. If you don't understand code , UI / Canvas is your last option .
10 . Do not lie to script about what resolution you are using , else it will do wrong .
This script only scale when you run the game first time ( did not change if you change the resolution in-game ) , also did not run if you didn't run the game .
Also this not fix your second problem , if player use resolution that is higher than resolution you use to make the game , the picture / sprite still get blurry a little .
If you still don't understand , contact me [email protected]
EDITED !