Using SpriteShape Spline editor outside of SpriteShapeController

Hi,

I want to use the Sprite Shape Controller editor tool outside of the SpriteShapeController.

I want to save the SpriteShape spline data in a scritpable object and then dynamically set the data to the SpriteShapeController at runtime as they get spawned.

I can’t seem to get access to SpriteShapeEditorTools because it’s all internal.

I tried a work around I thought might work, which is creating a temporary SpriteShapeController from a prefab and nest it’s inspector the in the scriptable object inspector. but that didn’t work. The editor tool is greyed out. I assume the editor tool requires the SpriteShapeController gameobject to be selected

Anyone has any idea on how to reuse the SpriteShapeEditorTool without actively selecting the SpriteShapeController gameobject?

You can get to the SpriteShapeEditorTool with reflection but you may also need to mess with the selected game object.

private static Object GetActiveSpriteShapeEditorTool()
{
    return Assembly.Load("Unity.2D.SpriteShape.Editor")
        .GetType("UnityEditor.U2D.SpriteShapeInternal.SpriteShapeEditorTool")
        .GetProperty("activeSpriteShapeEditorTool")
        .GetValue(null);
}

I would probably try poking around UnityEditor.U2D.Common.Path.PathEditorTool, which is the base class for SpriteShapeEditorTool. Oh, but if you need this at runtime, I’m not sure this will work. :confused: