Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ramones on March 31, 2013, 08:17:26 PM

Title: Posibility to call a static function and get result?[SOLVED]
Post by: ramones 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.
Title: Re: Posibility to call a static function and get result?
Post by: jeanfabre 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
Title: Re: Posibility to call a static function and get result?
Post by: ramones 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!
Title: Re: Posibility to call a static function and get result?
Post by: Semihero 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
Title: Re: Posibility to call a static function and get result?
Post by: jeanfabre 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

 
Title: Re: Posibility to call a static function and get result?
Post by: Semihero 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.
Title: Re: Posibility to call a static function and get result?[SOLVED]
Post by: Fat Pug Studio 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.

(https://s26.postimg.org/j0e8ei1l5/screenshot_97.png)

Here's the API

(https://s26.postimg.org/h9v7d0k21/screenshot_98.png)

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;
        }


Title: Re: Posibility to call a static function and get result?[SOLVED]
Post by: Fat Pug Studio on November 12, 2017, 12:21:46 AM
ah i figured it out  ;D