Need Help - Last Problem Converting PC to Android - Using JS to read CS

I managed to fix all of my code that was conflicting with Android specific rules (dynamics vs static, etc). All but one that is…

I am not good with C# (…yet) so all my scripts are done in JS. All but one that is…

I have a C# script that uses the built in serialization to save/load my ‘game saves’. I have a couple JS files that allow me to interact with the C# file. See the following link for full details:

http://forum.unity3d.com/threads/94997-Need-Help-Save-Load?p=619994&viewfull=1#post619994

Everything was working great in the PC/Mac version but I am having a problem with Android. If I could just get this one chunk working, I will understand how to fix the rest.

if(firstRun){
            firstRun = false;
            var script = GameObject.Find("Level").GetComponent("SaveAndLoad");

            //Slot 1
            script.SendMessage("Load","./saves/SaveData_1.agt");
            saveInfo[0] = GameObject.Find("Level").GetComponent.<LoadData>().data;

            //Slot 2
            script.SendMessage("Load","./saves/SaveData_2.agt");
            saveInfo[1] = GameObject.Find("Level").GetComponent.<LoadData>().data;

            //Slot 3
            script.SendMessage("Load","./saves/SaveData_3.agt");
            saveInfo[2] = GameObject.Find("Level").GetComponent.<LoadData>().data;

            //Slot 4
            script.SendMessage("Load","./saves/SaveData_4.agt");
            saveInfo[3] = GameObject.Find("Level").GetComponent.<LoadData>().data;

            //Slot 5
            script.SendMessage("Load","./saves/SaveData_5.agt");
            saveInfo[4] = GameObject.Find("Level").GetComponent.<LoadData>().data;

            //Slot 6
            script.SendMessage("Load","./saves/SaveData_6.agt");
            saveInfo[5] = GameObject.Find("Level").GetComponent.<LoadData>().data;

            //Debug Info
            for(var i=0; i<saveInfo.length; i++){
                **Debug.Log("SlotSelection caching "+i+": "+saveInfo_.levelReached);**_

}
}
The error I am getting is:
> Assets/Scripts/MainMenu/SlotSelection.js(47,71):
> BCE0019: ‘levelReached’ is not a
> member of ‘Object’.
“levelReached” is a public variable defined in the SaveAndLoad.cs file. It is included with other variables and “packed up” into a single variable called “data”. I’m not sure exactly how it works but the C# code looks like this:
**data = (SaveData)bformatter.Deserialize(stream);
GameObject.Find(“Level”).SendMessage(“LoadData”,data);**
If anyone can help me get the “levelReached” value out of “data”, I can fix all the rest of my problems and finally test this thing…

Your saveInfo variable is declared wrong. My guess is it is:

var saveInfo = new Array();

when it needs to be:

var saveInfo = new LoadData[5];

The problem was partly answered by Warwick’s post but one thing that I was also missing… The C# file was in the same folder with the JS files. I read that they cannot be loaded/executed at the same time and one needs to be in the “Standard Assets” or “Plugins” folder. I moved the C# script to the standard assets folder and I am now able to access “SaveAndLoad” and “SaveData” as a valid ‘type’ and as such, I can now do:

var saveInfo = new SaveData[5];

And voila, almost every single error I had just disappeared (now to replicate to the other files as needed and I’m done!)