Get/Set Sprite Custom Outline from script?

I’d like to get/set custom outlines (like in Sprite Editor) from a script in Editor.

From the meta file:
6338901--704058--Capture - Copy.PNG

I can modify other properties of spritesheet with the TextureImporter Settings/Properties, but I’m struggling to find the spot for adjusting the outline. If there’s no public way to do this, is modifying the .meta file directly dangerous?

Hi @Lo-renzo ,

Modifying the outline is not exposed to the public API for you to change it directly, as you can see here: Unity - Scripting API: SpriteMetaData

However, as you mentioned, it’s possible to change it directly by modifying the meta file.

You can find a working example of how you can do it here: Setting custom sprite outline via script/asset postprocessor

Using this specific method in the Editor is not dangerous if you use the proper values :wink:

Good luck with it!

1 Like

Hey @DiegoDePalacio_1 , and why is this not exposed in the public API? Seems like an unnecessarily complex workaround for something that shouldn’t be difficult to achieve :frowning:

@Lo-renzo , @Joseguepardo , you should be able to modify the Sprite outline using ISpriteOutlineDataProvider API as shown in this documentation page.

Do we know of any other outline implementations done except for the Unity one?
For example, in my case I’m using 1024x1024 textures which I’d like to use an outline for. The built-in Unity outline creates too many verts (189 tris, 184 verts), which in my case would suffice with just 10 or 15 verts to remove most of the transparent area.
Would be great if there were some implementations lying around!