- Home /
Question by
davidflynn2 · Jul 04, 2013 at 07:34 PM ·
js-c#js - c#
Convert js to C# Serializer problem
I have been working with the Unityserializer and I am wanting to convert over the loadgame from js to C# but I cant seem to get it correct.
Here is the original that works js:
import System.Collections.Generic;
function OnGUI()
{
for(var sg in LevelSerializer.SavedGames[LevelSerializer.PlayerName])
{
if(GUILayout.Button(sg.Caption))
{
LevelSerializer.LoadNow(sg.Data);
Time.timeScale = 1;
}
}
}
Here is the C# I have been working with so far that does not work:
using UnityEngine;
using System.Collections;
public class loadGame : MonoBehaviour
{
void OnGUI ()
{
for(var sg in LevelSerializer.SavedGames[LevelSerializer.PlayerName])
{
if(GUILayout.Button(sg.Caption))
{
LevelSerializer.LoadNow(sg.Data);
Time.timeScale = 1;
}
}
}
}
Comment
Best Answer
Answer by RalphTrickey · Jul 04, 2013 at 07:47 PM
Try changing
for(var sg in LevelSerializer.SavedGames[LevelSerializer.PlayerName])
to
foreach(var sg in LevelSerializer.SavedGames[LevelSerializer.PlayerName])
What error are you getting?
Your answer
Follow this Question
Related Questions
Create a guitexture When clicked on 3d text? 0 Answers
js to C# converstion Problem 3 Answers
.js to C# conversion 4 Answers
How would i convert this from JS into C#? 2 Answers
Gameobject variable on C# 1 Answer