예제 #1
0
        public void Update(Camera cam)
        {
            if (boxCollider == null)
            {
                Refreash();
                if (boxCollider == null)
                {
                    return;
                }
            }

            if (oldCenter != boxCollider.center || oldSize != boxCollider.size)
            {
                oldCenter = boxCollider.center;
                oldSize   = boxCollider.size;
                list      = VectorUtils.CalcCubeVertex(oldCenter, oldSize / 2);
            }

            RenderTexture.active = cam.targetTexture;

            CreateLineMaterial();
            lineMaterial.SetPass(0);

            GL.PushMatrix();
            GL.LoadProjectionMatrix(cam.projectionMatrix);
            GL.LoadIdentity();
            GL.MultMatrix(cam.worldToCameraMatrix * instanceTransform.localToWorldMatrix);

            GL.Begin(GL.LINES);
            GL.Color(Color.green);

            for (int i = 1; i < 24; i++)
            {
                GL.Vertex(list[i - 1]);
                GL.Vertex(list[i]);
            }

            GL.End();
            GL.PopMatrix();
        }