Load Game (PlayerPrefs) via dialogue.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ricjonsu098
Posts: 45
Joined: Sat Jul 30, 2016 8:37 am

Load Game (PlayerPrefs) via dialogue.

Post by ricjonsu098 »

Hello, I am using the Dialogue System Menus extra, is there a way to load the saved game via dialogue?

What I want is, when the conversation ends, it will load a saved game. thanks
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Load Game (PlayerPrefs) via dialogue.

Post by Tony Li »

Hello,

Add a small script with an OnConversationEnd method to the Dialogue Manager. For example, something like:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
using PixelCrushers.DialogueSystem.Menus;

public class LoadGameOnConversationEnd : MonoBehaviour {
    public void OnConversationEnd(Transform actor) {
        var loadSlot = DialogueLua.GetVariable("LoadSlot").AsInt;
        if (loadSlot >= 0) FindObjectOfType<SaveHelper>.LoadGameInSlot(loadSlot);
    }
} 
I have to emphasize that it will be something like the script above. I'm out of the office for most of the day today, so I can't double-check the syntax right now.

To use this, create a Number variable in your dialogue database named "LoadSlot", and set its value to -1. In your conversation, set the variable to a slot number. At the end of the conversation, this script will load the game in that slot.
ricjonsu098
Posts: 45
Joined: Sat Jul 30, 2016 8:37 am

Re: Load Game (PlayerPrefs) via dialogue.

Post by ricjonsu098 »

Thanks, I will try to make it work. Gonna comeback to give a feedback
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Load Game (PlayerPrefs) via dialogue.

Post by Tony Li »

Sounds good. If you get stuck, let me know. I'll be back in the office later today and can provide more details then.
Post Reply