Register Variable && GetAllVariable(string)

Fri 7. Apr 2017, 15:17

Hi,

I want to differ in time the update of a articy variable, I call that from flow


Code: Select all
   
//Param0 = name of the variable to change state, Param1 = in how many second I change this state
 public void TimerBoolean(string aParam0, string aParam1)
    {
        Debug.Log(ArticyDatabase.DefaultGlobalVariables.NamespaceVariableMap["Timer"].Count);
        if(!ArticyDatabase.DefaultGlobalVariables.IsVariableOfTypeInteger("Timer.Compteur" + aParam0.Split('.')[1]))
        {
            ArticyDatabase.DefaultGlobalVariables.RegisterVariable("Timer.Compteur" + aParam0.Split('.')[1], int.Parse(aParam1));
            Debug.Log(ArticyDatabase.DefaultGlobalVariables.NamespaceVariableMap["Timer"].Count);
        }
    }


The Register don't work for the current session, I will saw the variable only if I relaunch my app. How can I got it during the session?

And after that, I would like to in a coroutine get all variable like "Timer.Compteur*" and decremente them until 0, when I reach 0, I switch the state of the appropriate variable.

In Manfred Exemple I saw a exemple where regex seem accept :
Code: Select all
Inventory.cs
ArticyDatabase.DefaultGlobalVariables.Notifications.AddListener("Inventory.*", OnVarChanged);


But it's not seem to have a Method GetAllVariables(string), so is the better mean to achieve my goal it's to use the "ArticyDatabase.DefaultGlobalVariables.NamespaceVariableMap["Timer"]" or ArticyDatabase.DefaultGlobalVariables.Variables?


Thak you :)

Have a nice day

Zeldarck
User avatar
Zeldarck
 
Posts: 55
Joined: Thu 9. Mar 2017, 16:03

Re: Register Variable && GetAllVariable(string)

Fri 7. Apr 2017, 16:30

Hi,

I have to say that RegisterVariable wasn't supposed to be used like that. It was never meant to add a variable at runtime. It is to register a variable at edit time, thats also the reason why you see it appearing once you restart. When you reimport all those variables would be gone.

Why do you need a global variable here anyway? Why not using a normal C# variable for your timing? Global Variables exist only to be accessible in articy:draft scripts and the support for shadow states. The first argument is mute, as articy:draft cannot know of any variable you create in unity at runtime, the later argument is only an issue when you deal with methods and even then its possible to find an easier work around than using global variables. In other words, global variables are constant the moment you export them the same way as the scripts are constant that are the main reason for global variables to exist.

Best regards

Nico
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

Re: Register Variable && GetAllVariable(string)

Mon 10. Apr 2017, 08:07

Thank you,

I was in the thinking of "I got a save method for my Global Variable, I will use them at maximum"
But yeah, I will create a serializable object which handle a dictionnary of Compter, a thing like that :)
User avatar
Zeldarck
 
Posts: 55
Joined: Thu 9. Mar 2017, 16:03

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 16 guests

Who We Are
Contact Us
Social Links