diff --git a/Assets/Fungus/FungusScript/Commands/LoadScene.cs b/Assets/Fungus/FungusScript/Commands/LoadScene.cs new file mode 100644 index 00000000..f57cb24e --- /dev/null +++ b/Assets/Fungus/FungusScript/Commands/LoadScene.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using System; +using System.Collections; + +namespace Fungus.Script +{ + [HelpText("Loads a new scene and displays an optional loading image. This is useful " + + "for splitting a large game across multiple scene files to reduce peak memory " + + "usage. All previously loaded assets (including textures and audio) will be released." + + "The scene to be loaded must be added to the scene list in Build Settings.")] + public class LoadScene : FungusCommand + { + public string sceneName = ""; + + public Texture2D loadingImage; + + public override void OnEnter() + { + SceneLoader.LoadScene(sceneName, loadingImage); + } + + public override string GetSummary() + { + if (sceneName.Length == 0) + { + return "Error: No scene name selected"; + } + + return sceneName; + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/LoadScene.cs.meta b/Assets/Fungus/FungusScript/Commands/LoadScene.cs.meta new file mode 100644 index 00000000..0ee92055 --- /dev/null +++ b/Assets/Fungus/FungusScript/Commands/LoadScene.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 00d03ae0919f04264b018681ed534177 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Fungus/FungusScript/Scripts/SceneLoader.cs b/Assets/Fungus/FungusScript/Scripts/SceneLoader.cs index 7d68ebd2..889d9915 100644 --- a/Assets/Fungus/FungusScript/Scripts/SceneLoader.cs +++ b/Assets/Fungus/FungusScript/Scripts/SceneLoader.cs @@ -15,15 +15,13 @@ namespace Fungus Texture2D loadingTexture; string sceneToLoad; bool displayedImage; - bool saveCheckpoint; /** * Asynchronously load a new scene. * @param _sceneToLoad The name of the scene to load. Scenes must be added in project build settings. * @param _loadingTexture Loading image to display while loading the new scene. - * @param _saveCheckpoint Automatically save a checkpoint once the new scene has loaded. */ - static public void LoadScene(string _sceneToLoad, Texture2D _loadingTexture, bool _saveCheckpoint) + static public void LoadScene(string _sceneToLoad, Texture2D _loadingTexture) { // Unity does not provide a way to check if the named scene actually exists in the project. GameObject go = new GameObject("SceneLoader"); @@ -32,7 +30,6 @@ namespace Fungus SceneLoader sceneLoader = go.AddComponent(); sceneLoader.sceneToLoad = _sceneToLoad; sceneLoader.loadingTexture = _loadingTexture; - sceneLoader.saveCheckpoint = _saveCheckpoint; } void Start() @@ -71,16 +68,6 @@ namespace Fungus // Clean up any remaining unused assets Resources.UnloadUnusedAssets(); - // Save a checkpoint if required - if (saveCheckpoint) - { - Game game = Game.GetInstance(); - if (game != null) - { - // Game.Save(); - } - } - // We're now finished with the SceneLoader Destroy(gameObject); } diff --git a/Assets/Fungus/Legacy/Scripts/Game.cs b/Assets/Fungus/Legacy/Scripts/Game.cs index ced06878..41a26ade 100644 --- a/Assets/Fungus/Legacy/Scripts/Game.cs +++ b/Assets/Fungus/Legacy/Scripts/Game.cs @@ -116,18 +116,6 @@ namespace Fungus return false; } - /** - * Loads a new scene and displays an optional loading image. - * This is useful for splitting a large Fungus game across multiple scene files to reduce peak memory usage. - * All previously loaded assets (including textures and audio) will be released. - * @param sceneName The filename of the scene to load. - * @param saveGame Automatically save the current game state as a checkpoint. - */ - public void LoadScene(string sceneName, bool saveGame) - { - SceneLoader.LoadScene(sceneName, loadingImage, saveGame); - } - /** * Save the current game variables to persistant storage using a save game name. * Stores the currently loaded scene name so that Game.LoadGame() can automatically move to the appropriate scene. diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 0d11c0f0..445abeb7 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 47d2554a..6cb6612e 100644 Binary files a/ProjectSettings/EditorBuildSettings.asset and b/ProjectSettings/EditorBuildSettings.asset differ