PlayerPrefs or other script variables as conditions?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
olakehs
Posts: 7
Joined: Mon Apr 19, 2021 2:28 am

PlayerPrefs or other script variables as conditions?

Post by olakehs »

Hey Tony and everyone

I was wondering if someone knew how to set a condition via playerprefs? i.e. I have 2 nodes and would like to choose path A if PlayerPrefs.GetInt("Choice",1)

Thank you in advance for any advice
O
User avatar
Tony Li
Posts: 22163
Joined: Thu Jul 18, 2013 1:27 pm

Re: PlayerPrefs or other script variables as conditions?

Post by Tony Li »

Hi,

You can write a C# method that returns the PlayerPrefs value. Example:

Code: Select all

double GetChoice() { return PlayerPrefs.GetInt("Choice", 1); }
Then register it with Lua so you can use it in conversations' Conditions fields:

Post Reply