Class TDGameSettings
- Namespace
- TDMaker.Unity.View
- Assembly
- TDMaker.Unity.dll
Player-facing presentation toggles read by the camera, HUD and feedback components. Put one in the scene (components find it automatically) and expose its fields in your options menu.
[AddComponentMenu("2D Tower Defense Maker/Game Settings")]
public sealed class TDGameSettings : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourTDGameSettings
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Constructors
TDGameSettings()
public TDGameSettings()
Fields
allowDebugOverlay
F1 toggles the IMGUI debug overlay.
[Header("Debug")]
public bool allowDebugOverlay
Field Value
cameraPan
Allows camera panning at all (in levels whose framing scrolls).
[Header("Camera")]
public bool cameraPan
Field Value
cameraZoom
Allows mouse-wheel zoom.
public bool cameraZoom
Field Value
confirmSell
Asks for a second click before selling a tower (a product choice; the reference flow sells directly).
public bool confirmSell
Field Value
damageNumbers
Shows floating damage numbers.
[Header("Feedback")]
public bool damageNumbers
Field Value
dragPan
Pans while the middle mouse button is dragged.
public bool dragPan
Field Value
edgePan
Pans when the pointer touches a screen edge.
public bool edgePan
Field Value
ignoreSavedLanguageInEditor
Use the Inspector language for Editor Play tests; built players still load their saved preference.
[Tooltip("In Editor Play mode, use Language from the Inspector instead of loading PlayerPrefs. Language-menu choices still save. Has no effect in built players.")]
public bool ignoreSavedLanguageInEditor
Field Value
keyboardPan
Pans with WASD / arrow keys.
public bool keyboardPan
Field Value
language
Language of the HUD and menus ("en", "ko", ...): texts come from the textTables of this language, then the English tables, then the built-in English texts. Change it at runtime with SetLanguage(string).
[Header("Text")]
[Tooltip("Language code of the HUD and menus (en, ko, ...). Missing texts fall back to English, then to the key.")]
public string language
Field Value
languagePrefsKey
PlayerPrefs key of the selected language.
public string languagePrefsKey
Field Value
leftDragPan
Pans while the left button is dragged on the battlefield (past a small threshold, not starting over UI). Off by default: the default control scheme has no drag pan, and clicks keep their normal meaning.
[Tooltip("Pan by dragging the left mouse button on the battlefield (past a small threshold, not over UI). Off by default.")]
public bool leftDragPan
Field Value
masterVolume
Scales every sound and music track.
[Header("Audio")]
[Range(0, 1)]
public float masterVolume
Field Value
musicGroup
Optional mixer group for music (works without a mixer).
[Tooltip("Optional AudioMixerGroup for music. Volumes are applied on the AudioSources either way.")]
public AudioMixerGroup musicGroup
Field Value
- AudioMixerGroup
musicVolume
Music loops and stingers (MusicPlayer).
[Range(0, 1)]
public float musicVolume
Field Value
persistLanguage
Loads the language from PlayerPrefs on enable unless Editor preview overrides it, and saves menu choices.
[Tooltip("Load the language from PlayerPrefs on enable and save it when SetLanguage changes it. App settings like this stay outside the save slots.")]
public bool persistLanguage
Field Value
persistVolumes
Loads the four volumes from PlayerPrefs on enable and saves them when they change.
[Tooltip("Load the volumes from PlayerPrefs on enable and save them when they change.")]
public bool persistVolumes
Field Value
prefsKeyPrefix
PlayerPrefs key prefix for the volumes (keys are prefix + Master/Music/Sfx/Ui).
public string prefsKeyPrefix
Field Value
sfxGroup
Optional mixer group for gameplay sounds.
[Tooltip("Optional AudioMixerGroup for gameplay sounds.")]
public AudioMixerGroup sfxGroup
Field Value
- AudioMixerGroup
sfxVolume
Gameplay sounds.
[Range(0, 1)]
public float sfxVolume
Field Value
showEarlyCallBonus
Shows the early-call gold preview on wave indicators (a product option, off by default; the reference flow has no preview).
public bool showEarlyCallBonus
Field Value
speedControls
Shows the 1x/2x/3x game speed buttons (a product feature; turn off for a single speed).
[Header("Game Speed")]
[Tooltip("Shows the 1x/2x/3x game speed buttons in the HUD.")]
public bool speedControls
Field Value
textTables
String tables (any languages). Later tables override earlier ones of the same language.
[Tooltip("String tables for the HUD and menus. Tables of the selected language are used, English tables fill the gaps.")]
public List<TextTable> textTables
Field Value
uiGroup
Optional mixer group for interface sounds.
[Tooltip("Optional AudioMixerGroup for interface sounds.")]
public AudioMixerGroup uiGroup
Field Value
- AudioMixerGroup
uiVolume
Interface sounds.
[Range(0, 1)]
public float uiVolume
Field Value
Properties
Current
The active settings in the scene, or a hidden default instance.
public static TDGameSettings Current { get; }
Property Value
Texts
Resolves HUD and menu text keys for language over textTables.
public TextResolver Texts { get; }
Property Value
Methods
EffectiveVolume(AudioChannel)
The volume a sound on channel plays at: master × channel (master alone for Master).
public float EffectiveVolume(AudioChannel channel)
Parameters
channelAudioChannel
Returns
GetLanguages(List<string>)
Language codes of the assigned tables (distinct, in list order) for a language menu.
public void GetLanguages(List<string> into)
Parameters
GetVolume(AudioChannel)
The stored (unscaled) volume of a channel.
public float GetVolume(AudioChannel channel)
Parameters
channelAudioChannel
Returns
LoadLanguage()
Reads the saved language from PlayerPrefs and switches to it (a missing key keeps language). Never throws.
public void LoadLanguage()
LoadVolumes()
Reads the four volumes from PlayerPrefs (missing keys keep the current values). Never throws.
public void LoadVolumes()
MixerGroup(AudioChannel)
The mixer group of a channel, or null (play without a mixer).
public AudioMixerGroup MixerGroup(AudioChannel channel)
Parameters
channelAudioChannel
Returns
- AudioMixerGroup
PrefsKey(AudioChannel)
PlayerPrefs key of a channel volume.
public string PrefsKey(AudioChannel channel)
Parameters
channelAudioChannel
Returns
SaveVolumes()
Writes the four volumes to PlayerPrefs and flushes them to disk. Never throws.
public void SaveVolumes()
SetLanguage(string)
Switches the HUD and menu language (for an options menu). Open HUDs relabel themselves on the next frame.
public void SetLanguage(string code)
Parameters
codestring
SetVolume(AudioChannel, float)
Sets a channel volume (clamped to 0..1) for an options menu slider; persists it when persistVolumes is on (call SaveVolumes() to flush PlayerPrefs to disk, for example when the menu closes).
public void SetVolume(AudioChannel channel, float value)
Parameters
channelAudioChannelvaluefloat
Events
LanguageChanged
Raised after SetLanguage(string) changed the language (labels refresh themselves; use it for your own menus).
public event Action<string> LanguageChanged
Event Type
VolumeChanged
Raised after a volume changed through SetVolume(AudioChannel, float) or LoadVolumes().
public event Action<AudioChannel, float> VolumeChanged