1
0
mirror of synced 2024-11-14 10:07:40 +01:00

Cleanup excessive control panel audio sources

This commit is contained in:
Kylemc1413 2022-05-29 09:55:37 -04:00
parent 2ff13e1cd3
commit f2aeaa936e
5 changed files with 238 additions and 700 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@ using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
[RequireComponent(typeof(AudioSource))]
public class LocomotionToggle : MonoBehaviour
{
[System.Serializable]
@ -45,7 +44,6 @@ public class LocomotionToggle : MonoBehaviour
locoEvent = new LocomotionToggleEvent();
audioSrc = GetComponent<AudioSource>();
audioSrc.playOnAwake = false;
soundOn = Resources.Load<AudioClip>("Audio/loco on");
soundOff = Resources.Load<AudioClip>("Audio/loco off");

View File

@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
using UnityEngine;
using WindowsInput.Native;
[RequireComponent(typeof(AudioSource))]
public class PanelButton : MonoBehaviour
{
[DllImport("user32.dll")]
@ -25,18 +24,12 @@ public class PanelButton : MonoBehaviour
private Renderer cr;
public GameObject camera;
private AudioSource audioSrc;
private static AudioClip btnSound;
public AudioSource audioSrc;
void Start()
{
btnSound = Resources.Load<AudioClip>("Audio/button press");
cr = GetComponent<Renderer>();
audioSrc = GetComponent<AudioSource>();
audioSrc.playOnAwake = false;
audioSrc.clip = btnSound;
if (isToggle)
{
// initialize toggle state
@ -50,7 +43,7 @@ public class PanelButton : MonoBehaviour
_insideColliderCount += 1;
ButtonPress();
if (doesBeep)
audioSrc.Play();
audioSrc?.Play();
}
private void OnTriggerExit(Collider other)

View File

@ -20,8 +20,6 @@ public class PanelHiderButton : MonoBehaviour
[SerializeField]
private Image timerRing;
[SerializeField]
private AudioSource audioSrc;
[SerializeField]
private List<GameObject> panelButtons;
[Header("Assets")]
@ -34,8 +32,10 @@ public class PanelHiderButton : MonoBehaviour
[SerializeField]
private AudioClip unlockSound;
private AudioSource audioSrc;
private void Start()
{
audioSrc = GetComponent<AudioSource>();
r = GetComponent<Renderer>();
statusImg.texture = isLocked ? lockImg : unlockImg;
audioSrc.clip = lockSound;

View File

@ -3,22 +3,16 @@ using System.Runtime.InteropServices;
using UnityEngine;
using WindowsInput.Native;
[RequireComponent(typeof(AudioSource))]
public class PanelThirdPersonButton : MonoBehaviour
{
public bool isTP;
private Renderer cr;
public GameObject tpCamera;
private AudioSource audioSrc;
private static AudioClip btnSound;
public AudioSource audioSrc;
void Start()
{
btnSound = Resources.Load<AudioClip>("Audio/button press");
audioSrc = GetComponent<AudioSource>();
audioSrc.playOnAwake = false;
audioSrc.clip = btnSound;
cr = GetComponent<Renderer>();