diff --git a/Assets/Scenes/LevelDesign.unity b/Assets/Scenes/LevelDesign.unity index 792ff80..ade5749 100644 --- a/Assets/Scenes/LevelDesign.unity +++ b/Assets/Scenes/LevelDesign.unity @@ -1881,6 +1881,7 @@ GameObject: - component: {fileID: 1530935836} - component: {fileID: 1530935839} - component: {fileID: 1530935840} + - component: {fileID: 1530935841} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -2021,6 +2022,19 @@ MonoBehaviour: m_CameraActivatedEvent: m_PersistentCalls: m_Calls: [] +--- !u!114 &1530935841 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1530935835} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b3c79a3620af0f143ab3d5736c2ab534, type: 3} + m_Name: + m_EditorClassIdentifier: + targetAspect: {x: 4, y: 3} --- !u!1001 &1650059524 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index 21c3ecd..0204efa 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -585,6 +585,7 @@ GameObject: - component: {fileID: 212203381} - component: {fileID: 212203380} - component: {fileID: 212203383} + - component: {fileID: 212203384} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -691,6 +692,19 @@ MonoBehaviour: m_RequiresDepthTexture: 0 m_RequiresColorTexture: 0 m_Version: 2 +--- !u!114 &212203384 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 212203379} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b3c79a3620af0f143ab3d5736c2ab534, type: 3} + m_Name: + m_EditorClassIdentifier: + targetAspect: {x: 4, y: 3} --- !u!1001 &221153709 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/ThanksScene.unity b/Assets/Scenes/ThanksScene.unity index 87434f5..7918916 100644 --- a/Assets/Scenes/ThanksScene.unity +++ b/Assets/Scenes/ThanksScene.unity @@ -30617,6 +30617,7 @@ GameObject: - component: {fileID: 1530935836} - component: {fileID: 1530935839} - component: {fileID: 1530935840} + - component: {fileID: 1530935841} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -30757,6 +30758,19 @@ MonoBehaviour: m_CameraActivatedEvent: m_PersistentCalls: m_Calls: [] +--- !u!114 &1530935841 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1530935835} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b3c79a3620af0f143ab3d5736c2ab534, type: 3} + m_Name: + m_EditorClassIdentifier: + targetAspect: {x: 16, y: 9} --- !u!1 &1538549526 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CameraCrop.cs b/Assets/Scripts/CameraCrop.cs new file mode 100644 index 0000000..6f5a4c7 --- /dev/null +++ b/Assets/Scripts/CameraCrop.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +/** +https://gamedev.stackexchange.com/questions/144575/how-to-force-keep-the-aspect-ratio-and-specific-resolution-without-stretching-th +*/ + +[RequireComponent(typeof(Camera))] +public class CameraCrop : MonoBehaviour { + + // Set this to your target aspect ratio, eg. (16, 9) or (4, 3). + public Vector2 targetAspect = new Vector2(16, 9); + Camera _camera; + + void Start () { + _camera = GetComponent(); + UpdateCrop(); + } + + // Call this method if your window size or target aspect change. + public void UpdateCrop() { + // Determine ratios of screen/window & target, respectively. + float screenRatio = Screen.width / (float)Screen.height; + float targetRatio = targetAspect.x / targetAspect.y; + + if(Mathf.Approximately(screenRatio, targetRatio)) { + // Screen or window is the target aspect ratio: use the whole area. + _camera.rect = new Rect(0, 0, 1, 1); + } + else if(screenRatio > targetRatio) { + // Screen or window is wider than the target: pillarbox. + float normalizedWidth = targetRatio / screenRatio; + float barThickness = (1f - normalizedWidth)/2f; + _camera.rect = new Rect(barThickness, 0, normalizedWidth, 1); + } + else { + // Screen or window is narrower than the target: letterbox. + float normalizedHeight = screenRatio / targetRatio; + float barThickness = (1f - normalizedHeight) / 2f; + _camera.rect = new Rect(0, barThickness, 1, normalizedHeight); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/CameraCrop.cs.meta b/Assets/Scripts/CameraCrop.cs.meta new file mode 100644 index 0000000..4d0d62c --- /dev/null +++ b/Assets/Scripts/CameraCrop.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3c79a3620af0f143ab3d5736c2ab534 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/StreamingAssets.meta b/Assets/StreamingAssets.meta new file mode 100644 index 0000000..2d62425 --- /dev/null +++ b/Assets/StreamingAssets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20b5207e544e287489edeb6c3943bd45 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/StreamingAssets/UnityServicesProjectConfiguration.json b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json new file mode 100644 index 0000000..1303543 --- /dev/null +++ b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json @@ -0,0 +1 @@ +{"Keys":["com.unity.services.core.cloud-environment","com.unity.services.core.version"],"Values":[{"m_Value":"production","m_IsReadOnly":true},{"m_Value":"1.4.2","m_IsReadOnly":true}]} \ No newline at end of file diff --git a/Assets/StreamingAssets/UnityServicesProjectConfiguration.json.meta b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json.meta new file mode 100644 index 0000000..a460a44 --- /dev/null +++ b/Assets/StreamingAssets/UnityServicesProjectConfiguration.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 528c76750e583c144b167f8cfa20183f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: