playMaker

Author Topic: Any way to set the action name in code? [Solved]  (Read 1874 times)

Tricky_Widget

  • Junior Playmaker
  • **
  • Posts: 62
Any way to set the action name in code? [Solved]
« on: February 12, 2016, 08:11:24 PM »
I'm making a bunch of actions, and their (necessary) class names make for terrible action names.  Is there any way to set the action name to something else within the code?

I see there is a [Title("")]  attribute for fields.  Maybe something similar for the action name?

Thanks!
« Last Edit: February 13, 2016, 07:46:16 AM by Tricky_Widget »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3998
  • Official Playmaker Support
    • LinkedIn
Re: Any way to set the action name in code?
« Reply #1 on: February 12, 2016, 08:29:43 PM »
I plan to make TitleAttribute work for action names soon...

Right now you could override the AutoName method as a workaround.

AutoName is kind of an experimental feature to let an action build its own name, based on its parameters. So you could collapse an action and still see what it does from its title. Look at Get/Set Property or Call Method as examples.

But you could use it to just set a different name for the action:

Code: [Select]
#if UNITY_EDITOR
        public override string AutoName()
        {
            return "My Custom Action Name";
        }
#endif

Normally a user has to select AutoName from the Action Settings Menu, but you should be able to set the action's IsAutoNamed property to true in Reset.

Note, this feature is still experimental, so let me know if you run into problems...

Tricky_Widget

  • Junior Playmaker
  • **
  • Posts: 62
Re: Any way to set the action name in code?
« Reply #2 on: February 13, 2016, 07:45:49 AM »
Right now you could override the AutoName method as a workaround.

That'll do until the TitleAttribute change.  :)  Thanks so much!