Replacing articy variables with ones in unity project

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
laurienash
Posts: 4
Joined: Tue Oct 03, 2023 4:47 pm

Replacing articy variables with ones in unity project

Post 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
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Replacing articy variables with ones in unity project

Post 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.
laurienash
Posts: 4
Joined: Tue Oct 03, 2023 4:47 pm

Re: Replacing articy variables with ones in unity project

Post by laurienash »

Ohh ok great, that second method is perfect. Thank you!!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Replacing articy variables with ones in unity project

Post by Tony Li »

Glad to help!
Post Reply