Exemple #1
0
        public void AddPoint(Rect rect, Color color)
        {
            ControlPointRenderer.RenderChunk renderChunk = this.GetRenderChunk();
            int count = renderChunk.vertices.Count;

            renderChunk.vertices.Add(new Vector3(rect.xMin, rect.yMin, 0f));
            renderChunk.vertices.Add(new Vector3(rect.xMax, rect.yMin, 0f));
            renderChunk.vertices.Add(new Vector3(rect.xMax, rect.yMax, 0f));
            renderChunk.vertices.Add(new Vector3(rect.xMin, rect.yMax, 0f));
            renderChunk.colors.Add(color);
            renderChunk.colors.Add(color);
            renderChunk.colors.Add(color);
            renderChunk.colors.Add(color);
            renderChunk.uvs.Add(new Vector2(0f, 0f));
            renderChunk.uvs.Add(new Vector2(1f, 0f));
            renderChunk.uvs.Add(new Vector2(1f, 1f));
            renderChunk.uvs.Add(new Vector2(0f, 1f));
            renderChunk.indices.Add(count);
            renderChunk.indices.Add(count + 1);
            renderChunk.indices.Add(count + 2);
            renderChunk.indices.Add(count);
            renderChunk.indices.Add(count + 2);
            renderChunk.indices.Add(count + 3);
            renderChunk.isDirty = true;
        }
Exemple #2
0
 public void Clear()
 {
     for (int i = 0; i < this.m_RenderChunks.Count; i++)
     {
         ControlPointRenderer.RenderChunk renderChunk = this.m_RenderChunks[i];
         renderChunk.mesh.Clear();
         renderChunk.vertices.Clear();
         renderChunk.colors.Clear();
         renderChunk.uvs.Clear();
         renderChunk.indices.Clear();
         renderChunk.isDirty = true;
     }
 }
Exemple #3
0
 private ControlPointRenderer.RenderChunk CreateRenderChunk()
 {
     ControlPointRenderer.RenderChunk renderChunk = new ControlPointRenderer.RenderChunk();
     renderChunk.mesh            = new Mesh();
     renderChunk.mesh.name       = "ControlPointRendererMesh";
     renderChunk.mesh.hideFlags |= HideFlags.DontSave;
     renderChunk.vertices        = new List <Vector3>();
     renderChunk.colors          = new List <Color32>();
     renderChunk.uvs             = new List <Vector2>();
     renderChunk.indices         = new List <int>();
     this.m_RenderChunks.Add(renderChunk);
     return(renderChunk);
 }
Exemple #4
0
        public void Render()
        {
            Material material = ControlPointRenderer.material;

            material.SetTexture("_MainTex", this.m_Icon);
            material.SetPass(0);
            for (int i = 0; i < this.m_RenderChunks.Count; i++)
            {
                ControlPointRenderer.RenderChunk renderChunk = this.m_RenderChunks[i];
                if (renderChunk.isDirty)
                {
                    renderChunk.mesh.vertices = renderChunk.vertices.ToArray();
                    renderChunk.mesh.colors32 = renderChunk.colors.ToArray();
                    renderChunk.mesh.uv       = renderChunk.uvs.ToArray();
                    renderChunk.mesh.SetIndices(renderChunk.indices.ToArray(), MeshTopology.Triangles, 0);
                    renderChunk.isDirty = false;
                }
                Graphics.DrawMeshNow(renderChunk.mesh, Handles.matrix);
            }
        }