Articy Forum


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

Using "self" for custom C#-methods

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

Page 1 of 1

Using "self" for custom C#-methods

Posted: Thu 5. Apr 2018, 11:04
by Mikhail
I would like to use "self" param with my custom c#-methods in conditions and instructions, like:

Code: Select all
MyMethod (self, 12, "abc");


Is it possible?
I get error when import data to unity:

Code: Select all
Assets/ArticyContent/Generated/ArticyScriptFragments.cs(1156,20): error CS0103: The name `MyMethod' does not exist in the current context

Re: Using "self" for custom C#-methods

Posted: Thu 5. Apr 2018, 11:28
by [Articy] Nico Probst
Hi Mikhail,

yes it appears to be a bug: Using self or speaker in a custom method will end in the method not being exported at all.
As a workaround: What you can do is not using Self or Speaker in your custom methods only in our setProp, getProp etc. methods.
Instead inside your method you can use the SelfObject and SpeakerObject property found on the GlobalVariables object. It is the same as self and speaker inside your scripts.
So for example your method could look like this:

Code: Select all
public void MyMethod (int aParam0, string aParam1)
{
   if (!IsCalledInForecast)
   {
      (ArticyDatabase.DefaultGlobalVariables.SelfObject as Condition).Template.Something.Foo = 42;
   }
}


Hope that helps and thanks for reporting that issue.

Best regards

Nico

Re: Using "self" for custom C#-methods

Posted: Thu 5. Apr 2018, 11:43
by Mikhail
Yes that works. Thank you!

All times are UTC
Page 1 of 1