Hi, I tried DontDestroyOnLoad and Application.LoadLevel and the object is constantly created in the second level. Why is this?
using UnityEngine;
using System.Collections;
public class BacktrackingTest : MonoBehaviour
{
public float float1 = 420;
public float float2 = 9000;
private bool LevelLoaded = false;
void Start ()
{
DontDestroyOnLoad(gameObject);
//Data transfer between unity scenes test, does it subtract twice?
float2 = float2 - float1;
}
void FixedUpdate ()
{
if(Time.time>5 && LevelLoaded==false)
{
Application.LoadLevel(1);
LevelLoaded=true;
}
}
}
↧