using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using PixelCrushers;
namespace MoreMountains.InventoryEngine
{
/// <summary>
/// An example of a game manager, the only significant part being how we trigger in a single place the load of all inventories, in the Start method.
/// </summary>
public class InventoryDemoGameManager : Singleton<InventoryDemoGameManager>
{
public InventoryDemoCharacter Player { get; protected set; }
bool bad;
public SaveSystem saveobj;
protected override void Awake ()
{
base.Awake ();
if(bad){
Player = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryDemoCharacter>() ;
}
}
void OnApplicationQuit(){
MMGameEvent.Trigger("Save");
saveobj.SaveGameToSlot(0);
}
/// <summary>
/// On start, we trigger our load event, which will be caught by inventories so they try to load saved content
/// </summary>
protected virtual void Start()
{
MMGameEvent.Trigger("Load");
StartCoroutine(wait());
}
IEnumerator wait(){
yield return new WaitForSeconds(2f);
saveobj.LoadGameFromSlot(0);
}
}
}
Did you add the HideAndSeek quest to the quest database that's assigned to the Quest Machine GameObject?
Note: In the current version, the 'Add All Quests In Scene' button has a bug. It doesn't mark the database changes to be saved to disk, so they're not saved when you quit and restart Unity. It's fixed in the version pending release on the Asset Store. In the meantime, please add quests manually to the quest database.
Also make sure the Quest Machine GameObject is present at the time that your manager script calls saveobj.LoadGameFromSlot(0).
I have only 1 more issue, I have an active saver script on my gameobject that holds the items for the quest,
The save and load on this dont seem to be working, although im not sure if im doing it right,
I have the active saver on the object I want to save (its state and its childrens state), do i need to place an active saver on all the children or am i doing it right ?
If i am doing it right how would i debug why its not saving ?
Make sure the Active Saver is not on the GameObject that you want to save. Also make sure it has a unique key.
Tick the Debug checkboxes on the Save System component and the PlayerPrefs Saved Game Data Storer or Disk Saved Game Data Storer. When you load, it will log a JSON representation of the saved game data. Look for the Active Saver's key and its corresponding true/false value.
If the value looks correct, something else may be forcing the target into whatever state it's in after the Active Saver sets its state.
The gameobject itself is actually saving but the state of the child game objects of the saved gameobjects is not being saved,
What is the correct way to go about ensuring the child objects states are being saved as well as the parent?
should i be adding an active saver for each?
is there a more elegant way to put them all into an array and save that or something ? ( I will have like 300 items that need their status saved if they need to be individual)
Yes. The next version has a Multi Active Saver component. When I get back to the office in about 45 minutes, I'll send you a package with this component.