using UnityEngine;
using UnityEditor;
public class ChangePivot : EditorWindow
{
private Vector2 newPivot = new Vector2(0.5f, 0f); // 底部中间位置
[MenuItem("Tools/Change Pivot")]
public static void ShowWindow()
{
GetWindow<ChangePivot>("Change Pivot");
}
private void OnGUI()
{
GUILayout.Label("Change Pivot Tool", EditorStyles.boldLabel);
newPivot = EditorGUILayout.Vector2Field("New Pivot", newPivot);
if (GUILayout.Button("Apply Pivot to Selected"))
{
ApplyPivotChange();
}
}
private void ApplyPivotChange()
{
// 获取所有选中的 GameObject
GameObject[] selectedObjects = Selection.gameObjects;
if (selectedObjects.Length == 0)
{
Debug.LogError("No GameObjects selected!");
return;
}
foreach (GameObject selectedObject in selec
Unity 改变2D的Povit位置
于 2024-09-02 14:55:59 首次发布