Skip to content

Commit c034e22

Browse files
committed
Remove illegal scene tool activation buttons from inspectors, replace with helpboxes
1 parent 49c7ab6 commit c034e22

File tree

3 files changed

+24
-47
lines changed

3 files changed

+24
-47
lines changed

com.unity.cinemachine/Editor/Editors/CinemachineSplineDollyLookAtTargetsEditor.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,23 @@ public override VisualElement CreateInspectorGUI()
8383
HelpBoxMessageType.Warning);
8484
ux.Add(invalidHelp);
8585

86-
var tooltip = "Use the Scene View tool to Edit the LookAt targets on the spline";
87-
var buttonRow = ux.AddChild(new InspectorUtility.LabeledRow("Edit in Scene View", tooltip));
88-
var toolButton = buttonRow.Contents.AddChild(
89-
CinemachineSceneToolHelpers.CreateSceneToolActivationButtonForInspector(
90-
typeof(LookAtDataOnSplineTool), target, LookAtDataOnSplineTool.IconPath, tooltip));
86+
var toolHelp = ux.AddChild(new HelpBox(
87+
"Use the Scene View tool to Edit the LookAt targets on the spline", HelpBoxMessageType.Info));
88+
toolHelp.OnInitialGeometry(() =>
89+
{
90+
var icon = toolHelp.Q(className: "unity-help-box__icon");
91+
if (icon != null)
92+
{
93+
icon.style.backgroundImage = AssetDatabase.LoadAssetAtPath<Texture2D>(LookAtDataOnSplineTool.IconPath);
94+
icon.style.marginRight = 12;
95+
}
96+
});
97+
ux.AddSpace();
9198

9299
ux.TrackAnyUserActivity(() =>
93100
{
94101
var haveSpline = splineData != null && splineData.GetGetSplineAndDolly(out _, out _);
95102
invalidHelp.SetVisible(!haveSpline);
96-
toolButton.SetEnabled(haveSpline);
97103
});
98104

99105
var targetsProp = serializedObject.FindProperty(() => splineData.Targets);

com.unity.cinemachine/Editor/Editors/CinemachineSplineRollEditor.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ public override VisualElement CreateInspectorGUI()
2222
HelpBoxMessageType.Warning);
2323
ux.Add(invalidHelp);
2424

25-
var tooltip = "Use the Scene View tool to adjust the roll data points";
26-
var buttonRow = ux.AddChild(new InspectorUtility.LabeledRow("Edit in Scene View", tooltip));
27-
var toolButton = buttonRow.Contents.AddChild(
28-
CinemachineSceneToolHelpers.CreateSceneToolActivationButtonForInspector(
29-
typeof(SplineRollTool), target, SplineRollTool.IconPath, tooltip));
25+
var toolHelp = ux.AddChild(new HelpBox(
26+
"Use the Scene View tool to adjust the roll data points", HelpBoxMessageType.Info));
27+
toolHelp.OnInitialGeometry(() =>
28+
{
29+
var icon = toolHelp.Q(className: "unity-help-box__icon");
30+
if (icon != null)
31+
{
32+
icon.style.backgroundImage = AssetDatabase.LoadAssetAtPath<Texture2D>(SplineRollTool.IconPath);
33+
icon.style.marginRight = 12;
34+
}
35+
});
36+
ux.AddSpace();
3037

3138
ux.TrackAnyUserActivity(() =>
3239
{
3340
var haveSpline = splineData != null && splineData.SplineContainer != null;
3441
invalidHelp.SetVisible(!haveSpline);
35-
toolButton.SetEnabled(haveSpline);
3642
});
3743

3844
var rollProp = serializedObject.FindProperty(() => splineData.Roll);

com.unity.cinemachine/Editor/Utility/CinemachineSceneToolHelpers.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,6 @@ static class CinemachineSceneToolHelpers
2929

3030
static Color s_NormalBkgColor = Color.black;
3131

32-
/// <summary>Create a button for the inspector that activates a scene tool</summary>
33-
public static VisualElement CreateSceneToolActivationButtonForInspector(
34-
Type toolType, UnityEngine.Object target, string iconPath, string tooltip)
35-
{
36-
var toolButton = new Button(() =>
37-
{
38-
if (Selection.activeObject != target)
39-
Selection.activeObject = target;
40-
EditorApplication.delayCall += () => ToolManager.SetActiveTool(toolType);
41-
})
42-
{
43-
tooltip = tooltip,
44-
style =
45-
{
46-
flexGrow = 0,
47-
flexBasis = 2 * InspectorUtility.SingleLineHeight,
48-
height = InspectorUtility.SingleLineHeight + 3,
49-
},
50-
};
51-
toolButton.Add(new Image { image = AssetDatabase.LoadAssetAtPath<Texture2D>(iconPath) });
52-
53-
// Capture "normal" colors
54-
if (s_NormalBkgColor == Color.black)
55-
toolButton.OnInitialGeometry(() => s_NormalBkgColor = toolButton.resolvedStyle.backgroundColor);
56-
57-
toolButton.ContinuousUpdate(() =>
58-
{
59-
if (ToolManager.activeToolType == toolType)
60-
toolButton.style.backgroundColor = Color.Lerp(s_NormalBkgColor, new Color(0.1f, 0.3f, 0.6f, 1), 0.5f);
61-
else
62-
toolButton.style.backgroundColor = s_NormalBkgColor;
63-
});
64-
return toolButton;
65-
}
66-
6732
public static float SliderHandleDelta(Vector3 newPos, Vector3 oldPos, Vector3 forward)
6833
{
6934
var delta = newPos - oldPos;

0 commit comments

Comments
 (0)