Skip to content

Commit fbc9231

Browse files
committed
v0.0.10
Fix: - Fixed 2K and 4K resolutions not scaling correctly with the UI Canvas - Restored correct behavior for the old 4:3 aspect ratio handling Added: - Added real support for any 4:3 aspect ratio (dynamic AspectRatioFitter handling)
1 parent fbb7f82 commit fbc9231

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

Assets/Capture/Settings/AspectRatioDropdown.cs

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ public class AspectRatioDropdown : MonoBehaviour
1919
void Start()
2020
{
2121
aspectRatioList.Add("16:9");
22-
aspectRatioList.Add("4:9 - FullHD");
23-
aspectRatioList.Add("4:9 - 2K");
24-
aspectRatioList.Add("4:9 - 4K");
25-
aspectRatioList.Add("4:9 - HD");
22+
aspectRatioList.Add("4:9");
2623

2724
aspectRatioOptions.options.Clear();
2825

@@ -44,33 +41,17 @@ public void changeAspectRatio(string aspectRatio)
4441

4542
if (aspectRatio.Equals("16:9"))
4643
{
47-
resolutionSettings.changeResolutionInPxl(Screen.mainWindowDisplayInfo.width, Screen.mainWindowDisplayInfo.height);
44+
resolutionSettings.StartCapture.SetNativeAspectFromWebcam(resolutionSettings.StartCapture.webCameraTexture);
4845
selectedAspectRatio = "16:9";
4946
aspectRatioDropdownLabel.text = selectedAspectRatio;
47+
Debug.Log("Changed to 16:9");
5048
}
51-
else if (aspectRatio.Equals("4:9 - 4K"))
49+
else
5250
{
53-
resolutionSettings.changeResolutionInPxl(3840, 2880);
54-
selectedAspectRatio = "4:9 - 4K";
55-
aspectRatioDropdownLabel.text = selectedAspectRatio;
56-
}
57-
else if (aspectRatio.Equals("4:9 - 2K"))
58-
{
59-
resolutionSettings.changeResolutionInPxl(2560, 1920);
60-
selectedAspectRatio = "4:9 - 2K";
61-
aspectRatioDropdownLabel.text = selectedAspectRatio;
62-
}
63-
else if (aspectRatio.Equals("4:9 - FullHD"))
64-
{
65-
resolutionSettings.changeResolutionInPxl(1440, 1080);
66-
selectedAspectRatio = "4:9 - FullHD";
67-
aspectRatioDropdownLabel.text = selectedAspectRatio;
68-
}
69-
else if (aspectRatio.Equals("4:9 - HD"))
70-
{
71-
resolutionSettings.changeResolutionInPxl(960, 720);
72-
selectedAspectRatio = "4:9 - HD";
51+
resolutionSettings.StartCapture.SetAspect43();
52+
selectedAspectRatio = "4:9";
7353
aspectRatioDropdownLabel.text = selectedAspectRatio;
54+
Debug.Log("Changed to 4:9");
7455
}
7556
}
7657
}

Assets/Capture/StartCapture.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class StartCapture : MonoBehaviour
1616
{
1717
public WebCamTexture webCameraTexture;
1818
public RawImage webCamImage;
19+
public CanvasScaler userCanvas;
1920

2021
public Texture2D noSignalImage;
2122

@@ -26,12 +27,15 @@ public class StartCapture : MonoBehaviour
2627

2728
public StartAudio startAudio;
2829
public AspectRatioDropdown aspectRatioDropdown;
30+
public VideoGameCaptureController videoGameCaptureController;
2931

3032

3133
public TMP_Text captureCardDropdownLabel;
3234
public TMP_Text resolutionDropdownLabel;
3335
public TMP_Text fpsDropdownLabel;
3436

37+
public AspectRatioFitter aspectRatioFitter;
38+
3539
//aspectratio text is gettings changed in AspectRatioDropdown class. Sorry for that horrible spaghetti code. i hate it my self!
3640
//public TMP_Text aspectRatioDropdownLabel;
3741

@@ -59,6 +63,8 @@ public void setCaptureCard(string name)
5963
{
6064
webCameraTexture = new WebCamTexture(1920, 1080);
6165
}
66+
67+
6268
webCameraTexture.deviceName = name;
6369

6470
//Sets custom fps
@@ -100,4 +106,16 @@ public void reloadCaptureCardSettings()
100106
setCaptureCard(webCameraTexture.deviceName);
101107
}
102108
}
109+
110+
public void SetAspect43()
111+
{
112+
aspectRatioFitter.aspectMode = AspectRatioFitter.AspectMode.FitInParent;
113+
aspectRatioFitter.aspectRatio = 4f / 3f;
114+
}
115+
116+
public void SetNativeAspectFromWebcam(WebCamTexture cam)
117+
{
118+
aspectRatioFitter.aspectMode = AspectRatioFitter.AspectMode.FitInParent;
119+
aspectRatioFitter.aspectRatio = (float)cam.width / cam.height;
120+
}
103121
}

0 commit comments

Comments
 (0)