Global variables changed event

Sun 18. Aug 2019, 08:48

Hi again! Another question from me =) I guess there isn't a built in way to check if a variable (or any of the varables) was changed? I'm sorry, but I can't find anything like this. If there's not, what is the best way to achieve this? Or could you tell exactly where and when it happens?

UPD. I guess a variable changes If there's some instructions in the pin
Posts: 6
Joined: Thu 15. Aug 2019, 19:30

Re: Global variables changed event

Wed 21. Aug 2019, 08:48

Hi thepunkoff,

There actually is a way to do exactly that!
Global Variables are stored inside an instance of BaseGlobalVariables. You can have multiple of those
to keep track of different sets of your variables, but most of the time you only need one. This one is automatically created for you and accessible via

Code: Select all

or if you want C# access to your global variables; via the generated class(Both ways point to the exact same instance, just with different types)

Code: Select all

Either way you can access now the Notification Manager. Here you can register a method to be called everytime a global variables is modified.

Code: Select all
public class MyNotificationScript : MonoBehaviour
    void Start()
        // we get the default variable storage from our database and add a listener to the notification manager
        // to call our supplied method every time any Variable inside the namespace "GameState" is changed.
        ArticyDatabase.DefaultGlobalVariables.Notifications.AddListener("GameState.*", MyGameStateVariablesChanged);
    // here we handle every variable change inside the "GameState" namespace
    void MyGameStateVariablesChanged(string aVariableName, object aValue)
        // for example:
        // When our exit variable was set to true, we quit the game.
        if(aVariableName == "GameState.exit" && ((bool)aValue) == true)

        // in this example we play a beep when the variable changes
        // its worth noting that we won't hear a beep now every frame once the variable has been set to true. Because our listener method will only
        // be called once, when our variable changes.
        if(aVariableName == "GameState.beep" && ((bool) aValue) == true)

We do this for the inventory management in our Maniac Manfred Demo project(A small Point&Click Adventure), where the possession of an item is marked via global variable, everytime it changed the item gets added or removed from the players inventory. This turned out great for debugging, as even changing the GV via the inspector view, triggeres those events.

Hope that helped!

Best regards

Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 2 guests

Who We Are
Contact Us
Social Links