Skip to content

Commit

Permalink
well i think the camera with these settings will work perfectly t eve…
Browse files Browse the repository at this point in the history
…ry device. i change the scaling so now it scales to screen according to the cameras aspect ratio and included as comment the code i got the inspiration from
  • Loading branch information
Giannis Tantaoui authored and AnimaRain committed Dec 12, 2018
1 parent 3eeb0bf commit a3e2048
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Assets/Scripts/Game/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,18 @@ private void Start() {

cam.Play();
backgroundTexture.texture = cam;
backgroundTexture.rectTransform
backgroundTexture.rectTransform
.localEulerAngles = new Vector3(0, 0, cam.videoRotationAngle);
float scaleY = cam.videoVerticallyMirrored ? -1.0f : 1.0f;
backgroundTexture.rectTransform
.localScale = new Vector3(1f, scaleY, 1f);

fireButton?
float videoRatio = (float)cam.width / (float)cam.height;
backgroundTexture.rectTransform.localScale = new Vector3(scaleY, scaleY/videoRatio, 1); //Through testing i found out that using these settings makes the most optimal outcome

/*
#if UNITY_ANDROID
backgroundTexture.rectTransform.localScale = new Vector3(Screen.width, Screen.height, 0); //Didnt try this, but got the inspiration from it
#endif
*/
fireButton?
.onClick.AddListener(() => {
if (gameState.GameOver) {
SceneManager.LoadScene(1);
Expand Down Expand Up @@ -204,7 +209,7 @@ private void AdvanceLevel() {
#endif

foreach (var s in spawner) {
#region Spawn Patterns
#region Spawn Patterns

if (s.Key == typeof(Crasher))
s.Value.StartSpawning(
Expand All @@ -228,7 +233,7 @@ private void AdvanceLevel() {
* is used.
switch (s.Key)
{
#region Spawn Patterns
#region Spawn Patterns
case typeof(Crasher):
s.Value.StartSpawning(4 * gameState.Level + 8);
break;
Expand All @@ -242,10 +247,10 @@ private void AdvanceLevel() {
throw new Exception(
$"Unrecognised type of spawner: {s.Key}"
);
#endregion
#endregion
}
*/
#endregion
#endregion
}

gameState.RoundWon = false;
Expand Down

0 comments on commit a3e2048

Please sign in to comment.