aspect ratio handler

This commit is contained in:
2023-03-24 14:25:10 +01:00
parent 76f2975f7e
commit e644f1de7c
5 changed files with 146 additions and 86 deletions

View File

@@ -4052,6 +4052,7 @@ GameObject:
- component: {fileID: 197904235}
- component: {fileID: 197904237}
- component: {fileID: 197904238}
- component: {fileID: 197904239}
m_Layer: 0
m_Name: Mangager
m_TagString: Untagged
@@ -4134,6 +4135,7 @@ MonoBehaviour:
- {fileID: 255844036}
dobott: 0
dobottEgyszer: 0
ujradobasszamlalo: 0
--- !u!114 &197904222
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -4675,6 +4677,19 @@ MonoBehaviour:
threefourText:
- {fileID: 663535674}
- {fileID: 1583842800}
--- !u!114 &197904239
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 197904216}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1646c9ba4620a0e7861327e11e40849, type: 3}
m_Name:
m_EditorClassIdentifier:
mainCamera: {fileID: 519420031}
--- !u!1 &229807670
GameObject:
m_ObjectHideFlags: 0
@@ -11098,7 +11113,7 @@ Camera:
far clip plane: 10
field of view: 60
orthographic: 1
orthographic size: 10.409236
orthographic size: 10.4
m_Depth: -1
m_CullingMask:
serializedVersion: 2

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public class AspectRatioHandler : MonoBehaviour
{
public Camera mainCamera;
private void Awake() {
double aspectRatio = (double)Screen.width / (double)Screen.height;
aspectRatio = Math.Round(aspectRatio, 2);
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){
mainCamera.orthographicSize = 10.4f; //16:9, 21:9
}else if(aspectRatio == 1.6){
mainCamera.orthographicSize = 11.43f; //16:10
}else if(aspectRatio == 1.33){
mainCamera.orthographicSize = 13.72f; //4:3
}else if(aspectRatio == 1.25){
mainCamera.orthographicSize = 14.68f;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1646c9ba4620a0e7861327e11e40849
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -10,11 +10,13 @@ public class Source : MonoBehaviour
private movement movement;
public GameObject sourceSprite;
private Ugynok ugynok;
private bool oneTime = false;
private void Awake() {
movement = FindObjectOfType<movement>();
ugynok = FindObjectOfType<Ugynok>();
}
private void Start() {
@@ -28,6 +30,10 @@ public class Source : MonoBehaviour
if(isNyitva && oszlop != -1 && sor.Count == 1) {
sourceRender(oszlop, sor[0]);
if (!oneTime) {
for (int i = 0; i < 3; i++)
{
ugynok.UgynokSorsolas(sor[0], oszlop);
}
printSourceLocation();
oneTime = true;
}