playMaker

Author Topic: AutoName Feature Improvements  (Read 248 times)

Thore

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
AutoName Feature Improvements
« on: September 09, 2019, 10:10:50 AM »
I find the (experimental) AutoName feature quite useful. However many actions don't have autoName code (including some of mine). Below are a few instances I found. Maybe others can chime in and add some too, so that we can quickly get the catalog covered.

But before, I also suggest some general improvements.

In ActionHelpers.cs, line 784, remove space before colon, but add one afterwards. Like so:
Code: [Select]
var autoName = actionName + ": ";
This results in "ActionName: Some Stuff Here".

Next, I propose to add a general function (howOften in my example) that captures the everyFrame boolean present in most actions and puts it into a string to be added at the end. Here's a snipped for SetBoolValue.cs that has no autoNaming yet.

Code: [Select]
#if UNITY_EDITOR

        string howOften;

        public override string AutoName()
        {
            if (everyFrame) howOften = " /updated"; else howOften = " /once";


            if (boolValue.Name == "") return ActionHelpers.AutoName(this) + "'" + boolVariable.Name + "' to " + boolValue + howOften;
            else return ActionHelpers.AutoName(this) + "'" + boolVariable.Name + "' to '" + boolValue.Name + "' (" + boolValue + ")" + howOften;
        }

#endif

This results in
SetBoolValue: 'Variable' to False /once or
SetBoolValue: 'Variable' to 'otherVariable' (True) /updated

In SendEvent.cs, line 73, replace the hardcoded strings like so:
Code: [Select]
return ActionHelpers.AutoName(this) + (eventTarget.target != FsmEventTarget.EventTarget.Self ? eventTarget.target + " ": "")
Though, it's not great yet (it still just says GameObject instead of owner etc).

In GoToStateByName.cs, autonaming is missing. A suggestion:
Code: [Select]
#if UNITY_EDITOR

        public override string AutoName()
        {
            return ActionHelpers.AutoName(this) + " in '" + fsmName + "' to '" + stateName + "'";
        }

#endif

There's a lot more, but I wanted to start it up and see the response. :)


Thore

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
Re: AutoName Feature Improvements
« Reply #1 on: September 09, 2019, 10:15:43 AM »
Since the resulting string is going to have a few common elements, it would be good to reduce the hardcoded naming. For example, maybe any string variable can always be placed within " " (or ' '); maybe all variable names could stand out with a different font type, e.g. italics. Maybe the elements can be colour coded, like in a scripting editor. And finally, as I suggested above, some common elements like everyFrame could be their own function that attaches a /once or /updated (my example) at the end.

Example for a nicer format.
SetBoolValue: Variable to False /once
SetBoolValue: Variable to otherVariable (True) /updated

Studied the ActionHelpers.cs a bit more: Something like this would be nice:

Code: [Select]
      public static string updated(bool everyFrame)
        {
            string howOften;
            if (everyFrame) howOften = " /updated"; else howOften = " /once";

            return howOften; 
        }

Then, appending
Code: [Select]
+ ActionHelpers.updated(everyFrame);
... would add the /once or /updated to the AutoName.
« Last Edit: September 14, 2019, 10:25:13 AM by Thore »

Thore

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
Re: AutoName Feature Improvements
« Reply #2 on: September 13, 2019, 08:58:07 AM »
GetFSMVariables proposal.

Code: [Select]
#if UNITY_EDITOR

        public override string AutoName()
        {
            return ActionHelpers.AutoName(this) + "from " + fsmName.Value + " (" + getVariables.Length +")";
        }

#endif

Results in: GetFsmVariables: from myFSM (3)

Similar: GetAxis.cs and GetAxisRaw.cs

Code: [Select]
#if UNITY_EDITOR

        public override string AutoName()
        {
            return ActionHelpers.AutoName(this) + "from " + axisName.Value + " (" + store.Value + ")";
        }

#endif