Page 1 of 1

Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 10:17 am
by digiwombat
Hey Tony! Hope life's good.

On to the requests!

Firstly, I'd really appreciate if the Dialogue Text, Sequence, Notes, Conditions, and Script Textareas were EditorGUIUtility.singleLineHeight*2 or *3 tall. Maybe Dialogue Text can still be a single line, but I think it helps readability and UX quite a lot for the rest to be multiline as is. It helps break up the inspector window, I think.

I can obviously do this edit easily myself, and have done, but I'd figured I'd float the idea here. I'll include code to save you some time in case you want to add it to mainline

Just add

Code: Select all

, GUILayout.Height(EditorGUIUtility.singleLineHeight * 3)
to the Textarea declarations.

Changed Lines:
DialogueEditorWindowDialogueTreeSection.cs | Line: 594, 645
SequenceEditorTools.cs | Line: 104
LuaScriptWizard.cs | Line: 114
LuaConditionWizard.cs | Line: 105

Image

That's how it looks. I was also hoping to get the Conditions and Script boxes into a EditorGUILayout.BeginHorizontal() (if the inspector is over 400px wide). That just requires a little bit of code I'll slap below, but it looks like this:

Image

The code is just:

Code: Select all

// If statement is for optional Web2.0 RESPONSIVE UI!!!
if (EditorGUIUtility.currentViewWidth > 400)
{
    EditorGUILayout.BeginHorizontal();
}
EditorGUILayout.BeginVertical();
// Conditions:
luaConditionWizard.database = database;
entry.conditionsString = luaConditionWizard.Draw(new GUIContent("Conditions", "Optional Lua statement that must be true to use this entry."), entry.conditionsString);
EditorGUILayout.EndVertical();

EditorGUILayout.BeginVertical();
// Script:
luaScriptWizard.database = database;
entry.userScript = luaScriptWizard.Draw(new GUIContent("Script", "Optional Lua code to run when entry is spoken."), entry.userScript);
EditorGUILayout.EndVertical();
// If statement is for optional Web2.0 RESPONSIVE UI!!!
if (EditorGUIUtility.currentViewWidth > 400)
{
    EditorGUILayout.EndHorizontal();
}
NOTE: This also requires editing the two script field .Draw commands and changing the EditorGUILayout.LabelField to a GUILayout.Label for them to fill the area properly. The Script Wizard could probably also use a touch since it makes one field quite wide when they're side-by-side there.

Secondly, and more importantly, I think, dragging multi-selected nodes doesn't respect my snap settings. Only the clicked node respects the snap setting and the rest drift around awkwardly. Looking at the code for this, it SEEMS like they're supposed to snap (since it loops through a list of nodes) but it's not happening.

Pre drag: Image

Post drag: Image

Snap is set to 24 here but the same thing happens at all snap levels.

Re: Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 11:29 am
by Tony Li
Hi,

I'll fix that snapping issue. Currently it just snaps the primary selected node and allows the others to follow along relative to the mouse position.

Currently, the Dialogue Text area is flexible. It grows in height to accommodate the text size. I don't want to limit it to 2x or 3x lines tall since some authors write text that's much taller than 2 or 3 lines.

What if I add some horizontal divider lines instead? If so, where would they be most useful?

I'm also going to keep the Conditions and Script sections full width because they tend to get fairly long, especially when working with quest names.

I suppose I could add some foldouts to allow you to hide parts of the entry if that would be helpful. If so, where would you like to see foldouts? Currently the only foldout is the All Fields section.

Re: Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 12:12 pm
by digiwombat
That's a fair point about the 2x/3x. I thought those would grow along like normal (none of my current lines overflowed the 3x I was using), but I guess Unity's EditorGUI doesn't want us to feel happiness. Honestly sort of amazed by that. Ah well!

That said you could do a more complicated version to get the height:

Code: Select all

GUIStyle theHeightStyle = new GUIStyle();
float theHeight = theHeightStyle.CalcHeight(new GUIContent(entry.DialogueText), position.width - 35);
theHeight = theHeight + 5;
if (theHeight < EditorGUIUtility.singleLineHeight * 3)
{
	theHeight = EditorGUIUtility.singleLineHeight * 3;
}
entry.DialogueText = EditorGUILayout.TextArea(dialogueText, GUILayout.MinHeight(theHeight));
With that code it expands and starts off larger, though obviously it's a bit more calculation for each textarea. I didn't see any slowdown in editor though.

As far as lines to help readability, I think using the HelpBox style around the some key fields and maybe move the false condition action box down and add some spaces here and there.. That would look something like this:

Image

That just does a few BeginVerticals with the following simple style:

Code: Select all

GUIStyle theBox = new GUIStyle("HelpBox");
I rather like the updated version. And it retains the expanding text boxes. Though I might bring them down to 2x line height initially.

Re: Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 12:13 pm
by digiwombat
Also, I completely forgot to say it, but thanks in advance for fixing up the snapping.

Re: Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 12:48 pm
by digiwombat
Only last screenshot of a slightly cleaned up spacing/the dynamic height fields:

Image

I think the two-height looks better than the three, but it's certainly still workable with one-height either way.

EDIT: Also, all of this is easy stuff, but if you want to implement any of it, let me know if you want my files to save a bit of time.

Re: Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 1:17 pm
by Tony Li
Hi,

Thanks! I like the look of that. If I don't get it implemented in time for version 2.2.7's release (the current sprint has become more of a marathon, handling some Addressables features), I'll try to get a patch out soon after.

Re: Snap to Grid Multiselect is Broken and Larger Textareas.

Posted: Thu May 14, 2020 10:25 pm
by digiwombat
I definitely understand the marathon, haha.

And awesome, I'll look forward to it! Thanks for all your hard work. :D