Using "self" for custom C#-methods

Thu 5. Apr 2018, 11:04

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
Mikhail
 
Posts: 8
Joined: Fri 30. Mar 2018, 09:57

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

Thu 5. Apr 2018, 11:28

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
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: Using "self" for custom C#-methods

Thu 5. Apr 2018, 11:43

Yes that works. Thank you!
Mikhail
 
Posts: 8
Joined: Fri 30. Mar 2018, 09:57

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 93 guests

Who We Are
Contact Us
Social Links