当前位置: 首页>>代码示例>>C#>>正文


C# ParticleSystem.SetParticles方法代码示例

本文整理汇总了C#中UnityEngine.ParticleSystem.SetParticles方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleSystem.SetParticles方法的具体用法?C# ParticleSystem.SetParticles怎么用?C# ParticleSystem.SetParticles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.ParticleSystem的用法示例。


在下文中一共展示了ParticleSystem.SetParticles方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
开发者ID:Kuvo,项目名称:Primary,代码行数:30,代码来源:Particle.cs

示例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 ) ;
	}
开发者ID:NDark,项目名称:Ntust2013Unity_GitHub,代码行数:13,代码来源:AlterParticleSystem01.cs

示例3: 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);
        }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:15,代码来源:FlameBreath.cs

示例4: 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);
		}
	}
开发者ID:talford2,项目名称:SpaceGenerator,代码行数:17,代码来源:Utility.cs

示例5: CreateParticleObject

    // Update is called once per frame
    public void CreateParticleObject(Vector3 pos)
    {
        Debug.Log("Create fab");
        m_PartSys = GameObject.Instantiate ( Resources.Load<ParticleSystem> ( "Prefabs/BaseParticle" ) , pos , Quaternion.identity ) as ParticleSystem;
        m_Points = new ParticleSystem.Particle [ m_NumberOfParticles ];

        float increment = 10f / ( m_NumberOfParticles - 1 );

        for ( int i = 0 ; i < m_NumberOfParticles ; i++ )
        {
            float x = i * increment;
            m_Points [ i ].position = new Vector3 ( x , 0f , 0f );
            m_Points [ i ].color = new Color ( x , 0f , 0f );
            m_Points [ i ].size = 1f;
            //Debug.Log ( m_Points [ i ].position );
        }

        m_PartSys.SetParticles(m_Points, m_Points.Length);
    }
开发者ID:johnetc,项目名称:Hypersine,代码行数:20,代码来源:ParticleFab.cs

示例6: Update

    void Update()
    {
        if(isInit == false)
        {
            isInit = true;

            particleSystem = GetComponent<ParticleSystem>();
            particlesArray = new ParticleSystem.Particle[particleSystem.maxParticles];

            for (int i = 0; i < particlesArray.Length; i++)
            {
                particlesArray[i].position = 1000.0f * Random.insideUnitSphere;
                particlesArray[i].size = 100.0f;

            }

            particleSystem.SetParticles(particlesArray, particlesArray.Length);

            print (particleSystem);
            print (particlesArray.Length);

        }
    }
开发者ID:AjayTalati,项目名称:BCI_Experiments,代码行数:23,代码来源:ParticleGrid.cs

示例7: Start

    public void Start()
    {
        _dataPlot = LoadJson.Instance.Load(_jsonData.text);
        _particles = new Particle[_dataPlot.Particles.Length];
        _particleSystem = GetComponent<ParticleSystem>();
        _camT = Camera.main.transform;
        _baseRotation = Quaternion.identity;
        _rotations = new[] {Quaternion.identity, Quaternion.identity};

        _inV = Vector3.zero;

        _sizeSlider.value = ParticleSize;

        //Create Points
        for (int index = 0; index < _dataPlot.Particles.Length; index++)
        {
            var p = _dataPlot.Particles[index];
            
            var normal = new Vector4(p.Position.x, p.Position.y, p.Position.z, p.Position.w);
            normal.Normalize();

            _particles[index] = new Particle()
            {
                position = normal.StereographicProjection(),
                color = p.Color,
                size = p.Size
            };
        }

        _particleSystem.SetParticles(_particles, _particles.Length);

        //SelectFile.Instance.FileSelected += CreatePoints;

        _xPos.text = "0";
        _yPos.text = "0";
        _zPos.text = "0";
    }
开发者ID:Alex-Gilbert,项目名称:IVS3,代码行数:37,代码来源:ParticlePlot.cs

示例8: setParticles

 public static ParticleSystem setParticles(ParticleSystem psys, ParticleSystem.Particle[] particles)
 {
     psys.SetParticles(particles, particles.Length);
     return psys;
 }
开发者ID:teambonuspoints,项目名称:eeroscloud,代码行数:5,代码来源:ParticleFunctions.cs

示例9: 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);
    }
开发者ID:RyanofRIT,项目名称:MadMax-SketchyRoad,代码行数:48,代码来源:Explosion.cs

示例10: ToParticleSystem

 public void ToParticleSystem(ParticleSystem ps)
 {
     ps.SetParticles(this.particles.ToArray(), this.particles.Count);
 }
开发者ID:GirishBala,项目名称:unity-kickstarter-vis,代码行数:4,代码来源:City.cs

示例11: Start

    // Use this for initialization
    void Start()
    {
        flockParticleEmitter = this.gameObject.GetComponentInChildren<ParticleSystem>();

        //--------------- Gather all colliders --------------------
        colliders = GetColliders();
        //--------------- Gather all colliders --------------------

        //--------------- Gather all Destination points --------------------
        destinationPoints = GetDestinationPoints();
        destinationPoints.Shuffle();
        //--------------- Gather all Destination points --------------------

        //--------------- Spawn Flocks --------------------
        flockers = new FlockData[FlockingSpawnCount];
        int i = FlockingSpawnCount;

        Vector3 center = this.transform.position;
        while (--i > -1)
            SpawnRandomFlockSpherical(center, flockers, i);
        //--------------- Spawn Flocks --------------------

        //--------------- For each Flock, spawn a Particle--------------------
        if (flockParticleEmitter != null)
        {
            ParticleSystem.Particle[] particles = new ParticleSystem.Particle[FlockingSpawnCount];
            i = FlockingSpawnCount;
            while (--i > -1)
                SpawnNewParticle(particles, i);

            flockParticleEmitter.SetParticles(particles, particles.Length);
            flockParticleEmitter.Play();
        }
        //--------------- For each Flock, spawn a Particle --------------------

        InitThreadPool();
    }
开发者ID:remixod,项目名称:NetLibClient,代码行数:38,代码来源:MassiveFlockingExample.cs

示例12: CreatePoints

    private void CreatePoints(string ks)
    {
        if (click1) m_System.SetParticles(points, points.Length);
        click1 = true;
        int counter = 0;
        string line;
        using (StreamReader reader = new StreamReader(ks))
        {
            while ((line = reader.ReadLine()) != null)
            {
                float k;
                float.TryParse(line, out k);
                mas.Add(k);
                line = null;
                counter++;

            }
            Debug.Log(counter);
        }

        if (resolution < 1 || resolution > 100)
        {
            Debug.LogWarning("Grapher resolution out of bounds, resetting to minimum.", this);
            resolution = 1;
        }
        currentResolution = resolution;
        int count = 0; while ((mas[count] != -1000))
        {

            for (int i = 0; i < resolution; i++)
            {
                try
                {

                    int il = count * resolution / 2 + i;
                    float x = 2 * 256 * count / counter;
                    float a = mas[count] + (mas[count + 2] - mas[count]) * i / resolution;
                    float b = mas[count + 1] + (mas[count + 3] - mas[count + 1]) * i / resolution;
                    points[il].position = new Vector3(a, b, 0);
                    points[il].color = new Color(a / 10, b / 10, 0f);
                    points[il].size = 0.1f;

                }

                catch (System.IndexOutOfRangeException)
                { Debug.Log("Ошибка IndexOutOfRangeException"); }

            }
            count += 2;
        }

        m_System = GetComponent<ParticleSystem>();
        if (currentResolution != resolution)
        {
            CreatePoints(ks);
        }
        m_System.SetParticles(points, points.Length);
        for (int i = 0; i < (int)points.Length; i++) points[i].position = new Vector3(0f, 0f, 0f);
        mas.Clear();
    }
开发者ID:DeadBowie,项目名称:Unity,代码行数:60,代码来源:Grapher2.cs


注:本文中的UnityEngine.ParticleSystem.SetParticles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。