예제 #1
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);

            FullScreenToggle.isOn = Screen.fullScreen;

            _resolutions = Screen.resolutions.Select(resolution => new Resolution {
                width = resolution.width, height = resolution.height
            }).Distinct().ToArray();

            ResolutionsDropdown.ClearOptions();

            List <string> options = new List <string>();

            int resolutionIndex = 0;
            for (int i = 0; i < _resolutions.Length; i++)
            {
                string option = _resolutions[i].width + "x" + _resolutions[i].height;
                options.Add(option);

                if (_resolutions[i].width == Screen.currentResolution.width &&
                    _resolutions[i].height == Screen.currentResolution.height)
                {
                    resolutionIndex = i;
                }
            }

            ResolutionsDropdown.AddOptions(options);
            ResolutionsDropdown.value = resolutionIndex;
            ResolutionsDropdown.RefreshShownValue();

            DialogueText.Start();

            SceneManager.sceneLoaded += OnSceneLoadedListener;

            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }