Save Bolt variable in Dialogue System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VietLinh
Posts: 4
Joined: Sun Nov 07, 2021 5:43 am

Save Bolt variable in Dialogue System

Post by VietLinh »

Hello Tony,
I'm very new in Unity and i don't know about C# script.
I want to save bolt variable in dialogue system. Because Playerprefs of Bolt not encrypt.
I think i can use lua variable to sent bolt variable to save. But if i want save list[int] or list[string] i must create many lua variable...which other way to save bolt variable in dialogue system?

PS: I'm not native English. Maybe something i write not exactly. Sorry about that!
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Bolt variable in Dialogue System

Post by Tony Li »

Hello,

If you want to encrypt data in PlayerPrefs, use this open source code: SecurePlayerPrefs.

If you can put your list in a larger structure, you can use JsonUtiity to serialize (convert) the list into a string and back again. Example structure:

Code: Select all

using System;
using System.Collections.Generic;

[Serializable]
public class MyData
{
    public List<int> myNumbers;
}
If you have an object whose type is MyData, then in Bolt you can use UnityEngine.JsonUtility.ToJson to convert it to a string. Then you can store that string in a Dialogue System variable.

To retrieve the object from the Dialogue System, use UnityEngine.JsonUtility.FromJson.
VietLinh
Posts: 4
Joined: Sun Nov 07, 2021 5:43 am

Re: Save Bolt variable in Dialogue System

Post by VietLinh »

>If you can put your list in a larger structure, you can use JsonUtiity to serialize (convert) the list into a string and back again. Example structure:
As said above, I don't know how to code in c#
Can you give me a specific example?
For example, I have a list variable in bolt (this variable belongs to the player object):
Image
how can use JsonUtiity to serialize (convert) the list into a string and back again
Last edited by VietLinh on Thu Nov 11, 2021 10:28 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 22142
Joined: Thu Jul 18, 2013 1:27 pm

Re: Save Bolt variable in Dialogue System

Post by Tony Li »

Hi,

It will probably be easiest if you put each list element into a separate DS variable.
Post Reply