示例#1
0
        public void AddLineSegments(Vector3[] segments, Color[] colors)
        {
            // Because editor scripts are enabled first, pool could still be null
            // when first request comes in.
            if (pool == null)
            {
                pool = new pb_ObjectPool <Mesh>(1, 4, MeshConstructor, null);
            }

            Mesh m = pool.Get();

            m.Clear();
            m.name = "pb_LineRenderer::Mesh_" + m.GetInstanceID();
            m.MarkDynamic();

            int vc = segments.Length;
            int cc = colors.Length;

            m.vertices = segments;

            int[]   tris = new int[vc];
            Color[] col  = new Color[vc];

            int n = 0;

            for (int i = 0; i < vc; i++)
            {
                tris[i] = i;
                col[i]  = colors[n % cc];
                if (i % 2 == 1)
                {
                    n++;
                }
            }

            m.subMeshCount = 1;
            m.SetIndices(tris, MeshTopology.Lines, 0);
            m.uv     = new Vector2[m.vertexCount];
            m.colors = col;

            m.hideFlags = pb_Constant.EDITOR_OBJECT_HIDE_FLAGS;

            gizmos.Add(m);
        }
示例#2
0
 public override void OnEnable()
 {
     base.OnEnable();
     pool = new pb_ObjectPool <pb_Renderable>(0, 8, pb_Renderable.CreateInstance, pb_Renderable.DestroyInstance);
 }
示例#3
0
 public override void OnEnable()
 {
     base.OnEnable();
     pool = new pb_ObjectPool <Mesh>(1, 8, MeshConstructor, null);
 }