CameraUtility.cs 433 B

1234567891011121314
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6. namespace SplineMesh {
  7. public static class CameraUtility {
  8. public static bool IsOnScreen(Vector3 position) {
  9. Vector3 onScreen = Camera.current.WorldToViewportPoint(position);
  10. return onScreen.z > 0 && onScreen.x > 0 && onScreen.y > 0 && onScreen.x < 1 && onScreen.y < 1;
  11. }
  12. }
  13. }