Hello all,
Is there a way via code to check how many times a specific scene is loaded? I’d like to use the number of times one of my scenes is played in order to trigger an event. It seems like this was a bit easier to do in earlier releases in unity, but every method I try to use seems to yield nothing.
This is what my code looks like:
public class ToTheLivingRoom : MonoBehaviour {
public bool thermoGet;
public bool compGet;
public bool bearGet;
public Flowchart flowchart;
public int loadTimes= 0;
Scene scene = SceneManager.GetSceneByName("Office");
public bool sceneActive;
// Use this for initialization
void Start () {
flowchart = GameObject.FindObjectOfType<Flowchart>();
bearGet = flowchart.GetVariable("BearGet");
thermoGet = flowchart.GetVariable("ThermoGet");
compGet = flowchart.GetVariable("CompGet");
}
void Awake()
{
sceneActive = true;
}
// Update is called once per frame
void Update () {
//if (scene.name("Office"))
//{
// sceneActive == true;
//}
if (sceneActive == true)
{
loadTimes += 1;
Debug.Log("The Office has loaded this many times:" + 1);
}
if (loadTimes == 3)
{
if (bearGet && thermoGet && compGet == true)
{
flowchart.ExecuteBlock("A warning (Copy)");
}
}
}
}
As a note I am using fungus and referencing it in code, so I’m not sure if it’s the two systems not playing nice or something I’m missing.
Thanks!