Point list rendering in Unity3d

Hi all,

I'm trying to see if I can make Unity my next project engine and I'm trying to port some code I created on Xna to create a randomly generated Starfield using Points uniformally distributed on a sphere rendered using PointList primitive type.

However, I didn't find any way for me to do such thing. Would anyone see how I could achieve that?

Here is the original generation code:

        Random rand = new Random(seed);
        VertexPositionColor[] verts = new VertexPositionColor[MAX_NUMBER_OF_STARS];

        if (numberOfStars > MAX_NUMBER_OF_STARS)
            numberOfStars = MAX_NUMBER_OF_STARS;

        for (int i = 0; i < numberOfStars; i++)
        {
            double x, y, z, w, t;

            z = 2.0 * rand.NextDouble() - 1.0;
            t = 2.0 * MathHelper.Pi * rand.NextDouble();
            w = Math.Sqrt(1 - z * z);
            x = w * Math.Cos(t);
            y = w * Math.Sin(t);

            float color = (float)rand.NextDouble();

            verts _= new VertexPositionColor(new Vector3((float)x * 1000, (float)y * 1000, (float)z * 1000), new Color(color, color, color, color));_
 *}*
 *__SmallStarVertices = new Vertices<VertexPositionColor>(verts);*
*```*
*<p>And the Rendering code:</p>*
*```*
*__SmallStarVertices.Draw(state, null, PrimitiveType.PointList);*
*```*
*<p>Note that __SmallStarVertices is just a class that abstracts some inner render states helper calls from my previous graphics lib.</p>*

Well, in terms of porting your "random points on a sphere" code, there's a function in unity to do just that:

Random.onUnitSphere

For the actual rendering of the stars, I'm not aware of a way of rendering vertices as point on the screen, but perhaps you might consider using a particle system.

You could start by using this basic setup for creating a nebula, and then assign a small point-like texture for your star particles. Make sure the particle animator is deleted, so that the particles don't move. Then instead of allowing the particle emitter itself to emit the particles, you could use the particle system API to set a list of particles in the positions selected by your "Random.onUnitSphere" loop.

Drawing single-pixel points can be accomplished by drawing quads and doing calculations to make them one screen pixel in size. There is a script here which does that (requires Unity Pro since it uses the GL class).