Answer the question
In order to leave comments, you need to log in
How to make the game responsive?
I was writing a game and faced such a problem that when you start the game on your phone, the game does not adjust to the resolution of the device, and I did not find a single normal answer or guide on the Internet and forums, everything I found works with errors, well, or some then crutch methods.
Here seems to be one of the working methods, but I do not quite understand how to fix the error. If anything, it should be so, so that only permission is output to the console.
void Awake()
{
foreach (var res in Screen.resolutions)
{
Debug.Log(res.width + "x" + res.height + " : " + res.refreshRate);
}
}
UnityException: get_resolutions is not allowed to be called from a MonoBehavior constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'Controller' on game object 'Controller'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScreenShimBase.get_resolutions() (at :0)
UnityEngine.Screen.get_resolutions() (at :0)
Controller..ctor() (at Assets/scripts/Controller.cs:12)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question