12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
-
- namespace NRKernal
- {
- #if UNITY_EDITOR
- using UnityEngine;
-
- internal class NREmulatorManager : MonoBehaviour
- {
-
-
- public static NREmulatorManager Instance { get; set; }
-
- public static int SIMPlaneID = 0;
-
- public static bool Inited = false;
-
- private Camera centerCam = null;
-
- private void Start()
- {
- DontDestroyOnLoad(this);
- Instance = this;
- }
-
-
-
- public bool IsInGameView(Vector3 worldPos)
- {
- if (centerCam == null) centerCam = GameObject.Find("CenterCamera").GetComponent<Camera>();
- Transform camTransform = centerCam.transform;
- Vector2 viewPos = centerCam.WorldToViewportPoint(worldPos);
- Vector3 dir = (worldPos - camTransform.position).normalized;
- float dot = Vector3.Dot(camTransform.forward, dir);
- if (dot > 0 && viewPos.x >= 0 && viewPos.x <= 1 && viewPos.y >= 0 && viewPos.y <= 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- #endif
- }
|