Question by
elfasito · Dec 20, 2019 at 02:13 PM ·
androidscripting problemscenescameras
how reload scene when rotate screen android
Hello ppl.
I want reload my current scene when I rotate my android device (portrait to landscape and vice versa)
I triying with this script:
using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine;
public class RELOADSCENE : MonoBehaviour
{
void Update()
{
if (Screen.orientation == detect orientation) //I dont know how complete this
{
Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
}
else
{
}
}
}
but I dont know how call the API in charge of orientation/rotation device.
I want to do this because I need update the fov orientation of my secondary camera when I change to portrait or landscape. (Maybe there is an easier way) the main camera change the orientation automatically.
Comment
Best Answer
Answer by lgarczyn · Dec 21, 2019 at 12:33 AM
Just store the orientation on awake, and compare it every frame to the previous one.
if (Screen.orientation != lastOrientation)
{
lastOrientation = Screen.orientation
//...
}
Hello, thanks for the answer. I opted to resolve my problem detecting changes in the resolution ins$$anonymous$$d the orientation. I will try this in any moment, thanks.