Example #1
0
 /// <summary>
 /// Create VGO_PS_LightsModule from LightsModule.
 /// </summary>
 /// <param name="module"></param>
 /// <returns></returns>
 protected virtual VGO_PS_LightsModule CreateVgoModule(LightsModule module)
 {
     return(new VGO_PS_LightsModule()
     {
         enabled = module.enabled,
         ratio = module.ratio,
         useRandomDistribution = module.useRandomDistribution,
         light = VgoLightConverter.CreateFrom(module.light),
         useParticleColor = module.useParticleColor,
         sizeAffectsRange = module.sizeAffectsRange,
         alphaAffectsIntensity = module.alphaAffectsIntensity,
         range = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.range),
         rangeMultiplier = module.rangeMultiplier,
         intensity = VgoParticleSystemMinMaxCurveConverter.CreateFrom(module.intensity),
         intensityMultiplier = module.intensityMultiplier,
         maxLights = module.maxLights,
     });
 }
Example #2
0
        /// <summary>
        /// Set ParticleSystem lightsModule field value.
        /// </summary>
        /// <param name="particleSystem"></param>
        /// <param name="vgoModule"></param>
        protected virtual void SetModuleValue(ParticleSystem particleSystem, VGO_PS_LightsModule vgoModule)
        {
            if (vgoModule == null)
            {
                return;
            }

            LightsModule module = particleSystem.lights;

            module.enabled = vgoModule.enabled;
            module.ratio   = vgoModule.ratio;
            module.useRandomDistribution = vgoModule.useRandomDistribution;
            module.useParticleColor      = vgoModule.useParticleColor;
            module.sizeAffectsRange      = vgoModule.sizeAffectsRange;
            module.alphaAffectsIntensity = vgoModule.alphaAffectsIntensity;
            module.range               = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.range);
            module.rangeMultiplier     = vgoModule.rangeMultiplier;
            module.intensity           = VgoParticleSystemMinMaxCurveConverter.CreateMinMaxCurve(vgoModule.intensity);
            module.intensityMultiplier = vgoModule.intensityMultiplier;
            module.maxLights           = vgoModule.maxLights;

            if (vgoModule.light != null)
            {
                // @notice
                Light goLight = particleSystem.gameObject.GetComponent <Light>();

                if (goLight == null)
                {
                    goLight = particleSystem.gameObject.AddComponent <Light>();
                }

                VgoLightConverter.SetComponentValue(goLight, vgoModule.light);

                goLight.enabled = false;

                module.light = goLight;

                if (Application.isEditor)
                {
                    // @todo
                }
            }
        }
Example #3
0
        /// <summary>
        /// Adds a Light component to the game object.
        /// </summary>
        /// <typeparam name="T">The type of the component to add.</typeparam>
        /// <param name="go"></param>
        /// <param name="vgoLight"></param>
        /// <returns>Returns Light component.</returns>
        /// <remarks>Light is sealed class.</remarks>
        public static Light AddComponent <T>(this GameObject go, VGO_Light vgoLight)
        //where T : Light
        {
            if (typeof(T) != typeof(Light))
            {
                return(null);
            }

            Light light = go.GetComponent <Light>();

            if (light == null)
            {
                light = go.AddComponent <Light>();
            }

            if (vgoLight != null)
            {
                VgoLightConverter.SetComponentValue(light, vgoLight);
            }

            return(light);
        }