How to modify the center point (Pivot) position of the Sprite in Unity

In Unity, sprites are one of the most commonly used graphics resources in games. The sprite's center point (Pivot) determines the center position of its rotation and scaling. By default, a sprite's center point is at the center of its bounding box. However, in some cases we may need to set the sprite's center point to a different location to better suit specific needs. This article will introduce in detail how to modify the center point position of the sprite in Unity.

Step 1: Import Sprite

First, we need to import the sprite into the Unity project. Sprite image files (such as .png or .jpg) can be dragged and dropped into the Unity editor's resource window.

Step 2: Create Sprite object

In Unity, sprites are represented by Sprite objects. We can create a Sprite object with the following code:

using UnityEngine;

public class SpritePivotExample : MonoBehaviour
{
   
    
    
    public 

Guess you like

Origin blog.csdn.net/DiAngular/article/details/133124558