Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using ParticlePlayground;
- public class SwitchWorldObject : MonoBehaviour {
- public PlaygroundParticlesC particles; // Reference to your particle system
- public GameObject[] worldObjects; // Assign your world objects (needs a mesh)
- int current;
- void Update () {
- if (Input.GetMouseButtonDown (0)) {
- StartCoroutine(Switch());
- }
- }
- IEnumerator Switch () {
- if (worldObjects.Length==0) yield break;
- current = (current+1)%worldObjects.Length;
- // Update the current computed world object
- particles.worldObject.gameObject = worldObjects[current];
- // The new world object will be available next frame
- yield return null;
- // Set particle count to match the vertex amount
- particles.particleCount = particles.worldObject.vertexPositions.Length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement