public void Play(AudioSource3D source, AudioClip[] soundpack) { if (soundpack.Length != 0) { source.PlayOneShot(soundpack[Random.Range(0, soundpack.Length)]); } }
protected void Update() { pace = 10 * time.DeltaTime; if (camTarget) { camera.position = Vector3.Lerp(camera.position, camTarget.position, pace); camera.rotation = Quaternion.Lerp(camera.rotation, camTarget.rotation, pace); } if (!active) { return; } if (Input.GetKeyDown(KeyCode.DownArrow)) { selected = (selected + 1) % options.Length; source.PlayOneShot(move); } if (Input.GetKeyDown(KeyCode.UpArrow)) { selected = (options.Length + selected - 1) % options.Length; source.PlayOneShot(move); } if (Input.GetKeyDown(KeyCode.Return)) { options[selected].onClick.Invoke(); source.PlayOneShot(select); } RectTransform target = (RectTransform)options[selected].transform; selector.localPosition = Vector3.Lerp(selector.localPosition, target.localPosition + posOffset, pace); selector.sizeDelta = Vector3.Lerp(selector.sizeDelta, target.sizeDelta + scaleOffset, pace); }
public void PlaySound(AudioClip Sound, float Volume = -1, bool Static = false) { Source.PlayOneShot(Sound, Volume == -1 ? Source.Volume : Volume, Static); }