Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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.
-
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
-
Thanks a lot for the answer.
Do you need an example of such custom action?
No, thanks, I can write it myself.
Cheers!
-
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
-
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
-
Dear Jean,
Took a look at the Application.Quit action. Totally makes sense, I am wiser than I was before. 8) Thank you.
-
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
public static string GetPrefabName(string prefabName) {
var iParen = prefabName.IndexOf(" (Clone", StringComparison.Ordinal);
if (iParen > -1) {
prefabName = prefabName.Substring(0, iParen);
}
return prefabName;
}
-
ah i figured it out ;D