HKI Core
AudioLocalization.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections.Generic;
3 using HKI.Core.Variables;
4 
5 namespace HKI.Core.Loc
6 {
10  [System.Serializable]
11  public class AudioLocalization : ScriptableObject
12  {
16  [System.Serializable]
18  {
19  // Public variables
20  [SerializeField] SystemLanguage Language = SystemLanguage.English;
21  [SerializeField] AudioClip Clip = null;
22  [SerializeField] [Range(0.0f, 1.0f)] float Volume = 1.0f;
23  [SerializeField] [MinMaxRange(0.0f, 3.0f)] MinMaxRange Pitch = new MinMaxRange(1.0f, 1.0f);
24 
25  // Getter
26  public SystemLanguage GetLanguage { get { return Language; } }
27  public AudioClip GetClip { get { return Clip; } }
28  public float GetVolume { get { return Volume; } }
29  public MinMaxRange GetPitch { get { return Pitch; } }
30  }
31 
32  // Public variables
36  [SerializeField] List<AudioLocalizationElement> AudioLocalizationElements = new List<AudioLocalizationElement>();
37 
38  // Interface function
45  {
46  if (language != null)
47  return GetAudioLocalizationElement(language.Value);
48  else
49  return null;
50  }
51 
57  public AudioLocalizationElement GetAudioLocalizationElement(SystemLanguage language)
58  {
59  for (int i = 0; i < AudioLocalizationElements.Count; i++)
60  {
61  if(language == AudioLocalizationElements[i].GetLanguage)
62  return AudioLocalizationElements[i];
63  }
64 
65  return AudioLocalizationElements.Count > 0 ? AudioLocalizationElements[0] : null;
66  }
67  }
68 }
This subclass holds the data for a audio localization in a specific language.
AudioLocalizationElement GetAudioLocalizationElement(SystemLanguage language)
Alternative way of getting the localized string with SystemLanguage as input.
Special Variable enables the use of the SystemLanguage data type as a variable of the settings system...
Definition: Language.cs:13
AudioLocalizationElement GetAudioLocalizationElement(Language language)
This function returns the AudioLocalizationElement in a specific language. If there is no localizatio...
This is a data type that combines a float start and a float end value into one value. This can be used for storing min max informations for a random generator or volume settings.
Definition: MinMaxRange.cs:9
This ScriptableObject contains as a container for all audio localization information.