2023-06-17 13:48:59 +02:00

71 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Kann sein das das nur für statische Objekte funktioniert
public class DimShift : MonoBehaviour
{
// 0 = inactive in Dimension 1
// 1 = active in Dimension 1
public bool inFirstDim;
AudioSource Audio1;
AudioReverbFilter Rev1;
AudioLowPassFilter lpf;
GameObject Dim1;
GameObject Dim2;
void Start()
{
Dim1 = GameObject.Find("Dim1");
Dim2 = GameObject.Find("Dim2");
Audio1 = GameObject.Find("AudioController").GetComponent<AudioSource>();
Rev1 = GameObject.Find("AudioController").GetComponent<AudioReverbFilter>();
lpf = GameObject.Find("AudioController").GetComponent<AudioLowPassFilter>();
if (inFirstDim)
{
Dim1.SetActive(true);
Dim2.SetActive(false);
MusicDim1();
} else
{
Dim1.SetActive(false);
Dim2.SetActive(true);
MusicDim2();
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftShift)&&inFirstDim)
{
Dim2.SetActive(true);
Dim1.SetActive(false);
MusicDim2();
inFirstDim = !inFirstDim;
} else
{
if (Input.GetKeyDown(KeyCode.LeftShift)&&!inFirstDim)
{
Dim1.SetActive(true);
Dim2.SetActive(false);
MusicDim1();
inFirstDim = !inFirstDim;
}
}
}
void MusicDim1()
{
Rev1.enabled = false;
lpf.enabled = false;
}
void MusicDim2()
{
Rev1.enabled = true;
lpf.enabled = true;
}
}