Skip to content

Commit 8b0ce98

Browse files
committed
fix: UI stuff
1 parent 4702f40 commit 8b0ce98

File tree

3 files changed

+29
-30
lines changed

3 files changed

+29
-30
lines changed

Editor/UXML/CollectionInspectorTreeAsset.uxml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<uie:ToolbarSearchField style="width: auto;" />
55
</ui:VisualElement>
66
<ui:VisualElement name="ContentGroup" style="flex-grow: 1; margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px;">
7-
<ui:VisualElement style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 0; border-left-width: 1px; border-left-color: rgba(0, 0, 0, 0.8); border-right-color: rgba(0, 0, 0, 0.8); border-top-color: rgba(0, 0, 0, 0.8); border-bottom-color: rgba(0, 0, 0, 0.8); padding-top: 5px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: rgb(48, 48, 48); flex-direction: row;">
7+
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 0; border-left-width: 1px; border-left-color: rgb(32, 32, 32); border-right-color: rgb(32, 32, 32); border-top-color: rgb(32, 32, 32); border-bottom-color: rgb(32, 32, 32); padding-top: 4px; padding-right: 4px; padding-bottom: 0; padding-left: 4px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: rgb(48, 48, 48); flex-direction: row;">
88
<ui:Label tabindex="-1" text="Items" parse-escape-sequences="true" display-tooltip-when-elided="true" style="-unity-font-style: bold; font-size: 12px;" />
99
<ui:VisualElement style="flex-grow: 1; flex-direction: row; justify-content: flex-end;">
10-
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="expand-button" tooltip="Expand / Collapse Items" style="width: 18px; height: 18px;" />
10+
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="expand-button" tooltip="Expand / Collapse Items" text="↓ " enable-rich-text="false" style="width: 18px; height: 18px;" />
1111
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="sort-button" style="width: 18px; height: 18px; display: none;" />
1212
</ui:VisualElement>
1313
</ui:VisualElement>
@@ -25,25 +25,27 @@
2525
<ui:VisualElement style="flex-grow: 1; flex-direction: row; margin-top: 20px;">
2626
<ui:Button text="Generate Items" parse-escape-sequences="true" display-tooltip-when-elided="true" tooltip="Uses Code Generation to generate the Static File to access collection items by code." name="generate-auto-items" style="flex-grow: 1; min-height: 60px;" />
2727
</ui:VisualElement>
28-
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-top: 20px;">
29-
<ui:VisualElement name="advanced-header-visual-element" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 0; border-left-width: 1px; border-left-color: rgba(0, 0, 0, 0.8); border-right-color: rgba(0, 0, 0, 0.8); border-top-color: rgba(0, 0, 0, 0.8); border-bottom-color: rgba(0, 0, 0, 0.8); padding-top: 5px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: rgb(48, 48, 48);">
30-
<ui:Label tabindex="-1" text="Advanced" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label" style="-unity-font-style: bold; font-size: 12px;" />
31-
</ui:VisualElement>
32-
<ui:VisualElement style="flex-grow: 1; border-left-color: rgba(0, 0, 0, 0.8); border-right-color: rgba(0, 0, 0, 0.8); border-top-color: rgba(0, 0, 0, 0.8); border-bottom-color: rgba(0, 0, 0, 0.8); border-top-width: 0; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0; padding-top: 10px; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; flex-wrap: nowrap; align-items: stretch;">
33-
<ui:Toggle label="Automaticaly Loaded" name="automatic-loaded-toggle" binding-path="automaticallyLoaded" class="unity-base-field__aligned" style="flex-grow: 0; -unity-font-style: normal;" />
34-
<ui:Toggle label="Write as Partial Class" name="write-partial-class-toggle" class="unity-base-field__aligned" />
35-
<ui:Toggle label="Use Base Class for Items" name="base-class-for-items-toggle" class="unity-base-field__aligned" />
36-
<ui:Toggle label="Enforce Indirect Access" name="enforce-indirect-access" tooltip="Useful if this collections is not auto loaded, or loaded through addressables, or you just want to have better memory management" class="unity-base-field__aligned" />
37-
<uie:ObjectField label="Generated Scripts Folde" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" name="generated-scripts-parent-folder" class="unity-base-field__aligned" />
38-
<ui:TextField picking-mode="Ignore" label="Static Filename" value="filler text" name="static-filename-textfield" is-delayed="true" class="unity-base-field__aligned" />
39-
<ui:TextField picking-mode="Ignore" label="Namespace" value="filler text" name="namespace-textfield" is-delayed="true" class="unity-base-field__aligned" />
28+
<ui:VisualElement name="DefaultGroupBox">
29+
<ui:VisualElement name="VisualElement" style="flex-grow: 1; margin-top: 20px;">
30+
<ui:VisualElement name="advanced-header-visual-element" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-left-color: rgb(32, 32, 32); border-right-color: rgb(32, 32, 32); border-top-color: rgb(32, 32, 32); border-bottom-color: rgb(32, 32, 32); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: rgb(48, 48, 48);">
31+
<ui:Label tabindex="-1" text="Advanced" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label" style="-unity-font-style: bold; font-size: 12px;" />
32+
</ui:VisualElement>
33+
<ui:VisualElement style="flex-grow: 1; border-left-color: rgb(32, 32, 32); border-right-color: rgb(32, 32, 32); border-top-color: rgb(32, 32, 32); border-bottom-color: rgb(32, 32, 32); border-top-width: 0; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0; padding-top: 10px; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; flex-wrap: nowrap; align-items: stretch;">
34+
<ui:Toggle label="Automaticaly Loaded" name="automatic-loaded-toggle" binding-path="automaticallyLoaded" class="unity-base-field__aligned" style="flex-grow: 0; -unity-font-style: normal;" />
35+
<ui:Toggle label="Write as Partial Class" name="write-partial-class-toggle" class="unity-base-field__aligned" />
36+
<ui:Toggle label="Use Base Class for Items" name="base-class-for-items-toggle" class="unity-base-field__aligned" />
37+
<ui:Toggle label="Enforce Indirect Access" name="enforce-indirect-access" tooltip="Useful if this collections is not auto loaded, or loaded through addressables, or you just want to have better memory management" class="unity-base-field__aligned" />
38+
<uie:ObjectField label="Generated Scripts Folde" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" name="generated-scripts-parent-folder" class="unity-base-field__aligned" />
39+
<ui:TextField picking-mode="Ignore" label="Static Filename" value="filler text" name="static-filename-textfield" is-delayed="true" class="unity-base-field__aligned" />
40+
<ui:TextField picking-mode="Ignore" label="Namespace" value="filler text" name="namespace-textfield" is-delayed="true" class="unity-base-field__aligned" />
41+
</ui:VisualElement>
4042
</ui:VisualElement>
4143
</ui:VisualElement>
4244
<ui:VisualElement name="extra-properties-visual-element" style="flex-grow: 1; margin-top: 20px;">
43-
<ui:VisualElement name="advanced-header-visual-element" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 0; border-left-width: 1px; border-left-color: rgba(0, 0, 0, 0.8); border-right-color: rgba(0, 0, 0, 0.8); border-top-color: rgba(0, 0, 0, 0.8); border-bottom-color: rgba(0, 0, 0, 0.8); padding-top: 5px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: rgb(48, 48, 48);">
45+
<ui:VisualElement name="advanced-header-visual-element" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-left-color: rgb(32, 32, 32); border-right-color: rgb(32, 32, 32); border-top-color: rgb(32, 32, 32); border-bottom-color: rgb(32, 32, 32); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 0; border-bottom-left-radius: 0; background-color: rgb(48, 48, 48);">
4446
<ui:Label tabindex="-1" text="Default Inspector" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label" style="-unity-font-style: bold; font-size: 12px;" />
4547
</ui:VisualElement>
46-
<ui:VisualElement style="flex-grow: 1; border-left-color: rgba(0, 0, 0, 0.8); border-right-color: rgba(0, 0, 0, 0.8); border-top-color: rgba(0, 0, 0, 0.8); border-bottom-color: rgba(0, 0, 0, 0.8); border-top-width: 0; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0; padding-top: 10px; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; flex-wrap: nowrap; align-items: stretch;">
48+
<ui:VisualElement style="flex-grow: 1; border-left-color: rgb(32, 32, 32); border-right-color: rgb(32, 32, 32); border-top-color: rgb(32, 32, 32); border-bottom-color: rgb(32, 32, 32); border-top-width: 0; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0; padding-top: 10px; padding-right: 10px; padding-left: 10px; padding-bottom: 10px; flex-wrap: nowrap; align-items: stretch;">
4749
<ui:IMGUIContainer />
4850
</ui:VisualElement>
4951
</ui:VisualElement>

Editor/UXML/CollectionItemTreeAsset.uxml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
22
<Style src="project://database/Packages/com.brunomikoski.scriptableobjectcollection/Editor/USS/CollectionStyle.uss?fileID=7433441132597879392&amp;guid=f6040fd5efe6a1e43a9e95760a53fcba&amp;type=3#CollectionStyle" />
3-
<ui:VisualElement style="flex-grow: 1; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0;">
3+
<ui:VisualElement name="VisualElement" style="flex-grow: 1; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0;">
44
<ui:Foldout name="header-foldout" text="Title" value="true">
55
<ui:IMGUIContainer name="imgui-container" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0;" />
6-
<uie:Toolbar style="margin-top: 10px; display: none;">
7-
<uie:ToolbarButton text="Rename" parse-escape-sequences="true" display-tooltip-when-elided="true" enable-rich-text="false" />
8-
<uie:ToolbarButton text="Select" parse-escape-sequences="true" display-tooltip-when-elided="true" enable-rich-text="false" />
9-
<uie:ToolbarButton text="Duplicate" parse-escape-sequences="true" display-tooltip-when-elided="true" enable-rich-text="false" />
10-
<uie:ToolbarButton text="Copy" parse-escape-sequences="true" display-tooltip-when-elided="true" enable-rich-text="false" />
11-
<uie:ToolbarButton text="Paste" parse-escape-sequences="true" display-tooltip-when-elided="true" enable-rich-text="false" />
12-
</uie:Toolbar>
136
</ui:Foldout>
147
<ui:TextField picking-mode="Ignore" value="Default Endless" name="rename-text-field" is-delayed="true" style="display: none; position: absolute; flex-grow: 1; top: 0; width: 100%; background-color: rgba(0, 0, 0, 0); -unity-font-style: bold; margin-left: 0; left: 2px; overflow: visible; visibility: visible;" />
158
</ui:VisualElement>

Scripts/Editor/CustomEditors/CollectionCustomEditor.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,7 @@ public override VisualElement CreateInspectorGUI()
208208

209209

210210
expandShrinkButton = root.Q<Button>("expand-button");
211-
expandShrinkButton.Add(new Image()
212-
{
213-
image = EditorGUIUtility.IconContent("d_Grid.MoveTool").image,
214-
scaleMode = ScaleMode.ScaleToFit
215-
});
211+
216212
expandShrinkButton.clickable.activators.Clear();
217213
expandShrinkButton.RegisterCallback<MouseUpEvent>(OnToggleExpand);
218214

@@ -240,6 +236,7 @@ private void BindCollectionItemListItem(VisualElement targetElement, int targetI
240236
Foldout foldout = targetElement.Q<Foldout>("header-foldout");
241237
foldout.viewDataKey = targetIndex.ToString();
242238
foldout.text = targetItem.name;
239+
243240
Editor editor = EditorCache.GetOrCreateEditorForObject(targetItem);
244241

245242
Label titleLabel = targetElement.Q<Foldout>("header-foldout").Q<Label>();
@@ -329,6 +326,13 @@ private void OnToggleExpand(MouseUpEvent evt)
329326

330327
foldout.value = !isOn.Value;
331328
}
329+
330+
if (!isOn.HasValue)
331+
{
332+
isOn = false;
333+
}
334+
335+
expandShrinkButton.text = isOn.Value ? "\u2192" : "\u2193";
332336
}
333337

334338
private void OnEnable()
@@ -628,7 +632,7 @@ private void RenameItemAtIndex(int targetIndex)
628632
Undo.RecordObject(filteredItems[targetIndex], "Rename Item");
629633
VisualElement targetElement = collectionItemListView.GetRootElementForIndex(targetIndex);
630634

631-
currentRenamingLabel = targetElement.Q<Foldout>().Q<Toggle>().Q<Label>();
635+
currentRenamingLabel = targetElement.Q<Label>("", "unity-toggle__text");
632636

633637
currentRenamingLabel.style.display = DisplayStyle.None;
634638

0 commit comments

Comments
 (0)