Adventure Creator Wikia
Advertisement

By default, the game will automatically switch to the next scene once it has finished loading. However, it is possible to wait for some other event (e.g. user input) before this occurs. In this example script, the game will wait for the Space bar to be pressed before the scene transition completes. This works both with and without dedicated loading screens.

To use it:

  1. Under the Settings Manager's "Scene loading" section, check both Load scenes asynchronously? and Scene loading requires manual activation?.
  2. Create a new C# script named CompleteLoadingExample, and paste in the code below.
  3. Place the new Complete Loading Example in the scene you are loading from. To have it work in all scenes automatically, attach it to the PersistentEngine prefab in /Assets/AdventureCreator/Resources.

CompleteLoadingExample.cs:

using UnityEngine;
using AC;

public class CompleteLoadingExample : MonoBehaviour
{

	private bool isAwaitingInput = false;

	void OnEnable ()
	{
		AC.EventManager.OnAwaitSceneActivation += OnAwaitSceneActivation;
	}

	void OnDisable ()
	{
		AC.EventManager.OnAwaitSceneActivation -= OnAwaitSceneActivation;
	}

	void Update ()
	{
		if (isAwaitingInput && Input.GetKeyDown (KeyCode.Space))
		{
			KickStarter.sceneChanger.ActivateLoadedScene ();
			isAwaitingInput = false;
		}
	}

	void OnAwaitSceneActivation (string nextSceneName)
	{
		Debug.Log ("Scene loaded - press the Space bar to continue");
		isAwaitingInput = true;
	}

}
Advertisement