ResetCenterPoint.cs 514 B

12345678910111213141516171819
  1. using Sirenix.OdinInspector;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class ResetCenterPoint : MonoBehaviour
  6. {
  7. [Button("生成中心点")]
  8. private void ResetPoint()
  9. {
  10. GameObject obj = new GameObject();
  11. obj.name = gameObject.name+"---中心点";
  12. obj.transform.position = transform.GetComponent<MeshRenderer>().bounds.center;
  13. obj.transform.SetParent(transform.parent);
  14. transform.SetParent(obj.transform);
  15. }
  16. }