Exemplo n.º 1
0
    private void CreateView(Camera camera)
    {
        if (camera != null)
        {
            var controller = GetComponent <SightJackController>();

            IsDebug = controller.IsDebug;
            Scale   = controller.Scale;

            camera.fieldOfView  = controller.FieldOfView;
            camera.farClipPlane = controller.Range;

            View = camera.GenerateFrustumMesh();

            _meshRenderer = gameObject.AddComponent <MeshRenderer>();
            _meshRenderer.receiveShadows    = false;
            _meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
            _meshRenderer.material          = controller.Frustum;
            CenterMaterial = controller.Center;

            _meshFilter      = gameObject.AddComponent <MeshFilter>();
            _meshFilter.mesh = View;

            _meshCollider            = gameObject.AddComponent <MeshCollider>();
            _meshCollider.sharedMesh = View;
            _meshCollider.convex     = true;
            _meshCollider.isTrigger  = true;

            transform.localScale = new Vector3(1, controller.Height, 1);

            CreateViewCenter();
        }
        else
        {
            Debug.LogError("SIGHT-JACK ERROR: Camera frustum not found.");
        }
    }