0
나는 안드로이드 게임을 만들었고, 앤드 로이드로 게임을하려고 할 때 막 완성되었습니다. 아무것도 태어나지 않습니다. 내 생각에 모든 위치를 유지하는 책임이있는 파일과 관련이 있다고 생각합니다. 이 문제를 해결하도록 도와주세요.안드로이드에서 ".dat"파일을 비 직렬화하는 Unity?
public class DataHolder : MonoBehaviour
{
public static DataHolder dataholder;
public MazeData currentmaze;
void Awake()
{
if (dataholder == null)
{
dataholder = this;
}
else
{
Destroy(this.gameObject);
}
string directory = Application.dataPath + "/LevelData/"; ;
int number =Convert.ToInt32(SceneManager.GetActiveScene().name) -1;
if (File.Exists(directory + "/Level_" + number.ToString() + "/Level_" + number.ToString() + ".dat"))
{
BinaryFormatter binary = new BinaryFormatter();
FileStream file = File.Open(directory + "/Level_" + number.ToString() + "/Level_" + number.ToString() + ".dat", FileMode.Open);
MazeData _level = (MazeData)binary.Deserialize(file);
currentmaze = _level;
file.Close();
}
}
}
이 줄
string directory = Application.dataPath + "/LevelData/"; ;
을 변경하려면 먼저 나는 수의 값을 출력한다. 그런 다음 검색 할 파일의 이름을 확인합니다. 그렇다면 그것이 발견되었는지 여부. 기본적으로 if 문 안에서 인쇄 할 수 있습니까? – Everts
@Everts code please –
무엇을 원하십니까? 아니, 제발 코드? 나는 묻는 사람인가? 나는 당신에게 무슨 일이 일어나고 있는지 추적 할 수 있도록 코드에 인쇄물을 넣으라고 말하고 있습니다. – Everts