chunk 1: core gameplay scripts scenes runtime assets

This commit is contained in:
2026-04-06 11:02:34 +03:00
parent fa0388bc79
commit 0d11a097d8
703 changed files with 2292651 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToggleHandler : MonoBehaviour
{
//Each Toggle Array takes in values associated with each other, such as ON and OFF
//Audio & Graphics Settings
public GameObject[] GraphicsToggles;
public GameObject[] FrameRateToggles;
public GameObject[] ScreenVibrationToggles;
//Controller Settings
public GameObject[] ControllerSupportToggles;
//Language Settings
public GameObject[] LanguageToggles;
// Start is called before the first frame update
void Start()
{
AttachToggleListener(GraphicsToggles); //Attach listener to GraphicsToggles
AttachToggleListener(FrameRateToggles); //Attach listener to FrameRateToggles
AttachToggleListener(ScreenVibrationToggles); //Attach listener to ScreenVibrationToggles
AttachToggleListener(ControllerSupportToggles); //Attach listener to ControllerSupportToggles
AttachToggleListener(LanguageToggles); //Attach listener to LanguageToggles
}
// Update is called once per frame
void Update()
{
}
// Function called to keep track of toggle interaction
void AttachToggleListener(GameObject[] toggleArray){
// Loop through each toggle to add a listener to its Toggle component
foreach (GameObject toggleObj in toggleArray){
Toggle toggle = toggleObj.GetComponent<Toggle>();
if (toggle != null)
{
toggle.onValueChanged.AddListener((isSelected) => OnToggleValueChanged(toggleArray, toggle));
}
else
{
Debug.LogError("GameObject does not have a Toggle component!");
}
}
}
// Called when any toggle's value changes
void OnToggleValueChanged(GameObject[] toggleArray, Toggle selectedToggle)
{
if (selectedToggle.isOn)
{
// Deselect all other toggles
foreach (GameObject toggleObj in toggleArray)
{
Toggle toggle = toggleObj.GetComponent<Toggle>();
if (toggle != null && toggle != selectedToggle)
{
toggle.isOn = false;
}
}
}
}
}