Play tutorial only once with different scenes

Hi guys! I am creating an AR Alphabet app where there are two scenes, the Main Menu and the Alphabet. What I am trying to do is I want to show a tutorial image for the first time the user used the app then nothing more to show after the user uses it again for another time. This is what I did so far…


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Tutorial : MonoBehaviour {

public GameObject tutorialPanel;

// Use this for initialization
void Start () {

	PlayerPrefs.SetInt ("TutorialPlayed",0);

	if (PlayerPrefs.GetInt ("TutorialPlayed", 0) <= 0) {
		tutorialPanel.SetActive (true);
		PlayerPrefs.SetInt ("TutorialPlayed", 1);
	}
	
}

}


This code is placed in a holder from the Alphabet scene and is working but not what I had in mind. So I play the scene from Main Menu, then go straight to Alphabet scene. The tutorial appears and when I go back to Main Menu and open the Alphabet again, the tutorial appears again. It seems that it sets the PlayerPerfs in the Alphabet scene only and when I try to change scenes it just resets again from 0 instead of having it stuck at 1. Any ideas?

Hi @jessie_embiado, your first line of the Start function sets TutorialPlayed to 0… just remove this line. The next line will succeed because the GetInt defaults to 0 and then the value will be set to 1 after that. Hope that helps!