本文整理汇总了C#中UnityEngine.ParticleSystem.GetParticles方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleSystem.GetParticles方法的具体用法?C# ParticleSystem.GetParticles怎么用?C# ParticleSystem.GetParticles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem.GetParticles方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
particleSystem = gameObject.GetComponent<ParticleSystem>();
const int maxParticle = 1000;
particleSystem.maxParticles = maxParticle;
particles = new ParticleSystem.Particle[maxParticle];
particleData = new ParticleData[maxParticle];
particleSystem.Emit(maxParticle);
particleSystem.GetParticles(particles);
for (int i = 0; i < maxParticle; i++)
{
particles[i].position = Vector3.zero;
particles[i].velocity = Vector3.zero;
particles[i].size = 0.1f;
float rotateX = Random.value * 360;
float rotateY = Random.value * 180;
float rotateZ = Random.value * 360;
Quaternion q = new Quaternion();
q.eulerAngles = new Vector3(rotateX, rotateY, rotateZ);
particleData[i].direction = q * Vector3.forward;
particleData[i].speed = 1;
particleData[i].cos = i / ((float)maxParticle / 10);
}
particleSystem.SetParticles(particles, maxParticle);
}
示例2: AlterParticle
private void AlterParticle( ParticleSystem _ParticleSystem )
{
ParticleSystem.Particle [] parray = new ParticleSystem.Particle[ _ParticleSystem.particleCount ] ;
int num = _ParticleSystem.GetParticles( parray ) ;
Debug.Log( "num" + num );
for( int i = 0 ; i < num ; ++i )
{
parray[i].position = Vector3.zero ;
parray[i].color = Color.red ;
// Debug.Log( "parray[i].position=" + parray[i].position ) ;
}
_ParticleSystem.SetParticles( parray , parray.Length ) ;
}
示例3: Start
void Start()
{
mf = GetComponent<SkinnedMeshRenderer>();
ps = GetComponent<ParticleSystem> ();
origVerts = mf.sharedMesh.vertices;
int i = 0;
while (i < origVerts.Length) {
ps.Emit(origVerts[i], Vector3.zero, size, float.PositiveInfinity, Color.white);
i++;
}
particles = new ParticleSystem.Particle[ps.particleCount];
ps.GetParticles (particles);
}
示例4: Update
public void Update()
{
system = GetComponent<ParticleSystem>();
particles = new ParticleSystem.Particle[system.particleCount];
system.GetParticles(particles);
for (int i = 0; i < particles.Length; i++) {
if (i % 4 == 0) {
((Light)Instantiate(light, particles[i].position, Quaternion.identity))
.gameObject.transform.SetParent(root.transform, false);
}
}
system.SetParticles(particles, system.particleCount);
}
示例5: Start
// Use this for initialization
void Start()
{
startTime = Time.time;
particleSys = GetComponent<ParticleSystem>();
particleSys.Stop();
particleSys.Play();
start = Time.time;
particles = new ParticleSystem.Particle[particleSys.maxParticles];
size = particleSys.GetParticles(particles);
particleVelocity = new Vector3[size];
for (int i = 0; i < size; i++)
{
particleVelocity[i] = particles[i].velocity;
}
}
示例6: Start
void Start()
{
mf = GetComponent<MeshFilter>();
ps = GetComponent<ParticleSystem> ();
scale = this.transform.localScale;
origVerts = mf.sharedMesh.vertices;
newVerts = new Vector3[origVerts.Length];
int i = 0;
while (i < origVerts.Length) {
ps.Emit(origVerts[i], Vector3.zero, 1f, float.PositiveInfinity, Color.white);
i++;
}
particles = new ParticleSystem.Particle[ps.particleCount];
ps.GetParticles (particles);
}
示例7: MoveParticles
public static void MoveParticles(ParticleSystem ps, Vector3 moveAmount)
{
if (ps != null)
{
var parr = new ParticleSystem.Particle[ps.maxParticles];
var totalParticles = ps.GetParticles(parr);
//Debug.LogFormat("{0}: {1} / {2}", ps.name, totalParticles, parr.Length);
//Debug.Break();
for (var i = 0; i < totalParticles; i++)
{
parr[i].position += moveAmount;
}
ps.SetParticles(parr, parr.Length);
}
}
示例8: Start
void Start()
{
//get the particle system from the GameObject containing it
system = systemHolder.GetComponent<ParticleSystem>();
//create the specified count of particles
system.Emit(emitCount);
//create an array to hold the particles
particleArray = new ParticleSystem.Particle[systemHolder.GetComponent<ParticleSystem>().particleCount];
//fill particle array with system's particles so they can be manipulated
system.GetParticles(particleArray);
//the spacing between particles y value
float offset = 2.0f / emitCount;
//how much to increment the phi angle of the particles
float increment = Mathf.PI * (3.0f - Mathf.Sqrt(5.0f));
float x, y, z, r;
//set the initial velocity and position of each of the particles in radial pattern using fibonnacci spiral
//the fibonnacci spiral method prevents bunching of particles near the poles of the sphere (lat and long method)
for (float i = 0; i < system.particleCount; i++)
{
//get the y value of current particle
y = ((i * offset) - 1) + (offset / 2.0f);
//find rotation along spiral based on y value
r = Mathf.Sqrt(1 - Mathf.Pow(y, 2.0f));
//calculate an approximation of phi for current particle
float phi = ((i + 1) % emitCount) * increment;
//use rotation along spiral r, and phi to calculate x and z coords
x = Mathf.Cos(phi) * r;
z = Mathf.Sin(phi) * r;
//set particle position and velocity
//initial postion of all particles is set to the center since they are meant to explode outwards
particleArray[(int)i].position = new Vector3(0, 0, 0);
//allow initial velocity to be tweaked with the speedFactor
particleArray[(int)i].velocity = new Vector3(x / speedFactor, y / speedFactor, z / speedFactor);
}
//set the position and velocity of the particles in the system based on array
system.SetParticles(particleArray, system.particleCount);
}
示例9: RenderCollisionBounds
private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
{
if (system.trigger.enabled && s_VisualizeBounds)
{
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[system.particleCount];
int num = system.GetParticles(particles);
Color color = Gizmos.color;
Gizmos.color = Color.green;
Matrix4x4 identity = Matrix4x4.identity;
if (system.main.simulationSpace == ParticleSystemSimulationSpace.Local)
{
identity = system.GetLocalToWorldMatrix();
}
Matrix4x4 matrix = Gizmos.matrix;
Gizmos.matrix = identity;
for (int i = 0; i < num; i++)
{
ParticleSystem.Particle particle = particles[i];
Vector3 vector = particle.GetCurrentSize3D(system);
Gizmos.DrawWireSphere(particle.position, (Math.Max(vector.x, Math.Max(vector.y, vector.z)) * 0.5f) * system.trigger.radiusScale);
}
Gizmos.color = color;
Gizmos.matrix = matrix;
}
}
示例10: RenderCollisionBounds
private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
{
if (CollisionModuleUI.s_LastInteractedEditor == null || !CollisionModuleUI.s_LastInteractedEditor.m_VisualizeBounds || (Object) CollisionModuleUI.s_LastInteractedEditor.m_ParticleSystemUI.m_ParticleSystem != (Object) system)
return;
ParticleSystem.Particle[] particles1 = new ParticleSystem.Particle[system.particleCount];
int particles2 = system.GetParticles(particles1);
Color color = Gizmos.color;
Gizmos.color = Color.green;
Matrix4x4 matrix4x4 = Matrix4x4.identity;
if (system.simulationSpace == ParticleSystemSimulationSpace.Local)
matrix4x4 = system.transform.localToWorldMatrix;
for (int index = 0; index < particles2; ++index)
{
ParticleSystem.Particle particle = particles1[index];
Gizmos.DrawWireSphere(matrix4x4.MultiplyPoint(particle.position), particle.GetCurrentSize(system) * 0.5f * CollisionModuleUI.s_LastInteractedEditor.m_RadiusScale.floatValue);
}
Gizmos.color = color;
}
示例11: Do_Text_And_Audio
private IEnumerator Do_Text_And_Audio( ParticleSystem particle_system, float amount, float text_size, AudioClip audio_clip, float pitch )
{
// Wait for the initial particle to be fired off
while( particle_system.particleCount == 0 )
{
yield return null;
}
// Track it's position until it detonates
ParticleSystem.Particle[] particle = new ParticleSystem.Particle[1];
while( particle_system.particleCount > 0 )
{
particle_system.GetParticles( particle );
yield return null;
}
// Create text/audio
GameObject text_and_audio_gameobject = GameObject.Instantiate( this.amount_text_prefab ) as GameObject;
// Set up text
TextMesh text_mesh = text_and_audio_gameobject.GetComponentInChildren<TextMesh>();
text_mesh.text = this.AmountToText( amount );
text_mesh.fontSize = Mathf.RoundToInt( text_size );
text_and_audio_gameobject.transform.position = particle_system.transform.TransformPoint( particle[0].position ) + new Vector3( 0f, 25f, 0f );
text_and_audio_gameobject.transform.LookAt( this.camera.transform );
// Set up audio
AudioSource audio_source = text_and_audio_gameobject.GetComponent<AudioSource>();
audio_source.clip = audio_clip;
audio_source.pitch = pitch;
audio_source.Play();
// Animate in using scale
float t = 0f;
while( t < 1f )
{
t += Time.deltaTime;
text_and_audio_gameobject.transform.localScale = Vector3.one * this.EaseOut( 0f, 1f, t );
yield return null;
}
// Animate out
Vector3 from_position = text_and_audio_gameobject.transform.position;
Vector3 to_position = from_position + new Vector3( 0f, 10f, 0f );
Color from_colour = new Color( 1f, 1f, 1f, 1f );
Color to_colour = new Color( 1f, 1f, 1f, 0f );
t = 0f;
while( t < 1f )
{
t += Time.deltaTime / 2f;
text_and_audio_gameobject.transform.position = Vector3.Lerp( from_position, to_position, t );
text_and_audio_gameobject.transform.LookAt( this.camera.transform );
text_mesh.color = Color.Lerp( from_colour, to_colour, t );
yield return null;
}
Object.Destroy( text_and_audio_gameobject );
}