Пример #1
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        if (Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        anim = GetComponent <Animator>();

        defaultZoom = mainCamera.orthographicSize;

        screenWidth  = Screen.width;
        screenHeight = Screen.height;

        mainCamera = Camera.main;

        QualitySettings.vSyncCount = 0;

        LocalizedStringManager.Init();
        LocalizedStringManager.ParseTranslations();

        string currentCultureName = Localizer.GetCurrentCultureInfo().Name;

        Debug.LogFormat("Current culture: {0}", currentCultureName);

        LocalizedTextRegistry.Clear();

        bool isFirstLoad = IsFirstLoad();

        Options.Load();

        if (isFirstLoad)
        {
            Options.currentCulture = CultureInfo.GetCultureInfo(currentCultureName);
        }

        Debug.LogFormat("Loading culture {0}", Options.currentCulture.Name);
        if (Options.currentCulture == null)
        {
            Debug.Log("Setting current culture!");
            if (!LocalizedStringManager.availableCultures.Contains(currentCultureName))
            {
                Debug.LogFormat("Culture {0} is not supported, defaulting to en-US");
                Options.currentCulture = CultureInfo.GetCultureInfo("en-US");
            }
        }
        LocalizedStringManager.SetCulture(Options.currentCulture.Name);

        Options.ApplyGraphics();

        Options.Save();

        OnGameReady += () => canPause = true;
    }