2023-03-24 14:25:10 +01:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
2023-04-18 21:14:04 +02:00
|
|
|
using System.IO; //ideiglenes amig a mac camera bug nincs javitva aztan torolheto
|
|
|
|
|
using System.Text; //ideiglenes
|
2023-03-24 14:25:10 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class AspectRatioHandler : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Camera mainCamera;
|
2023-04-18 21:14:04 +02:00
|
|
|
private StreamWriter writer;
|
|
|
|
|
|
2023-03-24 14:25:10 +01:00
|
|
|
private void Awake() {
|
2023-06-12 13:05:47 +02:00
|
|
|
//to be removed when mac aspect ratio is fixed
|
2023-04-18 21:14:04 +02:00
|
|
|
writer = new StreamWriter(Application.persistentDataPath + "/aspectratio.txt", false, Encoding.Default);
|
|
|
|
|
|
2023-03-24 14:25:10 +01:00
|
|
|
double aspectRatio = (double)Screen.width / (double)Screen.height;
|
|
|
|
|
aspectRatio = Math.Round(aspectRatio, 2);
|
2023-04-18 21:14:04 +02:00
|
|
|
writer.Write("felbontas: width: " + Screen.width + " height: " + Screen.height + " aspectratio: " + aspectRatio+ "unity aspect: " + mainCamera.aspect);
|
|
|
|
|
writer.Close();
|
2023-03-24 14:25:10 +01:00
|
|
|
Debug.Log("aspectratio: " + aspectRatio);
|
|
|
|
|
|
|
|
|
|
//5:4 1,25, 4:3 1,33, 16:9 1,77, 16:10 1,6, 21:9 2,33
|
|
|
|
|
|
|
|
|
|
if(aspectRatio == 1.78 || aspectRatio == 2.33){
|
2023-04-18 21:14:04 +02:00
|
|
|
if(Application.platform == RuntimePlatform.OSXPlayer)
|
2023-04-19 10:08:03 +02:00
|
|
|
mainCamera.orthographicSize = 11.5f; //mac aspect ratio fix???
|
2023-04-18 21:14:04 +02:00
|
|
|
else
|
|
|
|
|
mainCamera.orthographicSize = 10.4f; //16:9, 21:9
|
2023-03-24 14:25:10 +01:00
|
|
|
}else if(aspectRatio == 1.6){
|
2023-04-18 21:14:04 +02:00
|
|
|
if(Application.platform == RuntimePlatform.OSXPlayer)
|
2023-04-19 10:08:03 +02:00
|
|
|
mainCamera.orthographicSize = 11.5f; //mac aspect ratio fix???
|
2023-04-18 21:14:04 +02:00
|
|
|
else
|
|
|
|
|
mainCamera.orthographicSize = 11.43f; //16:9, 21:9 //16:10 11.43f
|
2023-03-24 14:25:10 +01:00
|
|
|
}else if(aspectRatio == 1.33){
|
|
|
|
|
mainCamera.orthographicSize = 13.72f; //4:3
|
|
|
|
|
}else if(aspectRatio == 1.25){
|
|
|
|
|
mainCamera.orthographicSize = 14.68f;
|
2023-04-18 21:14:04 +02:00
|
|
|
}
|
2023-03-24 14:25:10 +01:00
|
|
|
}
|
|
|
|
|
}
|