Пример #1
0
        private void updateMesh()
        {
            Bounds newMeshBounds;

            if (portalRect.Contains(_prevHeadPosition))
            {
                if (_isInsidePortal)
                {
                    float distance = Mathf.Max(0, -_prevHeadPosition.z + PortalManager.Instance.headSize);
                    newMeshBounds = new Bounds(new Vector3(0, 0, distance / -2), new Vector3(_width, _height, distance));
                }
                else
                {
                    float distance = Mathf.Max(0, _prevHeadPosition.z + PortalManager.Instance.headSize);
                    newMeshBounds = new Bounds(new Vector3(0, 0, distance / 2), new Vector3(_width, _height, distance));
                }
            }
            else
            {
                newMeshBounds = new Bounds(Vector3.zero, new Vector3(_width, _height, 0));
            }


            if (newMeshBounds != _meshBounds)
            {
                using (new ProfilerSample("Update Portal Mesh", this)) {
                    _meshBounds = newMeshBounds;
                    CubeBuilder.CreateCubeMesh(_mesh, _meshBounds,
                                               bottom: Face.All,
                                               left: Face.All,
                                               right: Face.All,
                                               top: Face.All,
                                               back: _isInsidePortal ? Face.None : Face.All,
                                               front: _isInsidePortal ? Face.All : Face.None);
                }
            }
        }