playMaker

Author Topic: How to change default action names?  (Read 3689 times)

adre

  • Playmaker Newbie
  • *
  • Posts: 20
How to change default action names?
« on: October 08, 2018, 10: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
« Last Edit: October 09, 2018, 09:19:50 AM by adre »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How to change default action names?
« Reply #1 on: October 08, 2018, 05: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.
« Last Edit: October 08, 2018, 05:13:28 PM by Thore »

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to change default action names?
« Reply #2 on: October 09, 2018, 01:30:47 AM »
Thanks a lot for your reply Thore.

Renaming the title doesn't provide obscurity. The actual script name is still seen.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to change default action names?[SOLVED]
« Reply #3 on: October 09, 2018, 09:12:50 AM »
Hi.
Carefull with renaming actions
If you update you will get problems

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to change default action names?
« Reply #4 on: October 09, 2018, 09: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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to change default action names?
« Reply #5 on: October 09, 2018, 09: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

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to change default action names?
« Reply #6 on: October 09, 2018, 09: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?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to change default action names?
« Reply #7 on: October 09, 2018, 12:11:40 PM »
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)

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to change default action names?
« Reply #8 on: October 09, 2018, 12:20:49 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: How to change default action names?
« Reply #9 on: October 09, 2018, 01:03:41 PM »
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

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How to change default action names?
« Reply #10 on: October 09, 2018, 05: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.   

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to change default action names?
« Reply #11 on: October 11, 2018, 01:28:03 AM »
djaydino,Thore: Thanks for your replies.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to change default action names?
« Reply #12 on: October 11, 2018, 04: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

adre

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to change default action names?
« Reply #13 on: October 11, 2018, 05: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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to change default action names?
« Reply #14 on: October 18, 2018, 03: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