Unity2D Sprite editor multiple pivot point edit

Hey guys,

I wonder if there is a way in the sprite editor for a sprite that is set to multiple to set them all to a certain position without manually selecting them one by one ? I have like 50x sprites so it would be really convinient just to multi edit the pivot point. Any ideas ?

Thanks a lot for your time :slight_smile:

Claude

I’ve been using the following script for the editor which I found searching for the same thing in forums. It was written by David Robins ([here’s a video][1] of how to use it, and [where he posted the code][2] on Reddit. You put it in a directory named “Editor” within your project structure, and it will be loaded to the top menu of the Unity Editor when you restart it. It has been very useful for spritesheets. I’m still trying to find a solution that works for a group of individual sprites. Might try to modify this script to do it. Here’s the script within a class.

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class MenuItems : MonoBehaviour {

	[MenuItem("Sprites/Set Pivot(s)")]
	static void SetPivots()
	{
		
		Object[] textures = GetSelectedTextures();
		
		Selection.objects = new Object[0];
		foreach (Texture2D texture in textures)
		{
			string path = AssetDatabase.GetAssetPath(texture);
			TextureImporter ti = AssetImporter.GetAtPath(path) as TextureImporter;
			ti.isReadable = true;
			List<SpriteMetaData> newData = new List<SpriteMetaData>();
			for (int i = 0; i < ti.spritesheet.Length; i++)
			{
				SpriteMetaData d = ti.spritesheet*;*
  •  		d.alignment = 9;*
    
  •  		d.pivot = ti.spritesheet[0].pivot;*
    
  •  		newData.Add(d);*
    
  •  	}*
    
  •  	ti.spritesheet = newData.ToArray();*
    
  •  	AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);*
    
  •  }*
    
  • }*

  • static Object GetSelectedTextures()*

  • {*

  •  return Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets);*
    
  • }*
    }

EDIT: Actually for independent sprites, you can just select them all, and change their pivot at the same time in the inspector.
[1]: Unity3D: Set a sprites's pivot to custom for all frames in a grid - YouTube
[2]: Reddit - Dive into anything