Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: adre on October 08, 2018, 07:47:42 AM

Title: How to change default action names?
Post by: adre on October 08, 2018, 07:47:42 AM
Hello,
I would like to change default action names by hand for obscurity.

For example, When i change Wait.cs to Waitchanged.cs and edit "public class Wait" to "public class Waitchanged" ,  in the "State" part of "Playmaker Editor" window, Wait action changes to "Missing action" , making the FSM useless.

How do i make it so the current FSMs with the changed action names wont break?

Thanks a lot
Title: Re: How to change default action names?
Post by: Thore on October 08, 2018, 02:04:55 PM
When you place the action in the state, you can double click on the title and rename it. Or select and F2 should work, too. Do this.

Don‘t rename the actual action scripts. This screws up updating them later, and referencing them, and so forth. If you really want to go ahead, ignore my warning, which would be a terrible idea, then you need to change the class name and the file name to your new name (this is a general rule), which must be the exact same in both cases, must not conflict with similar named scripts anywhere in your project, must not contain space or weird letters.

Also, when you change the name in script, all scripts of course lose the reference. You must delete those empty references, and place the newly named actions instead. Again, don’t do this. Rename the title once placed instead. See some other tips, while I am at it.
 (https://hutonggames.com/playmakerforum/index.php?topic=15801.0)
Title: Re: How to change default action names?
Post by: adre on October 08, 2018, 10:30:47 PM
Thanks a lot for your reply Thore.

Renaming the title doesn't provide obscurity. The actual script name is still seen.
Title: Re: How to change default action names?[SOLVED]
Post by: djaydino on October 09, 2018, 06:12:50 AM
Hi.
Carefull with renaming actions
If you update you will get problems
Title: Re: How to change default action names?
Post by: adre on October 09, 2018, 06:19:39 AM
Hi.
Carefull with renaming actions
If you update you will get problems

I am aware of that.

I just want to know if what i asked ,is possible or if there is a way to do it. Because, in Unity, if you change a script name, it is updated without problems.

Still awaiting a reply, so i deleted [SOLVED] tag.
Title: Re: How to change default action names?
Post by: djaydino on October 09, 2018, 06:24:47 AM
Hi.
You would need to go inside the script and change the class name (must be unique)
and it would be best to change the filename also to the same class name.

But in the action list it will also be changed.

So if you would change 'Wait' to 'WaitForIt' then in the action list 'Wait' will be replace by 'Wait For It'

You could also copy the action and rename 1 then both would be there
Title: Re: How to change default action names?
Post by: adre on October 09, 2018, 06:44:22 AM
Hi.
You would need to go inside the script and change the class name (must be unique)
and it would be best to change the filename also to the same class name.

But in the action list it will also be changed.

So if you would change 'Wait' to 'WaitForIt' then in the action list 'Wait' will be replace by 'Wait For It'

You could also copy the action and rename 1 then both would be there

1) When I change the filename and class name to "WaitForIt" yes, it changes it the action list also. But all of the Wait actions inside my FSM states break, showing "Missing action"
2) Copying the action and renaming it doesnt provide solution to my problem. Because "Wait" states in my FSMs stay unchanged, in their original way.

In both of the two situations above, I have to rewrite the FSM states with the new action script.

What i am asking is: How do i make all "Wait" FSM states i already have, point to "WaitForIt.cs" and not break?
Title: Re: How to change default action names?
Post by: djaydino on October 09, 2018, 09:11:40 AM
Hi.
You probably cant do this, those that are placed in an fsm won't change as they are already stored (saved) in the scene.


Maybe some kind of custom editor automation can be made for this that would look in each fsm and get the wait action and then rename it.

but that would need to be coded in c#
i know how to get the fsm and variables but i don't know if it is possible to get the actions and rename them. (the title name from the action)
Title: Re: How to change default action names?
Post by: adre on October 09, 2018, 09:20:49 AM
Or I just need to change the way Playmaker looks for "Wait" action.
If i could change which script an action refers to in Actions Browser, then i could accomplish what i am looking for.

But maybe this is only not possible because Playmaker is closed source, and i can understand that because its a commercial product.
Title: Re: How to change default action names?
Post by: djaydino on October 09, 2018, 10:03:41 AM
Hi.
It needs to look for the c# class, so it would be very hard to change
unless the actions would get some kind of reference.
But then you will need to edit all the actions you wish to change + all the custom actions on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)
Title: Re: How to change default action names?
Post by: Thore on October 09, 2018, 02:41:34 PM
Or I just need to change the way Playmaker looks for "Wait" action.
If i could change which script an action refers to in Actions Browser, then i could accomplish what i am looking for.

But maybe this is only not possible because Playmaker is closed source, and i can understand that because its a commercial product.

I explained this above, but in some more detail. It has nothing to do with Playmaker. Actions are scripts. They work when their class name and filename match.

When you rename the class/file name, Unity no longer finds the script. For all it cares, the script is gone, and a new script was added. It’s not a mere filename, but describes a class in code. So if you change “wait” to “waitfor”, “wait” was deleted, and “waitfor” was added.

Try it with other scripts. Changing class names around the way you plan is a really bad idea. It will work, but you cut yourself off from updates, you cannot follow tutorials or advice from others, since you effectively speak a different language, and you might have conflicts with custom actions from ecosystem.   
Title: Re: How to change default action names?
Post by: adre on October 10, 2018, 10:28:03 PM
djaydino,Thore: Thanks for your replies.
Title: Re: How to change default action names?
Post by: jeanfabre on October 11, 2018, 01:41:14 AM
Hi.
Carefull with renaming actions
If you update you will get problems

I am aware of that.

I just want to know if what i asked ,is possible or if there is a way to do it. Because, in Unity, if you change a script name, it is updated without problems.

Still awaiting a reply, so i deleted [SOLVED] tag.

Hi,

 I would be very careful with renaming component classes already in use, they can break your project in so many places... all Unity events will loose reference to it to begin with, then any type based access will be broken ( but visual studio will help you with this though)


 Bye,

 Jean
Title: Re: How to change default action names?
Post by: adre on October 11, 2018, 02:29:53 AM
Hi.
Carefull with renaming actions
If you update you will get problems

I am aware of that.

I just want to know if what i asked ,is possible or if there is a way to do it. Because, in Unity, if you change a script name, it is updated without problems.

Still awaiting a reply, so i deleted [SOLVED] tag.

Hi,

 I would be very careful with renaming component classes already in use, they can break your project in so many places... all Unity events will loose reference to it to begin with, then any type based access will be broken ( but visual studio will help you with this though)


 Bye,

 Jean

I understand.
What is type based access and how could visual studio help me in case they are broken?
If you could give me an introductory info about this, i want to dig into it.
Thanks Jean
Title: Re: How to change default action names?
Post by: jeanfabre on October 18, 2018, 12:35:01 AM
Hi,

 for example if you have a public variable referencing your class like:

 public MyClass myClass;

if you rename MyClass, then the script above will break.

 so the best way to rename a class is to use Visual Studio or monodeveloper refactoring solution ( right click on the class name itself), then as you edit the name and validate it, it will scan your project and edit all scripts referencing it.

 this in itself  will not solve any reference you had within Unity events if you had some. you'll have to rewire them manually unfortunatly.

 Bye,

 Jean
Title: Re: How to change default action names?
Post by: adre on October 18, 2018, 01:02:36 AM
Hi,

 for example if you have a public variable referencing your class like:

 public MyClass myClass;

if you rename MyClass, then the script above will break.

 so the best way to rename a class is to use Visual Studio or monodeveloper refactoring solution ( right click on the class name itself), then as you edit the name and validate it, it will scan your project and edit all scripts referencing it.

 this in itself  will not solve any reference you had within Unity events if you had some. you'll have to rewire them manually unfortunatly.

 Bye,

 Jean

Thanks a lot for the info