playMaker

Author Topic: Posibility to call a static function and get result?[SOLVED]  (Read 2001 times)

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
Posibility to call a static function and get result?[SOLVED]
« on: March 31, 2013, 05:17:26 PM »
Hi!,

In my script side I have a Game manager singleton that I access like GameMgr.instance. Is there any possibility to call this in playmaker without looking for the GameObject that has the component and then get the component?

Thanks in advance.
« Last Edit: September 16, 2013, 05:06:03 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Posibility to call a static function and get result?
« Reply #1 on: April 01, 2013, 02:43:04 AM »
Hi,

 For this you can simply write a custom action that make this call. I am not aware of any playmaker features allowing to call static methods

Do you need an example of such custom action?


bye,

 Jean

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
Re: Posibility to call a static function and get result?
« Reply #2 on: April 01, 2013, 04:46:25 AM »
Thanks a lot for the answer.

Do you need an example of such custom action?
No, thanks, I can write it myself.

Cheers!

Semihero

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Posibility to call a static function and get result?
« Reply #3 on: September 15, 2013, 02:48:27 PM »
Hi,

 For this you can simply write a custom action that make this call. I am not aware of any playmaker features allowing to call static methods

Do you need an example of such custom action?


bye,

 Jean

Hello Jean, I got stuck with this, so I would really appreciate a sample of the custom send message action to fire up a static function. Kind regards, Bal√°zs

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Posibility to call a static function and get result?
« Reply #4 on: September 15, 2013, 10:34:53 PM »
Hi,

 Actually, it's very easy and there is plenty of official actions that do that already: example: ApplicationQuit

ApplicationQuit is your typical simple action that calls a static method. in this case it calls a Unity Class called "Application" and specifically the static method "Quit()"


So TWO VERY IMPORTANT THINGS:

--note that the call to the static method is done within the "OnEnter()" function, it's important to do it within that function for the action to work.

-- Also note that after you are finished with what the action is supposed to do, you need to call the function "Finish()" which is part of the way actions are supposed to work, this tells PlayMaker engine that your action is done, it helps figuring out if the state is finished ( can thus call the "FINISH" system event we all know)

Does that help?

bye,

 Jean

 

Semihero

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Posibility to call a static function and get result?
« Reply #5 on: September 16, 2013, 12:20:17 AM »
Dear Jean,

Took a look at the Application.Quit action. Totally makes sense, I am wiser than I was before.  8) Thank you.

krmko

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
    • Fat Pug Studio
Re: Posibility to call a static function and get result?[SOLVED]
« Reply #6 on: November 11, 2017, 03:05:18 PM »
Hi guys,

need a little help on this one. I need to call a static method from Pool Boss, and i haven't done a lot of things with. Here's the action.



Here's the API



I'm not quite sure what should i enter in method parameters. I tried prefabName, but as a result i get exactly that, "prefabName"  ::)

Here's the method

Code: [Select]
      public static string GetPrefabName(string prefabName) {
            var iParen = prefabName.IndexOf(" (Clone", StringComparison.Ordinal);
            if (iParen > -1) {
                prefabName = prefabName.Substring(0, iParen);
            }

            return prefabName;
        }


« Last Edit: November 11, 2017, 03:13:29 PM by krmko »

krmko

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
    • Fat Pug Studio
Re: Posibility to call a static function and get result?[SOLVED]
« Reply #7 on: November 11, 2017, 10:21:46 PM »
ah i figured it out  ;D