I already used the same Script for a Dropdown but after I replaced it with the Toggle, I got a Error in the Console after I check or uncheck the Toggle:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using BayatGames.SaveGameFree;
public class WRITE_VRCheckbox : MonoBehaviour
{
// ==================== VR-Mode Checkbox ====================
public Toggle _WriteToggle;
private void Start()
{
Application.targetFrameRate = 60;
_WriteToggle.onValueChanged.AddListener(delegate
{
VRActiveCheckboxSettingsValueWechselPassiert(_WriteToggle);
});
}
//This here will be executed as soon the checkbox toggle is checked or unchecked:
public void VRActiveCheckboxSettingsValueWechselPassiert(Toggle transmitter)
{
SaveGame.Encode = false;
// Speichert den gewechselten Wert sofort ein:
SaveGame.Save<bool>("meineVRActivecheckbox", _WriteToggle.isOn);
if (transmitter.isOn)
{
//================================================================
// This area is reserved for future scripts...
}
}
}