BoundsExtension.cs 488 B

12345678910111213141516171819
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public static class BoundsExtension
  5. {
  6. public static List<Vector3> GetCorners(this Bounds obj, bool includePosition = true)
  7. {
  8. List<Vector3> list = new List<Vector3>();
  9. for (int i = -1; i <= 1; i += 2)
  10. {
  11. for (int j = -1; j <= 1; j += 2)
  12. {
  13. list.Add(((!includePosition) ? Vector3.zero : obj.center) + (obj.size / 2f).Times(new Vector3((float)i, (float)j)));
  14. }
  15. }
  16. return list;
  17. }
  18. }