Forum rules - please read before posting.

onvarchange usage

Hi Chris,

It seems that AC can check if there is any variable changing in runtime.
In my case, I have a GVar changed in a script. But it seems that AC fail to check variable changes driven by a script.
So is the onvarchange in a scene can only check the variable change driven by actionlist in AC?
If onvarchange can check variable changing in script. How can I do it? Pls help, thanks.

Comments

  • The Scene Manager's OnVarChange will only run if using the provided Actions - as it will only run once the ActionList has ended.

    If you're affecting a variable value through script, you can hook into the OnVariableChange custom event, which will run instantly if a variable is updated:

    void OnEnable () { EventManager.OnVariableChange += OnVariableChange; }
    void OnDisable () { EventManager.OnVariableChange -= OnVariableChange; }
    
    void OnVariableChange (GVar variable)
    {
        Debug.Log ("Changed " + variable.type.ToString () + " variable '" + variable.label + "' to " + variable.GetValue ());
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.