Exemplo n.º 1
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
                }
            }
        }
Exemplo n.º 2
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);
        }