Sprite Shape editing Height all control points at once

Hi. I’m trying to perform the action in this tutorial at 4:22. I have selected all the points and adjust the height but it only affects a single point, maybe the last/first. Tangent Mode and Position seem to affect all the points, but Height and Corner only seem to affect a single point. Have I missed a step?

From scratch: Add closed shape, edit spline, drag over the 4 default control points (they turn white to yellow), change height. This only affects (for me) the bottom left control point.

Any ideas?
Thanks

4 Likes

Hi,

Welcome to our community! :slight_smile:

Could you please share screenshots of what you see in Unity? And which version of Unity do you use?

2020.3.21f1
This is what I see. Twiddling the Height only causes the bottom left point to bulge (or contract).

1 Like

I think you are right about the version.
I went back to a 2020.3.16f1 build and the above behaviour works as intended. 2020.3.20f1 and 2020.3.21f1 work the way described above. Unless there’s something weird with my versions.
Guess I’ll have to use the fudge technique and change the sprites Pixels Per Unit to get a similar effect. if needed.

1 Like

If something does not work in one version but in others, there might be a bug in that one version. Bugs are fairly common in Unity.

It’s the same issue as the OP describes for me in version 2021.2.0f1. Only a single point selected is modified for me and not all of them. Doesn’t matter if you select all points, only a few, select with a bounding box, or select multiple points individually with control. Only one point in the group has the height changed. Also doesn’t matter if it’s an open or closed sprite shape.

1 Like

Recently upgraded to 2021.2.1f1 and still have the problem too.
Hoping one day someone figures it out.

1 Like

Maybe you could report a bug to Unity via Help > Report a bug in Unity.

Because I don’t know that it’s a bug in unity. Perhaps there is some sort of change that was made in their unity setup that makes that work? Nothing I can find in any documentation other than here even mentions adjusting the height of multiple points at once. The documentation for sprite shape 7.0.2 only mentions that selecting a control point enables the following, one of which is the height. Maybe it’s not intended for multiple points? Or maybe there’s some other option that is required to be set. Point is I’m not submitting a bug report because I don’t have the knowledge that it’s a bug. Perhaps the people who set up the course should do so??

To judge whether something is a bug is the job of Unity’s employees. Neither you nor I have access to the source code of the Unity engine. For this reason, it is impossible for us to know wherther something is a bug.

Of course, we should not misuse the “Report a bug” button to message the Unity developers just because we are stuck again but if we use one of their tools and things do not work as expected, they are often glad if somebody brings the issue up to them. And even if the problem is not a bug, it could still be a problem that they could want to solve, for example, an insufficient description in the manual or a confusing GUI or something like that.

Given I understood your problem correctly, I was not able to find any solution on the internet, and I also was not able to find a similar problem. Since multiple people seem to have the same problem, the behaviour in Unity might be a bug.

Just got a response from Unity. It is a known issue:

It’s not the ticket I submitted by judging by the name of the file it was probably someone from this course!

1 Like

Thanks for sharing the link. I asked multiple people who had the same issue as you to report a bug. I’m glad that there is an official entry in the “issue tracker” now. :slight_smile:

Until the Unity programmers fixed the bug, please edit the control points manually.

This problem with changing height of multiple spline points still exist in 2021.2.2f1 :frowning:

Hey guys, just thought I would chime in. I was having the same problem as mentioned, I downloaded a newer version of Unity this morning and I am not sure if that might be the cause, However, I found that if you select each point individually and make the height adjustment for each one separately it worked. I am not sure if this will work for you but it worked for me and thought I would pass it on.

1 Like

Thanks for sharing this information. :slight_smile:

I think the problem is/was that we cannot edit multiple control points simultaneously. Editing them separately has always been working.

After playing around with the Unity UIToolkit - Introduction To Editor Scripting course, here’s a bodge:

Create a folder called “Editor”. Inside create a new C# script called “SpriteShapeHeightEditor” and replace with the below code. Compile.

This creates a menu in the Unity Editor called “Custom”. Click on the menu item. Change the height to the desired value, click on a sprite shape (so that the game object appears in the inspector), click Change Height.

Tested in 2021.2.1f1 and 2020.3.22f1.
Please save your project though in case it does something wonky.

using UnityEngine;
using UnityEditor;
using UnityEngine.UIElements;
using UnityEditor.UIElements;

public class SpriteShapeHeightEditor : EditorWindow
{
    FloatField floatField;

    [MenuItem("Custom/Edit Sprite Shape Height")]
    public static void ShowWindow()
    {
        SpriteShapeHeightEditor window = GetWindow<SpriteShapeHeightEditor>();
        window.titleContent = new GUIContent("Edit Sprite Shape Height");
    }

    public void CreateGUI()
    {
        rootVisualElement.Add(new Button(EditHeights) { text = "Change Height"});
        floatField = new FloatField("Height");
        floatField.value = 1f;
        rootVisualElement.Add(floatField);
        floatField.RegisterCallback<ChangeEvent<float>>(evt => { floatField.value = Mathf.Clamp(evt.newValue, 0.1f, 4f); });
    }

    void EditHeights()
    {
        if (!Selection.activeGameObject.TryGetComponent<UnityEngine.U2D.SpriteShapeController>(out UnityEngine.U2D.SpriteShapeController spriteShape)) return;
        Tools.current = Tool.View; // fudge, if in edit spline mode the changes dont seem to apply
        Undo.RecordObject(spriteShape, $"Set Sprite Shape Height to {floatField.value}");
        for (int i = 0; i < spriteShape.spline.GetPointCount(); i++) spriteShape.spline.SetHeight(i, floatField.value);
        EditorUtility.SetDirty(spriteShape);
    }
}

2 votes on the Unity Bug Tracker. Don’t think this will be fixed anytime soon!

8 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms