/// <summary> /// Adds a ParticleSystem component to the game object. /// </summary> /// <param name="go"></param> /// <param name="vgoParticleSystem"></param> /// <param name="materialList"></param> /// <param name="textureItemList"></param> /// <returns>Returns ParticleSystem component.</returns> public virtual ParticleSystem AddComponent(GameObject go, VGO_ParticleSystem vgoParticleSystem, IList <Material> materialList, IList <TextureItem> textureItemList) { ParticleSystem particleSystem = go.GetComponent <ParticleSystem>(); if (particleSystem == null) { particleSystem = go.AddComponent <ParticleSystem>(); } if (vgoParticleSystem != null) { SetModuleValue(particleSystem, vgoParticleSystem.main); SetModuleValue(particleSystem, vgoParticleSystem.emission); SetModuleValue(particleSystem, vgoParticleSystem.shape, textureItemList); SetModuleValue(particleSystem, vgoParticleSystem.velocityOverLifetime); SetModuleValue(particleSystem, vgoParticleSystem.limitVelocityOverLifetime); SetModuleValue(particleSystem, vgoParticleSystem.inheritVelocity); SetModuleValue(particleSystem, vgoParticleSystem.forceOverLifetime); SetModuleValue(particleSystem, vgoParticleSystem.colorOverLifetime); SetModuleValue(particleSystem, vgoParticleSystem.colorBySpeed); SetModuleValue(particleSystem, vgoParticleSystem.sizeOverLifetime); SetModuleValue(particleSystem, vgoParticleSystem.sizeBySpeed); SetModuleValue(particleSystem, vgoParticleSystem.rotationOverLifetime); SetModuleValue(particleSystem, vgoParticleSystem.rotationBySpeed); SetModuleValue(particleSystem, vgoParticleSystem.externalForces); SetModuleValue(particleSystem, vgoParticleSystem.noise); //SetModuleValue(particleSystem, vgoParticleSystem.Collision); //SetModuleValue(particleSystem, vgoParticleSystem.Trigger); //SetModuleValue(particleSystem, vgoParticleSystem.SubEmitters); //SetModuleValue(particleSystem, vgoParticleSystem.TextureSheetAnimation); SetModuleValue(particleSystem, vgoParticleSystem.lights); SetModuleValue(particleSystem, vgoParticleSystem.trails); //SetModuleValue(particleSystem, vgoParticleSystem.CustomData); } ParticleSystemRenderer particleSystemRenderer = go.GetComponent <ParticleSystemRenderer>(); if (particleSystemRenderer == null) { particleSystemRenderer = go.AddComponent <ParticleSystemRenderer>(); } if (particleSystemRenderer != null) { SetComponentValue(particleSystemRenderer, vgoParticleSystem.renderer, materialList); } return(particleSystem); }
/// <summary> /// Create VGO_ParticleSystem. /// </summary> /// <param name="particleSystem"></param> /// <param name="particleSystemRenderer"></param> /// <param name="gltf"></param> /// <returns></returns> public virtual VGO_ParticleSystem Create(ParticleSystem particleSystem, ParticleSystemRenderer particleSystemRenderer, glTF gltf) { if (particleSystem == null) { return(null); } var vgoParticleSystem = new VGO_ParticleSystem() { main = CreateVgoModule(particleSystem.main), emission = CreateVgoModule(particleSystem.emission), shape = CreateVgoModule(particleSystem.shape, gltf), velocityOverLifetime = CreateVgoModule(particleSystem.velocityOverLifetime), limitVelocityOverLifetime = CreateVgoModule(particleSystem.limitVelocityOverLifetime), inheritVelocity = CreateVgoModule(particleSystem.inheritVelocity), forceOverLifetime = CreateVgoModule(particleSystem.forceOverLifetime), colorOverLifetime = CreateVgoModule(particleSystem.colorOverLifetime), colorBySpeed = CreateVgoModule(particleSystem.colorBySpeed), sizeOverLifetime = CreateVgoModule(particleSystem.sizeOverLifetime), sizeBySpeed = CreateVgoModule(particleSystem.sizeBySpeed), rotationOverLifetime = CreateVgoModule(particleSystem.rotationOverLifetime), rotationBySpeed = CreateVgoModule(particleSystem.rotationBySpeed), externalForces = CreateVgoModule(particleSystem.externalForces), noise = CreateVgoModule(particleSystem.noise), //Collision = CreateVgoModule(particleSystem.collision), //Trigger = CreateVgoModule(particleSystem.trigger), //SubEmitters = CreateVgoModule(particleSystem.subEmitters), //TextureSheetAnimation = CreateVgoModule(particleSystem.textureSheetAnimation), lights = CreateVgoModule(particleSystem.lights), trails = CreateVgoModule(particleSystem.trails), //CustomData = CreateVgoModule(particleSystem.customData), renderer = CreateVgoPsRenderer(particleSystemRenderer, gltf), }; return(vgoParticleSystem); }