/// <summary> /// Create VGO_PS_MainModule from MainModule. /// </summary> /// <param name="module"></param> /// <returns></returns> protected virtual VGO_PS_MainModule CreateVgoModule(MainModule module) { var vgoModule = new VGO_PS_MainModule() { duration = module.duration, loop = module.loop, prewarm = module.prewarm, startDelay = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startDelay), startDelayMultiplier = module.startDelayMultiplier, startLifetime = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startLifetime), startLifetimeMultiplier = module.startLifetimeMultiplier, startSpeed = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSpeed), startSpeedMultiplier = module.startSpeedMultiplier, startSize3D = module.startSize3D, startRotation3D = module.startRotation3D, flipRotation = module.flipRotation, startColor = VgoParticleSystemMinMaxGradientConverter.CreateFrom(module.startColor), gravityModifier = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.gravityModifier), gravityModifierMultiplier = module.gravityModifierMultiplier, simulationSpace = module.simulationSpace, simulationSpeed = module.simulationSpeed, customSimulationSpace = VgoTransformConverter.CreateFrom(module.customSimulationSpace), useUnscaledTime = module.useUnscaledTime, scalingMode = module.scalingMode, playOnAwake = module.playOnAwake, emitterVelocityMode = module.emitterVelocityMode, maxParticles = module.maxParticles, stopAction = module.stopAction, cullingMode = module.cullingMode, ringBufferMode = module.ringBufferMode, }; if (module.startSize3D) { vgoModule.startSizeX = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSizeX); vgoModule.startSizeY = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSizeY); vgoModule.startSizeZ = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSizeZ); vgoModule.startSizeXMultiplier = module.startSizeXMultiplier; vgoModule.startSizeYMultiplier = module.startSizeYMultiplier; vgoModule.startSizeZMultiplier = module.startSizeZMultiplier; } else { vgoModule.startSize = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startSize); vgoModule.startSizeMultiplier = module.startSizeMultiplier; } if (module.startRotation3D) { vgoModule.startRotationX = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotationX); vgoModule.startRotationY = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotationY); vgoModule.startRotationZ = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotationZ); vgoModule.StartRotationXMultiplier = module.startRotationXMultiplier; vgoModule.StartRotationYMultiplier = module.startRotationYMultiplier; vgoModule.StartRotationZMultiplier = module.startRotationZMultiplier; } else { vgoModule.startRotation = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.startRotation); vgoModule.StartRotationMultiplier = module.startRotationMultiplier; } if (module.ringBufferMode == ParticleSystemRingBufferMode.LoopUntilReplaced) { vgoModule.ringBufferLoopRange = module.ringBufferLoopRange.ToArray(); } return(vgoModule); }
/// <summary> /// Set ParticleSystem main field value. /// </summary> /// <param name="particleSystem"></param> /// <param name="vgoModule"></param> protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_MainModule vgoModule) { if (vgoModule == null) { return; } MainModule module = particleSystem.main; // @notice if (Application.isPlaying == false) { module.duration = vgoModule.duration; } module.loop = vgoModule.loop; module.prewarm = vgoModule.prewarm; module.startDelay = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startDelay); module.startDelayMultiplier = vgoModule.startDelayMultiplier; module.startLifetime = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startLifetime); module.startLifetimeMultiplier = vgoModule.startLifetimeMultiplier; module.startSpeed = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSpeed); module.startSpeedMultiplier = vgoModule.startSpeedMultiplier; module.startSize3D = vgoModule.startSize3D; if (vgoModule.startSize3D) { module.startSizeX = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeX); module.startSizeY = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeY); module.startSizeZ = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSizeZ); module.startSizeXMultiplier = vgoModule.startSizeXMultiplier; module.startSizeYMultiplier = vgoModule.startSizeYMultiplier; module.startSizeZMultiplier = vgoModule.startSizeZMultiplier; } else { module.startSize = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startSize); module.startSizeMultiplier = vgoModule.startSizeMultiplier; } module.startRotation3D = vgoModule.startRotation3D; if (vgoModule.startRotation3D) { module.startRotationX = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationX); module.startRotationY = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationY); module.startRotationZ = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotationZ); module.startRotationXMultiplier = vgoModule.StartRotationXMultiplier; module.startRotationYMultiplier = vgoModule.StartRotationYMultiplier; module.startRotationZMultiplier = vgoModule.StartRotationZMultiplier; } else { module.startRotation = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.startRotation); module.startRotationMultiplier = vgoModule.StartRotationMultiplier; } module.flipRotation = vgoModule.flipRotation; module.startColor = VgoParticleSystemMinMaxGradientConverter.CreateMinMaxGradient(vgoModule.startColor); module.gravityModifier = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.gravityModifier); module.gravityModifierMultiplier = vgoModule.gravityModifierMultiplier; module.simulationSpace = vgoModule.simulationSpace; module.simulationSpeed = vgoModule.simulationSpeed; VgoTransformConverter.SetComponentValue(module.customSimulationSpace, vgoModule.customSimulationSpace); module.useUnscaledTime = vgoModule.useUnscaledTime; module.scalingMode = vgoModule.scalingMode; module.playOnAwake = vgoModule.playOnAwake; module.emitterVelocityMode = vgoModule.emitterVelocityMode; module.maxParticles = vgoModule.maxParticles; module.stopAction = vgoModule.stopAction; module.cullingMode = vgoModule.cullingMode; module.ringBufferMode = vgoModule.ringBufferMode; if (vgoModule.ringBufferMode == ParticleSystemRingBufferMode.LoopUntilReplaced) { module.ringBufferLoopRange = ArrayConverter.ToVector2(vgoModule.ringBufferLoopRange); } }