An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

10 years ago
using UnityEngine;
using UnityEngine.Serialization;
10 years ago
using System;
using System.Collections;
namespace Fungus
10 years ago
{
[CommandInfo("Flow",
"Load Scene",
"Loads a new Unity scene and displays an optional loading image. This is useful " +
"for splitting a large game across multiple scene files to reduce peak memory " +
"usage. Previously loaded assets will be released before loading the scene to free up memory." +
"The scene to be loaded must be added to the scene list in Build Settings.")]
[AddComponentMenu("")]
public class LoadScene : Command, ISerializationCallbackReceiver
10 years ago
{
#region Obsolete Properties
[HideInInspector] [FormerlySerializedAs("sceneName")] public string sceneNameOLD;
#endregion
[Tooltip("Name of the scene to load. The scene must also be added to the build settings.")]
public StringData _sceneName = new StringData("");
10 years ago
[Tooltip("Image to display while loading the scene")]
10 years ago
public Texture2D loadingImage;
public override void OnEnter()
{
SceneLoader.LoadScene(_sceneName.Value, loadingImage);
10 years ago
}
public override string GetSummary()
{
if (_sceneName.Value.Length == 0)
10 years ago
{
return "Error: No scene name selected";
}
return _sceneName;
10 years ago
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
//
// ISerializationCallbackReceiver implementation
//
public virtual void OnBeforeSerialize()
{}
public virtual void OnAfterDeserialize()
{
if (sceneNameOLD != default(string))
{
_sceneName.Value = sceneNameOLD;
sceneNameOLD = default(string);
}
}
10 years ago
}
}