problems using self or ArticyGlobalVariables.Default.SelfObj

Sun 17. Feb 2019, 21:39

I am having problems with using self or ArticyGlobalVariables.Default.SelfObject in a custom method in a instruction property of an entity.

So I have entity with a custom template who happens to have instruction field.
In an object I have the following script

Temp._string = IfObjectiveCompleted("unoticed", "unoticed", "failed");
setProp(self, "LevelObjectiveAttributes._state",Temp._string);


The method is generating well and it is getting called but if I use self or ArticyGlobalVariables.Default.SelfObject to reference the entity it is always null.

This is how I am calling the script in c#

entityAttributes.UpdateDescription.CallScript( scriptMethodProvider);

Am I doing something wrong?
h3llye
 
Posts: 9
Joined: Wed 6. Mar 2013, 09:35

Re: problems using self or ArticyGlobalVariables.Default.Sel

Mon 18. Feb 2019, 11:26

Hi h3llye,

We could reproduce this issue and will take a look at it more closely.

As a quick workaround you have two options:

- You set the self property on the global variables instance directly via reflection before calling the UpdateDescription the script:
Code: Select all
ArticyObject expectedSelfObj = ArticyDatabase.GetObject("Chr_Main");
PropertyInfo selfProp = ArticyGlobalVariables.Default.GetType().GetProperty("SelfObject");
selfProp.SetValue(ArticyGlobalVariables.Default, (ScriptObjectProxy)expectedSelfObj, null);

- It is possible to store representations of articy objects inside global string variables. So, you could store the expected self object inside a global variable and continue working with it.
Code: Select all
ArticyGlobalVariables.Default.GameState.CurrentSelfObj = (ScriptObjectProxy)expectedSelfObj;


Best regards,
Christian
User avatar
[Articy] Christian Schildt
Articy Staff
Articy Staff
 
Posts: 62
Joined: Tue 16. Jan 2018, 17:03
Location: Bochum

Re: problems using self or ArticyGlobalVariables.Default.Sel

Mon 18. Feb 2019, 14:13

I am using the reflection fix and it is working.
The only thing I am afraid is that the varible gets overwritten by articy own engine when I make other CallScript calls. When does the engine actually set the selfObject variable?
Also I cant use the latest version I my project is bound to unity version 5.6 so how can I have a possible version with this fix?

thank you for the help
h3llye
 
Posts: 9
Joined: Wed 6. Mar 2013, 09:35

Re: problems using self or ArticyGlobalVariables.Default.Sel

Tue 19. Feb 2019, 13:45

Hi h3llye,

The variable gets overwritten by the ArticyFlowPlayer component while traversing to the next flow object. If you call your UpdateDescription script continuously, the flow player callbacks should be a good place to refresh the SelfObject variable.

I’m sorry to say there is no way to get a version containing this fix for Unity 5.6.


Best regards,
Christian
User avatar
[Articy] Christian Schildt
Articy Staff
Articy Staff
 
Posts: 62
Joined: Tue 16. Jan 2018, 17:03
Location: Bochum

Re: problems using self or ArticyGlobalVariables.Default.Sel

Tue 19. Feb 2019, 15:22

If thats the only time it gets set it should be fine. I am currently setting the variable everytime I use any instruction/condition outside of the flowplayer.

Very disapointed about the version.
h3llye
 
Posts: 9
Joined: Wed 6. Mar 2013, 09:35

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 12 guests

Who We Are
Contact Us
Social Links