|
1 | | -using System; |
2 | 1 | using System.Linq; |
3 | 2 | using UnityEditor.Experimental.GraphView; |
4 | 3 | using UnityEngine; |
@@ -133,6 +132,14 @@ public VFXBlackboard(VFXView view) |
133 | 132 | m_AddButton.SetEnabled(false); |
134 | 133 |
|
135 | 134 | this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu)); |
| 135 | + |
| 136 | + // Workaround: output category is in a scrollview which can lead to get the Add button invisible (moved out of the visible viewport of the scrollviewer) |
| 137 | + var scrollView = this.Q<ScrollView>(); |
| 138 | + if (scrollView != null) |
| 139 | + { |
| 140 | + scrollView.RegisterCallback<GeometryChangedEvent, ScrollView>(OnGeometryChanged, scrollView); |
| 141 | + scrollView.horizontalScroller.valueChanged += x => OnOutputCategoryScrollChanged(scrollView); |
| 142 | + } |
136 | 143 | } |
137 | 144 |
|
138 | 145 | public void LockUI() |
@@ -167,6 +174,23 @@ DropdownMenuAction.Status GetContextualMenuStatus() |
167 | 174 | return DropdownMenuAction.Status.Disabled; |
168 | 175 | } |
169 | 176 |
|
| 177 | + void OnOutputCategoryScrollChanged(ScrollView scrollView) |
| 178 | + { |
| 179 | + OnGeometryChanged(null, scrollView); |
| 180 | + } |
| 181 | + |
| 182 | + void OnGeometryChanged(GeometryChangedEvent evt, ScrollView scrollView) |
| 183 | + { |
| 184 | + if (scrollView != null) |
| 185 | + { |
| 186 | + var addOutputButton = scrollView.Q<Button>("addOutputButton"); |
| 187 | + if (addOutputButton != null) |
| 188 | + { |
| 189 | + addOutputButton.style.left = -scrollView.horizontalScroller.highValue + scrollView.horizontalScroller.value; |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | + |
170 | 194 | void BuildContextualMenu(ContextualMenuPopulateEvent evt) |
171 | 195 | { |
172 | 196 | evt.menu.AppendAction("Select All", (a) => SelectAll(), (a) => GetContextualMenuStatus()); |
|
0 commit comments