Log in or register to post comments

restart / reset scene

April 15, 2013 - 9:51am #1

Is there is simple method for resetting the scene to it's initial state.  I would like to have a button that will restart the ARCamera without having to restart the application itself.  

restart / reset scene

April 15, 2013 - 12:31pm #6

Alternatively you could asynchronously reload the level which would give you the opportunity to present the user with a loading spinner, a transition screen, or execute some other code until your scene is loaded and ready to go like this (Unity Pro required):

public bool isLoading = false;
public string level;
	
	public IEnumerator LoadScene()
	{
		// If the level is not already loading, load it (prevents double tap loads)
		if(!isLoading)
		yield return StartCoroutine("LoadLevelAsync");
	}
	
	IEnumerator LoadLevelAsync() 
	{
		isLoading = true;	
		#if UNITY_ANDROID
		// Android Loading Spinner (or w/e else)
		#endif
		#if UNITY_IOS
		// iOS Loading Spinner (or w/e else)
		#endif
		// Start async level load
		AsyncOperation async = Application.LoadLevelAsync(level);
		Debug.Log("Loading... (Async)");
		while(!async.isDone) {
			Debug.Log("Loading... " + async.progress);
			yield return null;
		}
	}

 

restart / reset scene

April 15, 2013 - 11:32am #5

Ah!  Got it!   I just need to call Application.LoadLevel to "restart" the scene?  :)

restart / reset scene

April 15, 2013 - 11:29am #4

What do you want to retain that will be lost if you simply reload the scene using Application.LoadLevel? That method will cause the ARCamera to reinitialize w/ the targets that you configure for that scene.

restart / reset scene

April 15, 2013 - 11:26am #3

On target found.  So I guess the entire scene?  I basically want to have the ability to reset all my game objects to their original state.   Some of them are dynamic and move over time, so a simple reset button to bring them back to the first time the ARCamera locates them.

restart / reset scene

April 15, 2013 - 10:41am #2

Which aspects of the scene do you want to reset?

Log in or register to post comments