简体   繁体   English

Unity - 如何制作设置菜单?

[英]Unity - How to make a settings menu?

I'm making a settings menu in my game, but I don't know how to make it.我正在我的游戏中制作一个设置菜单,但我不知道如何制作它。 I tried a few tutorials, but when I finish them they don't work.我尝试了一些教程,但是当我完成它们时它们不起作用。 So, in the main menu I made a button that goes to the options menu, and in the options menu, I made a button that goes to the settings.因此,在主菜单中,我制作了一个前往选项菜单的按钮,在选项菜单中,我制作了一个前往设置的按钮。 In the settings menu I want to make a dropdown that changes the resoluton, a dropdown that changes the quality and a toggle that enables/disables fullscreen.在设置菜单中,我想创建一个更改分辨率的下拉菜单、一个更改质量的下拉菜单和一个启用/禁用全屏的切换。 I researched a lot, but I couldn't found anything.我研究了很多,但我找不到任何东西。 The main problem is that if I change the settings, then I exit the settings, and then I go back to the settings, the settings don't save.主要问题是如果我更改设置,然后我退出设置,然后我 go 回到设置,设置不保存。 If you know any way to make a script that controls the settings menu, please help!如果您知道任何方法来制作控制设置菜单的脚本,请帮助!

You need a basic save system to keep your variables saved.您需要一个基本的保存系统来保存您的变量。

Most basic thing I could suggest is我可以建议的最基本的事情是

Saving your variables like保存你的变量,比如

PlayerPrefs.SetInt("screenwidth",800);
PlayerPrefs.SetInt("screenheight",600);
PlayerPrefs.Save()

And load them whenever they are necessary并在需要时加载它们

int screenWidth = PlayerPrefs.GetInt("screenwidth");
int screenHeight = PlayerPrefs.GetInt("screenheight");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM