Page 1 of 1

Replacing articy variables with ones in unity project

Posted: Tue Oct 03, 2023 5:03 pm
by laurienash
Hi,

I'm writing my script in Articy draft and have 2 temporary bools that the conversations are checking for. The variables I actually want to check are global bools in my unity project.

I'm not sure what the best approach is for swapping out these temporary bools with my unity ones, and how to do this in a way that when I reimport the updated articy project, that I don't need to rehook up these variables.

Should I have a script that also sets these temporary variables to true/false when the unity ones are updated? Or is there a way of hooking it up that I'm not aware of?

Thanks,
Laurien

Re: Replacing articy variables with ones in unity project

Posted: Tue Oct 03, 2023 8:08 pm
by Tony Li
Hi Laurien,

Are your global bools defined in a C# script?

There are two ways to handle a bool like this:

1. Use an articy/Dialogue System variable.
  • Define the variable in articy. For example, say it's in the variable group named "Global" and the variable name is "IsHappy".
  • In the Dialogue System, it will be imported into a dialogue database variable named "Global.IsHappy".
  • Your C# scripts can access it directly using DialogueLua.GetVariable("Global.IsHappy").asBool and SetVariable().
  • Or, if you want your C# scripts to access a C# value instead, define a property:

    Code: Select all

    public bool IsHappy
    {
        get { return DialogueLua.GetVariable("Global.IsHappy").asBool; }
        set { DialogueLua.SetVariable("Global.IsHappy", value); }
    }
    Then your C# scripts can get and set IsHappy.
2. Or use a C# variable.
  • Write C# methods to get and set the C# variable:

    Code: Select all

    public bool IsHappy;
    
    public bool GetIsHappy() { return IsHappy; }
    public void SetIsHappy(bool value) { IsHappy = value; }
  • Register those C# methods with Lua so you can use them in the Dialogue System.
  • Use those C# methods in your articy project. Articy will complain that it doesn't recognize the methods, but they'll still import fine and work properly in Unity.

Re: Replacing articy variables with ones in unity project

Posted: Wed Oct 04, 2023 5:00 pm
by laurienash
Ohh ok great, that second method is perfect. Thank you!!

Re: Replacing articy variables with ones in unity project

Posted: Wed Oct 04, 2023 9:01 pm
by Tony Li
Glad to help!