protected override void Awake()
        {
            base.Awake();

            coneAngle = SMath.ClampDegree0To360(coneAngle);
            faceAngle = SMath.ClampDegree0To360(faceAngle);

            var meshFilter = GetComponent <MeshFilter>();

            if (meshFilter == null)
            {
                meshFilter = gameObject.AddComponent <MeshFilter>();
            }

            if (_mesh == null)
            {
                _mesh           = new Mesh();
                meshFilter.mesh = _mesh;
            }

            _losCamera = LOSManager.instance.losCamera;

            Vector2 screenSize = SHelper.GetScreenSizeInWorld(_losCamera.unityCamera);

            _raycastDistance = Mathf.Sqrt(screenSize.x * screenSize.x + screenSize.y * screenSize.y);
        }
Ejemplo n.º 2
0
        public void UpdateViewingBox()
        {
            Vector2 screenSize = SHelper.GetScreenSizeInWorld(unityCamera);

            halfViewboxSize = screenSize / 2 * LOSManager.instance.viewboxExtension;

            Vector2 upperRight = new Vector2(halfViewboxSize.x, halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
            Vector2 upperLeft  = new Vector2(-halfViewboxSize.x, halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
            Vector2 lowerLeft  = new Vector2(-halfViewboxSize.x, -halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
            Vector2 lowerRight = new Vector2(halfViewboxSize.x, -halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);

            viewbox[0].SetStartEnd(lowerRight, upperRight);             // right
            viewbox[1].SetStartEnd(upperRight, upperLeft);              // up
            viewbox[2].SetStartEnd(upperLeft, lowerLeft);               // left
            viewbox[3].SetStartEnd(lowerLeft, lowerRight);              // down
        }
        protected float GetMinRaycastDistance()
        {
            Vector3 screenSize = SHelper.GetScreenSizeInWorld(_losCamera.unityCamera);

            return(screenSize.magnitude);
        }