Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMCL-1517: Fix ListView inspectors #903

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions com.unity.cinemachine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.0.0-pre.9] - 2023-10-31

### Fixed
- Regresion fix: Sequencer inspector child camera popups were not being populated.
- Regresion fix: Manager Camera's child camera warning icons were not being updated correctly.
- Bugfix: CinemachineInputAxisController editor was missing foldout arrows on the Driven Axis items.


## [3.0.0-pre.8] - 2023-09-22

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,23 @@ public override VisualElement CreateInspectorGUI()
list.RefreshItems(); // rebuild the list
});

// Delay to work around a bug in ListView (UUM-27687 and UUM-27688)
list.OnInitialGeometry(() =>
list.makeItem = () => new BindableElement { style = { flexDirection = FlexDirection.Row }};
list.bindItem = (row, index) =>
{
list.makeItem = () => new BindableElement { style = { flexDirection = FlexDirection.Row }};
list.bindItem = (row, index) =>
{
// Remove children - items get recycled
for (int i = row.childCount - 1; i >= 0; --i)
row.RemoveAt(i);
// Remove children - items get recycled
for (int i = row.childCount - 1; i >= 0; --i)
row.RemoveAt(i);

var def = new CinemachineBlenderSettings.CustomBlend();
var element = elements.GetArrayElementAtIndex(index);
var def = new CinemachineBlenderSettings.CustomBlend();
var element = elements.GetArrayElementAtIndex(index);

var from = row.AddChild(CreateCameraPopup(element.FindPropertyRelative(() => def.From)));
var to = row.AddChild(CreateCameraPopup(element.FindPropertyRelative(() => def.To)));
var blend = row.AddChild(new PropertyField(element.FindPropertyRelative(() => def.Blend), ""));
FormatElement(false, from, to, blend);
var from = row.AddChild(CreateCameraPopup(element.FindPropertyRelative(() => def.From)));
var to = row.AddChild(CreateCameraPopup(element.FindPropertyRelative(() => def.To)));
var blend = row.AddChild(new PropertyField(element.FindPropertyRelative(() => def.Blend), ""));
FormatElement(false, from, to, blend);

((BindableElement)row).BindProperty(element); // bind must be done at the end
};
});
((BindableElement)row).BindProperty(element); // bind must be done at the end
};

// Local function
static void FormatElement(bool isHeader, VisualElement e1, VisualElement e2, VisualElement e3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,9 @@ public override VisualElement CreateInspectorGUI()
var element = instructions.GetArrayElementAtIndex(index);

var vcamSelProp = element.FindPropertyRelative(() => def.Camera);
var vcamSel = row.AddChild(new PopupField<Object>());
var vcamSel = row.AddChild(new PopupField<Object> { name = $"vcamSelector{index}" });
vcamSel.formatListItemCallback = (obj) => obj == null ? "(null)" : obj.name;
vcamSel.formatSelectedValueCallback = (obj) => obj == null ? "(null)" : obj.name;
vcamSel.TrackAnyUserActivity(() =>
{
if (Target == null)
return; // object deleted
vcamSel.choices ??= new();
vcamSel.choices.Clear();
var children = Target.ChildCameras;
for (int i = 0; i < children.Count; ++i)
vcamSel.choices.Add(children[i]);
});

var blend = row.AddChild(
new PropertyField(element.FindPropertyRelative(() => def.Blend), ""));
Expand All @@ -90,6 +80,28 @@ public override VisualElement CreateInspectorGUI()
vcamSel.BindProperty(vcamSelProp);
};

// Update the list items
list.TrackAnyUserActivity(() =>
{
int index = 0;
var iter = list.itemsSource.GetEnumerator();
while (iter.MoveNext())
{
var vcamSel = list.Q<PopupField<Object>>($"vcamSelector{index}");
if (vcamSel != null)
{
if (Target == null)
return; // object deleted
vcamSel.choices ??= new();
vcamSel.choices.Clear();
var children = Target.ChildCameras;
for (int i = 0; i < children.Count; ++i)
vcamSel.choices.Add(children[i]);
}
++index;
}
});

// Local function
static void FormatInstructionElement(bool isHeader, VisualElement e1, VisualElement e2, VisualElement e3)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
foldout.Add(new PropertyField(childProperty));
childProperty.NextVisible(false);
}
return new InspectorUtility.FoldoutWithOverlay(foldout, overlay, null);
return new InspectorUtility.FoldoutWithOverlay(foldout, overlay, null) { style = { marginLeft = 12 }};
}
}

Expand All @@ -158,13 +158,11 @@ public override VisualElement CreatePropertyGUI(SerializedProperty property)
showBorder = false,
showBoundCollectionSize = false,
showFoldoutHeader = false,
virtualizationMethod = CollectionVirtualizationMethod.DynamicHeight
virtualizationMethod = CollectionVirtualizationMethod.DynamicHeight,
style = { marginLeft = -12 }
});
list.BindProperty(property);

// Delay to work around a bug in ListView (UUM-33402)
list.OnInitialGeometry(() => list.reorderable = false);

var isEmptyMessage = ux.AddChild(new HelpBox(
"No applicable components found. Must have one of: "
+ InspectorUtility.GetAssignableBehaviourNames(typeof(IInputAxisOwner)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ public static void AddChildCameras(
for (int i = row.childCount - 1; i >= 0; --i)
row.RemoveAt(i);

var warningIcon = row.AddChild(InspectorUtility.MiniHelpIcon("Item is null"));
var element = list.itemsSource[index] as CinemachineVirtualCameraBase;
row.AddChild(new ObjectField
{
Expand All @@ -518,6 +517,11 @@ public static void AddChildCameras(
if (element == null)
return;

var warningIcon = row.AddChild(InspectorUtility.MiniHelpIcon("Item is null"));
var warningText = getChildWarning == null ? string.Empty : getChildWarning(element);
warningIcon.tooltip = warningText;
warningIcon.SetVisible(!string.IsNullOrEmpty(warningText));

var dragger = row.AddChild(new Label(" "));
dragger.AddToClassList("unity-base-field__label--with-dragger");

Expand All @@ -540,13 +544,6 @@ public static void AddChildCameras(
});
priorityField.TrackPropertyValue(priorityProp, (p) => priorityField.value = p.intValue);
priorityField.TrackPropertyValue(enabledProp, (p) => priorityField.value = p.boolValue ? priorityProp.intValue : 0);

warningIcon.TrackAnyUserActivity(() =>
{
var warningText = (getChildWarning == null || element == null) ? string.Empty : getChildWarning(element);
warningIcon.tooltip = warningText;
warningIcon.SetVisible(!string.IsNullOrEmpty(warningText));
});
};

list.itemsAdded += (added) =>
Expand Down Expand Up @@ -585,10 +582,8 @@ public static void AddChildCameras(
// Update child list
if (!isMultiSelect)
{
var rebuild = list.itemsSource != vcam.ChildCameras || list.itemsSource.Count != vcam.ChildCameras.Count;
list.itemsSource = vcam.ChildCameras;
if (rebuild)
list.Rebuild();
list.Rebuild();
}
});
}
Expand Down
Loading