1 using System.Collections;
2 using System.Collections.Generic;
5 using Unity.Collections;
16 [Header(
"Airplane Audio Properties")]
17 [Tooltip(
"Attach base input script to audio group; Drag and drop that script component on input")]
18 [ReadOnly][SerializeField]
20 [Tooltip(
"Create empty Gameobject - idleSource, add audiosource to it; add audio idleSource file to audiosource; Drag and drop that game object on idleSource")]
21 [ReadOnly][SerializeField]
22 private AudioSource idleSource;
23 [Tooltip(
"Create empty Gameobject - fullThrottleSource, add audiosource to it; add audio fullThrottleSource file to audiosource; Drag and drop that game object on fullThrottleSource")]
24 [ReadOnly][SerializeField]
25 private AudioSource fullThrottleSource;
26 private float maxPitchValue = 1.5f;
28 private float fullVolumeValue;
29 private bool isShutOff =
false;
30 private float finalPitchValue;
32 private float fadeVolumeRate = 0.005f;
33 private bool currentEnableAudio =
true;
38 public bool ShutEngineOff
40 set{isShutOff = value;}
45 #region Builtin Methods
50 idleSource = GameObject.Find(CommonFunctions.ActiveAirplane+
"/Audio_GRP/Idle").GetComponent<AudioSource>();
51 fullThrottleSource = GameObject.Find(CommonFunctions.ActiveAirplane+
"/Audio_GRP/FullThrottle").GetComponent<AudioSource>();
52 if(fullThrottleSource)
54 fullThrottleSource.volume = 0f;
65 if(StaticAudioSchema.IsActive)
67 idleSource.enabled = StaticAudioSchema.EnableAudio;
68 fullThrottleSource.enabled = StaticAudioSchema.EnableAudio;
69 currentEnableAudio = StaticAudioSchema.EnableAudio;
71 Debug.unityLogger.Log(
" Audio set to : "+ StaticAudioSchema.EnableAudio);
72 StaticAudioSchema.IsActive =
false;
85 fullThrottleSource.volume -= fullThrottleSource.volume * fadeVolumeRate;
86 idleSource.volume -= idleSource.volume * fadeVolumeRate;
93 #region Custom Methods
94 protected virtual void HandleAudio()
98 fullVolumeValue = Mathf.Lerp(0f,1f,input.StickyThrottle);
99 finalPitchValue = Mathf.Lerp(1f,maxPitchValue,input.StickyThrottle);
100 if(fullThrottleSource)
102 fullThrottleSource.volume = fullVolumeValue;
103 fullThrottleSource.pitch = finalPitchValue ;