I have this function that is supposed to save a string however I’m getting an error saying: (23,16): error CS0136: A local or parameter named ‘dataPath’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter I did use this once for a pc game and it worked, the game i’m working on is a iOS game does that have anything to do with it?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public class MainMenuDataManager : MonoBehaviour
{
public static MainMenuDataManager instance;
public string currentLanguageData = "/CurrentLanguage.dat";
private void Awake()
{
if (instance == null)
instance = this;
}
public void SaveString(string dataPath, string stringToSave)
{
BinaryFormatter formatter = new BinaryFormatter();
string dataPath = Application.persistentDataPath + stringToSave;
FileStream stream = new FileStream(dataPath, FileMode.Create);
MainMenuData mainMenuData = new MainMenuData();
mainMenuData.currentLanguageData = stringToSave;
formatter.Serialize(stream, mainMenuData);
stream.Close();
}
}