void Awake()
        {
            string lang = PlayerPrefs.GetString("Language", "");

            if (!string.IsNullOrEmpty(lang))
            {
                if (Enum.TryParse <Language>(lang, out var language))
                {
                    currentLanguage = language;
                    return;
                }
                DebugOnly.Error($"Invalid language in settings: {lang}");
            }

            var sysLang = Application.systemLanguage;

            switch (sysLang)
            {
            case SystemLanguage.Russian: currentLanguage = Language.Russian; return;

            case SystemLanguage.English: currentLanguage = Language.English; return;
            }

            DebugOnly.Error($"Unsupported system language \"{sysLang}\", using English instead.");
            currentLanguage = Language.English;
        }
 public ISoundChannel GetChannel(string name)
 {
     if (channelDict.TryGetValue(name, out var channel))
     {
         return(channel);
     }
     DebugOnly.Error($"Sound channel '{name}' was not found.");
     return(null);
 }
Ejemplo n.º 3
0
 void IObserverList.Add(ref ObserverHandle handle, object observer)
 {
     if (observer is T typedObserver)
     {
         Add(ref handle, typedObserver);
     }
     else
     {
         if (observer == null)
         {
             DebugOnly.Error("Observer is null.");
         }
         else
         {
             DebugOnly.Error($"Was expecting type {typeof(T)}, got type {observer.GetType().Name}.");
         }
     }
 }
        public void Stop(SoundHandle handle)
        {
            if (!handle.IsValid)
            {
                DebugOnly.Error("Attempted to stop sound with an invalid SoundHandle.");
                return;
            }

            int n = soundSources.Count;

            while (n-- > 0)
            {
                if (soundSources[n] == handle.Source)
                {
                    soundSources.RemoveAt(n);
                    handle.Source.Dispose();
                    return;
                }
            }

            DebugOnly.Error("Attempted to stop sound that is not playing in this channel.");
        }