在此项目中,您能够访问使用 Visual Effect Graph 制作的示例场景和效果。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

40 行
1.2 KiB

using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace GameOptionsUtility
{
[RequireComponent(typeof(Dropdown))]
public class DropDownFullScreenMode : MonoBehaviour
{
private void OnEnable()
{
var dropdown = GetComponent<Dropdown>();
InitializeEntries(dropdown);
dropdown.onValueChanged.AddListener(UpdateOptions);
UpdateOptions(dropdown.value);
}
private void OnDisable()
{
GetComponent<Dropdown>().onValueChanged.RemoveListener(UpdateOptions);
}
public void InitializeEntries(Dropdown dropdown)
{
dropdown.options.Clear();
dropdown.options.Add(new Dropdown.OptionData("Full Screen"));
dropdown.options.Add(new Dropdown.OptionData("Full Screen (Windowed)"));
dropdown.options.Add(new Dropdown.OptionData("Maximized Window"));
dropdown.options.Add(new Dropdown.OptionData("Window"));
}
void UpdateOptions(int value)
{
GameOptions.graphics.fullScreenMode = (FullScreenMode)value;
}
}
}