Skip to content

Commit 8bfae03

Browse files
julienamsellemEvergreen
authored andcommitted
[VFX] Some UI can overflow the bounds
Jira: UUM-70602 Steps to reproduce: 1. Create Random Selector Weighted node 2. Select it 3. In the Inspector, click Clamp Weight 4. Click Clamp Weight again Actual results: The input fields have overflowed their container Expected results: UI elements stay in their container upon adjusting parameters Tested on (OS): repro with other input fields, labels too, i.e Input fields, labels that come from ShaderGraph ![](https://jira.unity3d.com/secure/attachment/1436950/Screenshot%202024-04-24%20at%2015.09.40.png)
1 parent c79036d commit 8bfae03

File tree

5 files changed

+34
-40
lines changed

5 files changed

+34
-40
lines changed

Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXEditableDataAnchor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ void BuildProperty()
114114
{
115115
Remove(m_PropertyRM);
116116
}
117-
m_PropertyRM = PropertyRM.Create(controller, VFXNodeUI.DefaultLabelWidth);
117+
118+
var labelWidth = VFXNodeUI.DefaultLabelWidth;
119+
if (node != null)
120+
{
121+
node.GetWidths(out labelWidth, out _);
122+
}
123+
m_PropertyRM = PropertyRM.Create(controller, labelWidth);
118124
if (m_PropertyRM != null)
119125
{
120126
Add(m_PropertyRM);

Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXNodeUI.cs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,9 @@ public virtual void OnControllerChanged(ref ControllerChangedEvent e)
172172

173173
protected virtual bool HasPosition() => true;
174174

175-
private bool SyncSettings()
175+
private void SyncSettings()
176176
{
177177
Profiler.BeginSample("VFXNodeUI.SyncSettings");
178-
var hasChanged = false;
179178
var settings = controller.settings;
180179
var graphSettings = controller.model.GetSettings(false, VFXSettingAttribute.VisibleFlags.InGraph).ToArray();
181180

@@ -186,7 +185,6 @@ private bool SyncSettings()
186185
{
187186
propertyRM.RemoveFromHierarchy();
188187
m_Settings.Remove(propertyRM);
189-
hasChanged = true;
190188
}
191189
}
192190

@@ -199,7 +197,6 @@ private bool SyncSettings()
199197
var setting = settings.Single(x => string.Compare(x.name, vfxSetting.field.Name, StringComparison.OrdinalIgnoreCase) == 0);
200198
var propertyRM = AddSetting(setting);
201199
settingsContainer.Insert(i, propertyRM);
202-
hasChanged = true;
203200
}
204201
}
205202

@@ -224,20 +221,17 @@ private bool SyncSettings()
224221
}
225222

226223
Profiler.EndSample();
227-
return hasChanged;
228224
}
229225

230-
bool SyncAnchors()
226+
void SyncAnchors()
231227
{
232228
Profiler.BeginSample("VFXNodeUI.SyncAnchors");
233-
var hasResync = SyncAnchors(controller.outputPorts, outputContainer, false);
234-
hasResync |= SyncAnchors(controller.inputPorts, inputContainer, controller.HasActivationAnchor);
229+
SyncAnchors(controller.outputPorts, outputContainer, false);
230+
SyncAnchors(controller.inputPorts, inputContainer, controller.HasActivationAnchor);
235231
Profiler.EndSample();
236-
237-
return hasResync;
238232
}
239233

240-
bool SyncAnchors(ReadOnlyCollection<VFXDataAnchorController> ports, VisualElement container, bool hasActivationPort)
234+
void SyncAnchors(ReadOnlyCollection<VFXDataAnchorController> ports, VisualElement container, bool hasActivationPort)
241235
{
242236
// Check whether resync is needed
243237
bool needsResync = false;
@@ -295,7 +289,6 @@ bool SyncAnchors(ReadOnlyCollection<VFXDataAnchorController> ports, VisualElemen
295289

296290
if (hasActivationPort)
297291
UpdateActivationPortPositionIfAny(); // Needed to account for expanded state change in case of undo/redo
298-
return needsResync;
299292
}
300293

301294
private void UpdateActivationPortPosition(VFXDataAnchor anchor)
@@ -416,18 +409,15 @@ protected virtual void SelfChange()
416409

417410
base.expanded = controller.expanded;
418411

419-
var needRefresh = SyncSettings();
420-
needRefresh |= SyncAnchors();
412+
SyncSettings();
413+
SyncAnchors();
421414
Profiler.BeginSample("VFXNodeUI.SelfChange The Rest");
422415
RefreshExpandedState();
423416
Profiler.EndSample();
424417
Profiler.EndSample();
425418

426419
UpdateCollapse();
427-
if (needRefresh)
428-
{
429-
EditorApplication.delayCall += RefreshLayout;
430-
}
420+
RefreshLayout();
431421
}
432422

433423
protected virtual VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController ctrl, VFXNodeUI node)
@@ -520,18 +510,23 @@ private PropertyRM AddSetting(VFXSettingController setting)
520510
return rm;
521511
}
522512

513+
public void GetWidths(out float labelWidth, out float controlWidth)
514+
{
515+
var settingsLabelWidth = 0f;
516+
var inputsLabelWidth = 0f;
517+
controlWidth = 50f;
518+
GetPreferredSettingsWidths(ref settingsLabelWidth, ref controlWidth);
519+
GetPreferredWidths(ref inputsLabelWidth, ref controlWidth);
520+
labelWidth = Mathf.Max(settingsLabelWidth, inputsLabelWidth);
521+
if (labelWidth > 0)
522+
labelWidth = Mathf.Max(labelWidth, defaultLabelWidth);
523+
}
524+
523525
protected virtual void RefreshLayout()
524526
{
525527
if (expanded)
526528
{
527-
var settingsLabelWidth = 0f;
528-
var inputsLabelWidth = 0f;
529-
var controlWidth = 50f;
530-
GetPreferredSettingsWidths(ref settingsLabelWidth, ref controlWidth);
531-
GetPreferredWidths(ref inputsLabelWidth, ref controlWidth);
532-
var labelWidth = Mathf.Max(settingsLabelWidth, inputsLabelWidth);
533-
if (labelWidth > 0)
534-
labelWidth = Mathf.Max(labelWidth, defaultLabelWidth);
529+
GetWidths(out var labelWidth, out var controlWidth);
535530
ApplySettingsWidths(labelWidth);
536531
ApplyWidths(labelWidth, controlWidth);
537532
}

Packages/com.unity.visualeffectgraph/Editor/GraphView/Elements/VFXOperatorUI.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ protected override void OnNewController()
6060
if (m_EditContainer != null)
6161
m_EditContainer.name = "edit-container";
6262
}
63-
64-
}
65-
66-
protected override void ApplyWidths(float labelWidth, float controlWidth)
67-
{
68-
base.ApplyWidths(labelWidth, controlWidth);
69-
inputContainer.style.width = labelWidth + controlWidth + 20;
7063
}
7164

7265
private bool isEditable => controller != null && controller.isEditable;

Packages/com.unity.visualeffectgraph/Editor/UIResources/uss/PropertyRM.uss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ Vector3PropertyRM.propertyrm VFXVector3Field.fieldContainer
219219
flex: 1 0 auto;
220220
}
221221

222-
VFXVector3Field FloatField {
222+
VFXVector3Field .unity-float-field {
223223
margin-left: 4px;
224224
}
225225

226+
226227
ColorPropertyRM .unity-float-field
227228
{
228229
flex: 1 0 auto;
@@ -386,3 +387,7 @@ VFXColorField .colorcontainer
386387
.propertyrm.hasDepth > .unity-base-field {
387388
margin-left: 4px;
388389
}
390+
391+
.fieldContainer .unity-base-text-field__input {
392+
width: 36px;
393+
}

Packages/com.unity.visualeffectgraph/Editor/UIResources/uss/VFXContext.uss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ VFXContextUI > #node-border > #inside > #contents
346346
background-color: rgba(45,45,45,0.8);
347347
}
348348

349-
VFXContextUI ColorPropertyRM .fieldContainer > *
350-
{
351-
width: 56px;
352-
}
353-
354349
VFXContextUI .subtitle
355350
{
356351
align-self:center;

0 commit comments

Comments
 (0)