ParticleSystemとスクリプトで星空的なものを作る

More than 1 year has passed since last update.

5000個パーティクル作り、パーティクルは静止させている。

image

using UnityEngine;

using System.Collections;

public class ParticleTest : MonoBehaviour
{

// Use this for initialization
void Start ()
{
ParticleSystem particleSystem = GetComponent<ParticleSystem> ();

int num = 5000;

particleSystem.Emit (num);
ParticleSystem.Particle[] particle = new ParticleSystem.Particle[num];
particleSystem.GetParticles(particle);
particleSystem.Pause();
for (var i = 0; i < num; i++)
{
particle [i].position = new Vector3 (
(Random.value-0.5f)*100f,
(Random.value-0.5f)*100f,
(Random.value-0.5f)*100f
);
}

particleSystem.SetParticles(particle,num);
}

}