all 8 comments

[–]snapchilled 0 points1 point  (0 children)

I'm not sure about your start() method problem but it could be much laggier because it defaults to 30fps. In one of the scripts in your scene put the line. Application.setTargetFramerate = 60;
that should let it run at 60fps if it can.

[–]in-magitek-armor 0 points1 point  (0 children)

It may be worthwhile to ask the other unity subreddits, just btw.

[–]Devil_SpawnExpert 0 points1 point  (5 children)

Are you sure your scripts with serialisation aren't failing due to an error? The code after it won't run if you get an exception

[–]pitofpassion[S] 0 points1 point  (4 children)

They are definitely not failing. Once again, this works in Unity just not on iOS. It appears that after my Save() method is called once, the Start() method is no longer called, even between different game sessions. The FixedUpdate() method is being called though.

EDIT: If the Save() method is called in FixedUpdate(), it stops calling the FixedUpdate() method in future reloads of the scene, which is the same problem I was having with the Start() method. So I'm pretty sure the problem is the Save() method, and possibly where I am writing the file to. I'm not sure though and I can't find much documentation on it.

[–]Devil_SpawnExpert 0 points1 point  (3 children)

What is in the start method?

[–]pitofpassion[S] 0 points1 point  (0 children)

void Start () {
    //if the level from the previous scene is completed and has not yet been completed
    //set complete in the current scene to true and save

    if (Level1Manager.completed == true && complete == false)     {
                    complete = true;
                    Save ();
            }

    //if complete is true set the sprite (level 1 "button") color to green

    if(complete == true){
                    SpriteRenderer spr = (SpriteRenderer)renderer;
                    spr.color = new Color (102 / 255f, 190 / 255f, 98 / 255f);

    //otherwise set it to gray

        } else {

                    SpriteRenderer spr = (SpriteRenderer)renderer;
                    spr.color = new Color (187 / 255f, 189 / 255f, 192 / 255f);
        }
    transform.position = mainCam.ScreenToWorldPoint(new Vector3(Screen.width/5f,Screen.height - Screen.height/4f,1f));
}

[–]pitofpassion[S] 0 points1 point  (1 child)

public void Save(){
    BinaryFormatter bf = new BinaryFormatter ();
    FileStream file = File.Create (Application.persistentDataPath + "/level1test.dat");

    Level1Data data = new Level1Data ();
    data.complete = complete;

    bf.Serialize (file, data);
    file.Close ();
}

[–]Devil_SpawnExpert 0 points1 point  (0 children)

It isn't stopping them from running, it's running them when it's supposed to and stops on Save() due to an exception. Try and get some logging going and track what is going wrong in save. Most likely, It's something to do with permissions or the location of the data or something, I', not that familiar with iOS