playMaker

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

ramones

  • Playmaker Newbie
  • *
  • Posts: 42
Posibility to call a static function and get result?[SOLVED]
« on: March 31, 2013, 08: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, 08:06:03 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Posibility to call a static function and get result?
« Reply #1 on: April 01, 2013, 05: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
Re: Posibility to call a static function and get result?
« Reply #2 on: April 01, 2013, 07: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
Re: Posibility to call a static function and get result?
« Reply #3 on: September 15, 2013, 05: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: 15500
  • Official Playmaker Support
Re: Posibility to call a static function and get result?
« Reply #4 on: September 16, 2013, 01:34:53 AM »
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
Re: Posibility to call a static function and get result?
« Reply #5 on: September 16, 2013, 03: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.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Posibility to call a static function and get result?[SOLVED]
« Reply #6 on: November 11, 2017, 05: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, 05:13:29 PM by krmko »
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Posibility to call a static function and get result?[SOLVED]
« Reply #7 on: November 12, 2017, 12:21:46 AM »
ah i figured it out  ;D
Available for Playmaker work