Skip to content

Commit

Permalink
CMCL-0000: Spline roll cleanup (#997)
Browse files Browse the repository at this point in the history
* Spline roll cleanup

* Add button in inspector to engage the scene view tool

* Prettier SplineRoll inspector - requires minor API change

* Add missing tooltips

* Update CinemachineSplineRollEditor.cs

* Fix broken roll data list

* Add tooltips in scene view

* Add SplineDataInspectorUtility

* Refactor spline roll to work with scaled splines

* Refactor ISplineReferencer

* Update SplineSettings.cs

* Update CinemachineSplineCart.cs

* Fix missing doc and remove finalizer

* Remove some infrastructure editor classes from public

* New spline roll tool icons

* Update CinemachineSplineDolly.cs
  • Loading branch information
glabute authored May 30, 2024
1 parent 6828a18 commit cedfb6c
Show file tree
Hide file tree
Showing 27 changed files with 972 additions and 364 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions com.unity.cinemachine/Editor/EditorResources/Icons/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class CinemachineSplineCartEditor : UnityEditor.Editor
public override VisualElement CreateInspectorGUI()
{
var ux = new VisualElement();
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.SplineSettings)));

var splineIsChildHelp = ux.AddChild(new HelpBox("Spline should not be a child of this object.", HelpBoxMessageType.Error));
ux.Add(new PropertyField(serializedObject.FindProperty("m_SplineSettings")));
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.UpdateMethod)));

var autoDollyProp = serializedObject.FindProperty(() => Target.AutomaticDolly);
Expand All @@ -26,6 +28,18 @@ public override VisualElement CreateInspectorGUI()
targetField.SetVisible(autodolly != null && autodolly.RequiresTrackingTarget);
});

ux.TrackAnyUserActivity(() =>
{
bool isChild = false;
for (int i = 0; !isChild && i < targets.Length; ++i)
{
var t = targets[i] as CinemachineSplineCart;
if (t != null && t.Spline != null)
isChild = t.transform.IsAncestorOf(t.Spline.transform);
}
splineIsChildHelp.SetVisible(isChild);
});

return ux;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using UnityEngine.Splines;

namespace Unity.Cinemachine.Editor
{
Expand All @@ -17,8 +16,9 @@ public override VisualElement CreateInspectorGUI()

this.AddMissingCmCameraHelpBox(ux);
var noSplineHelp = ux.AddChild(new HelpBox("A Spline is required.", HelpBoxMessageType.Warning));
var splineIsChildHelp = ux.AddChild(new HelpBox("Spline should not be a child of this object.", HelpBoxMessageType.Error));

var splineProp = serializedObject.FindProperty(() => Target.SplineSettings);
var splineProp = serializedObject.FindProperty("m_SplineSettings");
ux.Add(new PropertyField(splineProp));
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.SplineOffset)));
ux.Add(new PropertyField(serializedObject.FindProperty(() => Target.CameraRotation)));
Expand All @@ -33,6 +33,18 @@ public override VisualElement CreateInspectorGUI()
noSplineHelp.SetVisible(noSpline);
});

ux.TrackAnyUserActivity(() =>
{
bool isChild = false;
for (int i = 0; !isChild && i < targets.Length; ++i)
{
var t = targets[i] as CinemachineSplineDolly;
if (t != null && t.Spline != null)
isChild = t.transform.IsAncestorOf(t.Spline.transform);
}
splineIsChildHelp.SetVisible(isChild);
});

return ux;
}
}
Expand Down
Loading

0 comments on commit cedfb6c

Please sign in to comment.