Articy Forum


https://www.articy.com:443/forum/

problems using self or ArticyGlobalVariables.Default.SelfObj

https://www.articy.com:443/forum/viewtopic.php?f=46&t=18511

Page 1 of 1

problems using self or ArticyGlobalVariables.Default.SelfObj

Posted: Sun 17. Feb 2019, 21:39
by h3llye
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?

Re: problems using self or ArticyGlobalVariables.Default.Sel

Posted: Mon 18. Feb 2019, 11:26
by [Articy] Christian Schildt
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

Re: problems using self or ArticyGlobalVariables.Default.Sel

Posted: Mon 18. Feb 2019, 14:13
by h3llye
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

Re: problems using self or ArticyGlobalVariables.Default.Sel

Posted: Tue 19. Feb 2019, 13:45
by [Articy] Christian Schildt
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

Re: problems using self or ArticyGlobalVariables.Default.Sel

Posted: Tue 19. Feb 2019, 15:22
by h3llye
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.

All times are UTC
Page 1 of 1