playMaker

Author Topic: A few reflections on the Action Browser and perhaps a derived tool  (Read 1525 times)

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
The Action Browser (AB) search filter is very interesting and quite flexible.

Here is an example. I summon it for "bool test".
It parses "bool" and "test" and finds all the actions that have these two words. One can type "test bool" and obtain the same results.
Even more impressive, assuming there are actions that start with the word bool, the search engine will find them even if no space is included: "booltest".
It is therefore possible to type "test booltest" and still reach the results indicated above too. This because both "test" and "booltest" remain correct conditions.
The spaceless criterion brings us closer to classical coding.

There is however one problem that slows down the workflow: the selector will be on the highest action in the AB and not the one that is closest to the search. This is very annoying because one still has to press down several times to get the proper action. This problem is further increased because the Recent category sits at the top of the AB and adds even more results, which are literally doubles of former solutions in cases they have been recently used.
In the illustrated case (if I can post a picture  >:(), the proper result I'm looking for stands at the bottom of a list of actions in seventh position instead of first, or more precisely, the selector is located six positions above the action I'm looking for.



New dedicated shortcut
Also on MacOS, the AB's shortcut is lost, can't find it. I fortunately could create one of my own: I went to 'System Preferences > Keyboard > Shortcuts > Application Shortcuts > Other > Unity' and added CTRL + SPACE for "Action Browser".
But I dislike combinations of keys and I realize that there's one key that's absolutely not used at all here:

['80s audio FX] the Space bar [/'80s audio FX].

So it got me checking if we could have this Space bar used as a valid shortcut too and after a few tests in Unity it didn't seem to be causing any issue with any other function, at least when the Graph View (GV) tab was selected. I pressed Space in other Unity tabs and it's just never used.
So now, knowing this, if you go back to the GV, one understands it's possible to have the Space bar used as a shortcut for the AB, and it would be more practical imho. I don't know if it is on PC but on a Mac it looks like it would not create any conflict with anything else.



An embedded faster AB: the MAB
With this in mind, I think we can even push the tool even further as I compared the way actions are added through the keyboard with how typical code is added in, say, Visual Studio or Mono.
When I was musing over this much needed faster and more practical shortcut, I thought, wait, let's just leave the AB where it is. After all, it's a very big element in the UI, it occupies a vast area of screen estate, some people have it docked, others prefer to summon it when needed.
It's not necessarily very practical to have this big window either pop onto the screen, or have the user look left or right (depending on where it's docked) to check for the AB search field every time you press the shortcut and start typing (a minor annoyance though because you obviously quickly get trained into looking for the search field, wherever you docked the AB since it's supposed to remain in the same spot). Still, there's no one-way-one-shot glow effect to tell you that the cursor is now in the AB's search field (the autofocus was a request that goes back to 1.1 IIRC).

So if you're with me here, I'm saying that the Space bar could be a shortcut for a quicker, turbo, Mini AB (MAB). A practical popup.

The MAB's structure would be like this:

(+)[search field] [action field] [var/event area...]

(+) = cursor position or closest if cursor is out of bounds.


Example of state or action edition
Assuming you're in the GV, Space will summon this MAB where your cursor is as much as possible, knowing it's actually going to take into account a thick invisible border so the MAB doesn't appear too close to the edge of the GV.

The way it works is like the AB but more akin to coding.

Summon MAB with Space.

(+)[search field]

Search field appears. Autofocus on it.
Type desired action name.  Most accurate action appears in a box on the right.
This box, the action field, is fully opaque. Closest found action appears on the right in another rectangle of limited size (if the action's name is bigger, it's truncated with three dots ...).
This result field acts as a drop down menu.

(+)[search field] [action field]

From here, if you press Right, you move from the search field to the action field (the core of the MAB) and it deploys the list of all valid results (with a maximum of n lines, up and down arrow are used to scroll the list).

(+)[search field] [action 1] [var/event area]
                          [action 2]
                          [action 3]
                          [action n]

Once the cursor is moved into the action field, it deploys the list of all corresponding actions (based on the search field's input). It's larger in order to display longer action names (in my example above it's narrower because "action 1" is obviously shorter than "action field").

As soon as an action is selected, to the right of the action field appears in semi-opaque fashion the first variable field in another rectangle.

Press Right and the cursor is now in this var field and it's now fully opaque.
It's a static field (manually entered value) but acts as a drop up/down menu once the cursor is in it;
- if you press up, you deploy the menu up and you display 'create var'. Do it twice and you can select the creation of a Global variable.
- if you press down, the menu deploys in a manner similar to the action field and shows all the available vars to put there.

(+)[search field] [action] [value/variable 1] [more var/event]
                                       [    variable 2     ]
                                       [    variable 3     ]
                                       [    variable n     ]

As you entered the selected action's first var field, another one appeared to right also in a semi-opaque way, whether it's a variable field or an event field.
Usually the first entry in 99% of actions is a variable field instead of an event one but there is no fixed rule so that's why I say it's a var/event field.
Perhaps I could call it, to be exact, a (value/variable)/event field?

Again, press Right and the box to the right becomes fully opaque as the cursor enters this field.
So you see, the MAB grows like a train toward the right as long as you build it.

Validate your entire "construct" with Enter.

I am unsure how smarter the MAB could be made, like for example in the suggestions of vars to use. What I mean is if the workflow could be accelerated a little more with even more guidance but I'm not sure what could be added here since there's little way to predict what the user wants beyond just displaying a list of available actions and vars.

Also, perhaps the MAB would not infinitely expand to the right but be of a limited size, so the var/event area (itself composed of multiple sub cells) would be a scroll field where arrows would be displayed as long as something is hidden on the left or the right.


Quickly adding or stuffing states
Another point, and quite important too. With the current AB, nothing happens if you select an action and press Enter if no state is selected.
With the MAB, this would actually create a new state with the action's name; recycling the drag and drop function that already exists as one can pull an action from the AB and drop it into the GV which produces a state which title is the action's name.
Perhaps this phase could be closed with an extra step where once you validate the set up with a first press of Enter, you're prompted to enter a new title before validating the whole process. If you press Enter right away it creates the state with the action's name. Otherwise, whatever you typed (assuming it's syntactically valid) is used as the new state's new title.
So press Enter, the state is created roughly were the MAB was opened.

The state creation would obviously avoid superposing states and always try to place the new state in a smart manner.
If no FSM exists on the Game Object, it would also create a new FSM and make the first state the Start State.

However, if a state is already selected (including for example the newly created one) then the MAB would simply add a new action to the bottom of the pile of actions in that state.

This would have to be tested but it's possible that after a few rounds, power users could get the gist of it and find themselves quickly adding states or actions in states in no time flat with a reduced use of the mouse:
SPACE! type type type arrow arrow etc. ENTER!
Bam! Action.
(eventually move state)
Rinse and repeat.

Perhaps a secondary "secret" shortcut could be added to act as a Right key so coders don't have to move their heavy right hand too far from the letters area on the keyboard. In which case, the Backspace key would perhaps need to move the cursor to the adjacent box on the left. I don't know, just thinking out loud.


Moving states with the keyboard
A shortcut to move states with arrows would be nice too in this context. As of now, one can namevigate around with these keys, jump from one state to another, that's fine, but it could be expanded by letting users move states too, perhaps with SHIFT + ARROW KEY.
Also, Escape could be used to unselect any state. Right now it's unused.
Besides, in the case of no state being selected (usually as the user clicks in the GV's emptiness), pressing arrow keys would also begin a selection of a state based on the key's direction (left, up, etc.), going for the closest state or anything that seems logical anyway.

On MacOS, Alt + ArrowKey is not used either, contrary to CTRL + arrowKey that is exploited by the OS' desktop/UI functions.



Validation with Space
For extra nuttiness, I also considered the possibility of validating with Space but it would generate issues. Tests would reveal its feasibility. For one, spaces are not needed for searches, assuming the words are typed in the right order (see "booltest"); but it becomes necessary if you cannot remember in what order the words come. Also, if it becomes possible to create variables, events and rename the new state, it's obvious that not being able to use the Space bar (to add blanks) would be terribly annoying. But then again some coders have conventions and use no spaces at all. Playmaker pays more respect to string fields so it's different.
It remains an option worthy of attention because classical coders can opt to totally ignore spaces so they might find an interest in this.


Auto correction of names
Perhaps there could be an option to auto correct vars, events and states: It should be separated as naming conventions are not the same whether we're dealing with variables, events or states. So if you type "jumpOnTrain" it would automatically reformat to "Jump On Train" or "Jump on train" (leave this subtlety to the user with another bunch of parameters to tick).
That's just an idea I'm throwing here, it's rather precarious and would really require some testing.



Quick navigation and auto-linking
Cherry on top, imagine you have selected a state's transition (not just the state).
Go through the process of creating a new state with the MAB. The new state will be automatically placed next to the former state and will be linked too!

Is there a key to go from state selection to transition selection? Tab key is already used and I must admit, I'd rather have it allowing me to cycle through a state's transitions than what it does now, i.e., focus on the state's name field in the GV's State tab.

With this, a pure keyboard shortcut to create transitions when you're in a state would be very useful too.

In fact, it looks like I'm thinking about a way to produce and edit most of a FSM's content with the keyboard only.

The idea behind the MAB is to show that Playmaker also has a more classical workflow available, which is an attempt to lure coders.
« Last Edit: February 27, 2021, 06:27:43 PM by Broken Stylus »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: A few reflections on the Action Browser and perhaps a derived tool
« Reply #1 on: February 12, 2021, 03:06:57 PM »
Great ideas, thanks! Lots to digest here, will have to read it a few times!

The exact search match has actually been on my todo list for a while. I'll try to get that in soon.


Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: A few reflections on the Action Browser and perhaps a derived tool
« Reply #2 on: February 15, 2021, 06:19:33 AM »
Well, search exactness seems most needed in the case of "send event" for example, which is literally at the bottom of a list of, let me count, 13 items by default (not counting the recent category).  ;D

I also heavily edited the original post for much needed extra clarity.
« Last Edit: February 15, 2021, 07:13:03 AM by Broken Stylus »