Browse Source

Added LoadGlobals, SaveGlobals and DestroyOnSceneLoad tag

master
chrisgregan 10 years ago
parent
commit
e1c4eacc4d
  1. 24
      Assets/Fungus/FungusScript/Commands/LoadGlobals.cs
  2. 8
      Assets/Fungus/FungusScript/Commands/LoadGlobals.cs.meta
  3. 1
      Assets/Fungus/FungusScript/Commands/LoadScene.cs
  4. 24
      Assets/Fungus/FungusScript/Commands/SaveGlobals.cs
  5. 8
      Assets/Fungus/FungusScript/Commands/SaveGlobals.cs.meta
  6. 7
      Assets/Fungus/FungusScript/Scripts/SceneLoader.cs

24
Assets/Fungus/FungusScript/Commands/LoadGlobals.cs

@ -0,0 +1,24 @@
using UnityEngine;
using System;
using System.Collections;
namespace Fungus.Script
{
[CommandName("Load Globals")]
[HelpText("Loads a set of global variables previously saved using the SaveGlobals command.")]
public class LoadGlobals : FungusCommand
{
public string saveName = "";
public override void OnEnter()
{
GlobalVariables.Load(saveName);
}
public override string GetSummary()
{
return saveName;
}
}
}

8
Assets/Fungus/FungusScript/Commands/LoadGlobals.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23c657364a3b24e16bdf5946729a8b7b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

1
Assets/Fungus/FungusScript/Commands/LoadScene.cs

@ -4,6 +4,7 @@ using System.Collections;
namespace Fungus.Script
{
[CommandName("Load Scene")]
[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." +

24
Assets/Fungus/FungusScript/Commands/SaveGlobals.cs

@ -0,0 +1,24 @@
using UnityEngine;
using System;
using System.Collections;
namespace Fungus.Script
{
[CommandName("Save Globals")]
[HelpText("Saves all current global variables to be loaded again later using the LoadGlobals command. This provides a basic save game system.")]
public class SaveGlobals : FungusCommand
{
public string saveName = "";
public override void OnEnter()
{
GlobalVariables.Save(saveName);
}
public override string GetSummary()
{
return saveName;
}
}
}

8
Assets/Fungus/FungusScript/Commands/SaveGlobals.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1bef7966140464bd5a3ef4da2ff236b9
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

7
Assets/Fungus/FungusScript/Scripts/SceneLoader.cs

@ -46,7 +46,12 @@ namespace Fungus
yield return new WaitForEndOfFrame();
}
// TODO: Destroy all objects to release references to most game assets
// Destroy tagged objects to release asset references
GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("DestroyOnSceneLoad");
foreach (GameObject go in gameObjects)
{
DestroyImmediate(go);
}
// Wait for objects to actually be destroyed at end of run loop
yield return new WaitForEndOfFrame();

Loading…
Cancel
Save