void Start() { MyTransform = this.transform; MyPosition = transform.position; CloudParticle MyCloudParticle; Vector3 MyPos; Vector3 SideAux; int i; //CloudPrefab = GameObject.Find("VolCloud Basic"); //CloudPrefab = Resources.LoadAssetAtPath("Assets/Volumetric Clouds/Prefabs/VolCloud Basic.prefab", typeof(GameObject)); CloudPresetAnt = CloudPreset; CloudRenderAnt = CloudRender; CloudDetailAnt = CloudDetail; TypeCloudsAnt = TypeClouds; EmissionMultAnt = EmissionMult; SizeFactorPartAnt = SizeFactorPart; SoftCloudsAnt = SoftClouds; SpreadDirAnt = SpreadDir; LengthSpreadAnt = LengthSpread; NumberCloudsAnt = NumberClouds; MaximunVelocityAnt = MaximunVelocity; VelocityMultipierAnt = VelocityMultipier; PaintTypeAnt = PaintType; CloudColorAnt = CloudColor; MainColorAnt = MainColor; SecondColorAnt = SecondColor; TintStrengthAnt = TintStrength; offsetAnt = offset; NumberOfShadowsAnt = NumberOfShadows; MaxWithCloudAnt = MaxWithCloud; MaxTallCloudAnt = MaxTallCloud; MaxDepthCloudAnt = MaxDepthCloud; // Define the axis the clouds are moving on. (Only one value X or Y or Z, must be not equal Zero). Vector3 MyVelocity = MaximunVelocity; if (MyVelocity.x > 0) { CloudsGenerateAxis = Axis.X; } else if (MyVelocity.x < 0) { CloudsGenerateAxis = Axis.XNeg; } else if (MyVelocity.y > 0) { CloudsGenerateAxis = Axis.Y; } else if (MyVelocity.y < 0) { CloudsGenerateAxis = Axis.YNeg; } else if (MyVelocity.z > 0) { CloudsGenerateAxis = Axis.Z; } else if (MyVelocity.z < 0) { CloudsGenerateAxis = Axis.ZNeg; } // Create the procedural Texture Object only if it's selected in the clouds option in the editor. if (TypeClouds == Type.PT1) { GameObject PText1 = new GameObject(); PText1.name = "CloudsToyPT1"; PText1.transform.position = Vector3.zero; PText1.transform.rotation = Quaternion.identity; PText1.transform.parent = MyTransform; ProceduralTexture = (ProceduralCloudTexture)PText1.AddComponent("ProceduralCloudTexture"); PT1CopyInitialParameters(); } // Create the materials based in the textures provided by the user. maximun textures . 6 // There are two types of materials Additive Soft for bright Clouds & Blend for more realistic ones. // First type of clouds. Additive - Bright Ones. for (i = 0; i < 6; i++) { CloudsMatAdditive[i] = new Material(Shader.Find("FX/CloudBright")); CloudsMatAdditive[i].mainTexture = CloudsTextAdd[i]; } // Second type of Clouds. Realistic Ones. for (i = 0; i < 6; i++) { CloudsMatBlended[i] = new Material(Shader.Find("FX/CloudRealistic")); CloudsMatBlended[i].SetColor("_TintColor", CloudColor); CloudsMatBlended[i].mainTexture = CloudsTextBlended[i]; } // Tirdth type of Cloud. Procedural Additive texture, Created only if procedural texture had been selected if (ProceduralTexture) { CloudsPTMatAdditive = new Material(Shader.Find("FX/CloudBright")); if (ProceduralTexture.IsInicialized()) { CloudsPTMatAdditive.mainTexture = ProceduralTexture.MyTexture; } // Fourth type of Cloud. Procedural Blended texture CloudsPTMatBlended = new Material(Shader.Find("FX/CloudRealistic")); CloudsPTMatBlended.SetColor("_TintColor", CloudColor); if (ProceduralTexture.IsInicialized()) { CloudsPTMatBlended.mainTexture = ProceduralTexture.MyAlphaTexture; } } // Generate the clouds for first time, never well be destroyed during the scene. // Using a cubic shape to bounds the limits of coords. creation SideAux = Side / 2; for (i = 0; i < MaximunClouds; i++) { MyPos = MyPosition; MyPos.x = Random.Range(MyPos.x - SideAux.x, MyPos.x + SideAux.x); MyPos.y = Random.Range(MyPos.y - SideAux.y, MyPos.y + SideAux.y); MyPos.z = Random.Range(MyPos.z - SideAux.z, MyPos.z + SideAux.z); MyCloudParticle = new CloudParticle(MyPos, Quaternion.identity); MyCloudParticle.SetCloudParent(MyTransform); MyCloudsParticles.Add(MyCloudParticle); // Define some main particle properties if (TypeClouds == Type.Nimbus1 || TypeClouds == Type.Nimbus2 || TypeClouds == Type.Nimbus3 || TypeClouds == Type.Nimbus4 || TypeClouds == Type.MixNimbus || TypeClouds == Type.MixAll || TypeClouds == Type.PT1) { MyCloudParticle.DefineCloudProperties(i, MaxWithCloud, MaxTallCloud, MaxDepthCloud, 0, FixedSize, true, true); } else if (TypeClouds == Type.Cirrus1 || TypeClouds == Type.Cirrus2 || TypeClouds == Type.MixCirrus) { MyCloudParticle.DefineCloudProperties(i, MaxWithCloud, MaxTallCloud, MaxDepthCloud, 1, FixedSize, true, true); } AssignCloudMaterial(MyCloudParticle, CloudRender, TypeClouds); MyCloudParticle.SetCloudEmitter(i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SetCloudVelocity(MaximunVelocity, VelocityMultipier); MyCloudParticle.SetLengthScale(LengthSpread); MyCloudParticle.SetWorldVelocity(SpreadDir); MyCloudParticle.SoftCloud(SoftClouds); ManageCloudShadow(MyCloudParticle); // If the cloud will be active, Paint the cloud otherwise deactivate it (they are initially active, but dont emit anything) if (i < NumberClouds) { if (TypeClouds != Type.PT1) { MyCloudParticle.SetActive(true); // Emit the particles, because this cloud is visible MyCloudParticle.UpdateCloudsPosition(); // Updating the positions of particles once the Particle Emmitter emit them. if (CloudRender == TypeRender.Realistic) { MyCloudParticle.SetMainColor(CloudColor); // Set the main color of the cloud } PaintTheParticlesShadows(MyCloudParticle); // Colorize the cloud with the Cloud Color and the Secondary Color } } else { MyCloudParticle.DesactivateRecursively(); } } }
// Only we manage the changes of variables in the inspector of Unity, not be used in gametime when // everything is setup. void Update() { CloudParticle MyCloudParticle; int i; // Create the procedural Texture Object of PT1 texture is selected in runtime. if (TypeClouds == Type.PT1 && !ProceduralTexture) { GameObject PText1 = new GameObject(); PText1.name = "CloudsToyPT1"; PText1.transform.position = Vector3.zero; PText1.transform.rotation = Quaternion.identity; PText1.transform.parent = MyTransform; ProceduralTexture = (ProceduralCloudTexture)PText1.AddComponent("ProceduralCloudTexture"); PT1CopyInitialParameters(); // Create the procedural materials to use in the clouds if PT1 had been selected. CloudsPTMatAdditive = new Material(Shader.Find("FX/CloudBright")); if (ProceduralTexture.IsInicialized()) { CloudsPTMatAdditive.mainTexture = ProceduralTexture.MyTexture; } // Fourth type of Clouds. Procedural Blended textures CloudsPTMatBlended = new Material(Shader.Find("FX/CloudRealistic")); CloudsPTMatBlended.SetColor("_TintColor", CloudColor); if (ProceduralTexture.IsInicialized()) { CloudsPTMatBlended.mainTexture = ProceduralTexture.MyAlphaTexture; } } // Trying to Assign a procedural txeture, once the texture is already created, not earlyer // PT1 needs time to be created and inicialized, that's why this code exits if (ProceduralTexture) { if (ProceduralTexture.IsInicialized() && !bAssignProcTexture) { // Procedural Additive textures CloudsPTMatAdditive.mainTexture = ProceduralTexture.MyTexture; // Procedural Blended textures CloudsPTMatBlended.SetColor("_TintColor", CloudColor); CloudsPTMatBlended.mainTexture = ProceduralTexture.MyAlphaTexture; if (TypeClouds == Type.PT1) { for (i = 0; i < MaximunClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; if (i < NumberClouds) { MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); if (CloudRender == TypeRender.Realistic) { MyCloudParticle.SetMainColor(CloudColor); } PaintTheParticlesShadows(MyCloudParticle); } } } bAssignProcTexture = true; } } // Change the number of visible clouds. Must activate the new particles and Update de position of the particles in the ellipse if (NumberCloudsAnt != NumberClouds) { for (i = 0; i < MaximunClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; if (i < NumberClouds && !MyCloudParticle.IsActive()) { MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); if (SoftClouds) { SoftCloudsAnt = !SoftClouds; } } else if (i >= NumberClouds && MyCloudParticle.IsActive()) { MyCloudParticle.DesactivateRecursively(); } } NumberCloudsAnt = NumberClouds; } // Actualize the particle emmitter if the density of particles emmited has changed by user if (CloudDetailAnt != CloudDetail) { if (CloudDetail == TypeDetail.Low) { EmissionMult = 1; SizeFactorPart = 1; } else if (CloudDetail == TypeDetail.Normal) { EmissionMult = 1.5f; SizeFactorPart = 1.2f; } else if (CloudDetail == TypeDetail.High) { EmissionMult = 2.0f; SizeFactorPart = 1.3f; } for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetCloudEmitter(i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); if (CloudRender == TypeRender.Realistic) { MyCloudParticle.SetMainColor(CloudColor); } PaintTheParticlesShadows(MyCloudParticle); } CloudDetailAnt = CloudDetail; } // if change the Size or amount of particles emmitted by any Cloud, must update the partice emmitter and emit again. // after that, we ensure the particles are in the assigned ellipsoid of the cloud if (SizeFactorPartAnt != SizeFactorPart || EmissionMultAnt != EmissionMult) { for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetCloudEmitter(i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); } SizeFactorPartAnt = SizeFactorPart; EmissionMultAnt = EmissionMult; } // Are soft clouds? Update the particle emmitter and renderer to take care of the change if (SoftCloudsAnt != SoftClouds) { for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetCloudEmitter(i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SoftCloud(SoftClouds); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); } SoftCloudsAnt = SoftClouds; } // this two vars, only are visibles if softClouds are true, otherwise any change will not be advised if (SpreadDirAnt != SpreadDir || LengthSpreadAnt != LengthSpread) { for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetLengthScale(LengthSpread); if (SpreadDirAnt != SpreadDir) { MyCloudParticle.SetWorldVelocity(SpreadDir); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); } } SpreadDirAnt = SpreadDir; LengthSpreadAnt = LengthSpread; } // Changin the clouds width or tall. Must redefine all the cloud parameters, including his name if (MaxWithCloud != MaxWithCloudAnt || MaxTallCloud != MaxTallCloudAnt || MaxDepthCloud != MaxDepthCloudAnt) { for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; // Define some main particle properties if (TypeClouds == Type.Nimbus1 || TypeClouds == Type.Nimbus2 || TypeClouds == Type.Nimbus3 || TypeClouds == Type.Nimbus4 || TypeClouds == Type.MixNimbus || TypeClouds == Type.MixAll || TypeClouds == Type.PT1) { MyCloudParticle.DefineCloudProperties(i, MaxWithCloud, MaxTallCloud, MaxDepthCloud, 0, FixedSize, true, true); } else if (TypeClouds == Type.Cirrus1 || TypeClouds == Type.Cirrus2 || TypeClouds == Type.MixCirrus) { MyCloudParticle.DefineCloudProperties(i, MaxWithCloud, MaxTallCloud, MaxDepthCloud, 1, FixedSize, true, true); } // Change the emitter params of the cloud to adjust the new size. MyCloudParticle.SetCloudEmitter(i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); // Start emit again, my friend. MyCloudParticle.SetActive(true); // Update the position of the particles emmitted inside the ellipsoid MyCloudParticle.UpdateCloudsPosition(); // Colorize the cloud if (CloudRender == TypeRender.Realistic) { MyCloudParticle.SetMainColor(CloudColor); } PaintTheParticlesShadows(MyCloudParticle); } MaxWithCloudAnt = MaxWithCloud; MaxTallCloudAnt = MaxTallCloud; MaxDepthCloudAnt = MaxDepthCloud; } // If change the type of cloud just meaning i must change his material or render mode // also assign again the new texture if the procedural texture has changed. if (TypeCloudsAnt != TypeClouds || CloudRenderAnt != CloudRender /*|| ProceduralTexture.IsTextureUpdated()*/) { for (i = 0; i < MaximunClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; // Change the Material depending on the type defined by user AssignCloudMaterial(MyCloudParticle, CloudRender, TypeClouds); } TypeCloudsAnt = TypeClouds; CloudRenderAnt = CloudRender; } // Actualize the velocity of the cloud and take care of the direccion of the mov for the LateUpdate proccess. if (MaximunVelocityAnt != MaximunVelocity || VelocityMultipierAnt != VelocityMultipier) { // Define the axis the clouds are moving on. (Only one value X or Y or Z, must be not equal Zero). // Used to determine the way the coulds are goig to dissapear when they move far away from the Box. if (MaximunVelocity.x > 0) { CloudsGenerateAxis = Axis.X; } else if (MaximunVelocity.x < 0) { CloudsGenerateAxis = Axis.XNeg; } else if (MaximunVelocity.y > 0) { CloudsGenerateAxis = Axis.Y; } else if (MaximunVelocity.y < 0) { CloudsGenerateAxis = Axis.YNeg; } else if (MaximunVelocity.z > 0) { CloudsGenerateAxis = Axis.Z; } else if (MaximunVelocity.z < 0) { CloudsGenerateAxis = Axis.ZNeg; } for (i = 0; i < MaximunClouds; i++) { ((CloudParticle)MyCloudsParticles[i]).SetCloudVelocity(MaximunVelocity, VelocityMultipier); } MaximunVelocityAnt = MaximunVelocity; VelocityMultipierAnt = VelocityMultipier; } // All this just change one color or the system to colorize the cloud, just that. if (CloudColorAnt != CloudColor) { for (i = 0; i < NumberClouds; i++) { ((CloudParticle)MyCloudsParticles[i]).SetMainColor(CloudColor); } CloudColorAnt = CloudColor; } if (MainColorAnt != MainColor) { for (i = 0; i < NumberClouds; i++) { PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); } MainColorAnt = MainColor; } if (SecondColorAnt != SecondColor || TintStrengthAnt != TintStrength) { for (i = 0; i < NumberClouds; i++) { PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); } SecondColorAnt = SecondColor; TintStrengthAnt = TintStrength; } if (offsetAnt != offset) { for (i = 0; i < NumberClouds; i++) { PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); } offsetAnt = offset; } if (PaintTypeAnt != PaintType) { for (i = 0; i < NumberClouds; i++) { PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); } PaintTypeAnt = PaintType; } // Determine if cloud shadow must be active or not, depending on user choice if (NumberOfShadowsAnt != NumberOfShadows) { for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; ManageCloudShadow(MyCloudParticle); } NumberOfShadowsAnt = NumberOfShadows; } if (IsAnimate) { for (i = 0; i < NumberClouds; i++) { MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.AnimateCloud(AnimationVelocity); } } }
// Only we manage the changes of variables in the inspector of Unity, not be used in gametime when // everything is setup. void Update() { CloudParticle MyCloudParticle; int i; // Create the procedural Texture Object of PT1 texture is selected in runtime. if(TypeClouds == Type.PT1 && !ProceduralTexture){ GameObject PText1 = new GameObject(); PText1.name = "CloudsToyPT1"; PText1.transform.position = Vector3.zero; PText1.transform.rotation = Quaternion.identity; PText1.transform.parent = MyTransform; ProceduralTexture = (ProceduralCloudTexture)PText1.AddComponent ("ProceduralCloudTexture"); PT1CopyInitialParameters(); // Create the procedural materials to use in the clouds if PT1 had been selected. CloudsPTMatAdditive = new Material(Shader.Find("FX/CloudBright")); if(ProceduralTexture.IsInicialized()) CloudsPTMatAdditive.mainTexture = ProceduralTexture.MyTexture; // Fourth type of Clouds. Procedural Blended textures CloudsPTMatBlended = new Material(Shader.Find("FX/CloudRealistic")); CloudsPTMatBlended.SetColor("_TintColor", CloudColor); if(ProceduralTexture.IsInicialized()) CloudsPTMatBlended.mainTexture = ProceduralTexture.MyAlphaTexture; } // Trying to Assign a procedural txeture, once the texture is already created, not earlyer // PT1 needs time to be created and inicialized, that's why this code exits if(ProceduralTexture){ if(ProceduralTexture.IsInicialized() && !bAssignProcTexture){ // Procedural Additive textures CloudsPTMatAdditive.mainTexture = ProceduralTexture.MyTexture; // Procedural Blended textures CloudsPTMatBlended.SetColor("_TintColor", CloudColor); CloudsPTMatBlended.mainTexture = ProceduralTexture.MyAlphaTexture; if(TypeClouds == Type.PT1){ for(i = 0; i < MaximunClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; if(i < NumberClouds){ MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); if(CloudRender == TypeRender.Realistic) MyCloudParticle.SetMainColor(CloudColor); PaintTheParticlesShadows(MyCloudParticle); } } } bAssignProcTexture = true; } } // Change the number of visible clouds. Must activate the new particles and Update de position of the particles in the ellipse if(NumberCloudsAnt != NumberClouds){ for(i = 0; i < MaximunClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; if(i < NumberClouds && !MyCloudParticle.IsActive()){ MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); if(SoftClouds) SoftCloudsAnt = !SoftClouds; } else if(i >= NumberClouds && MyCloudParticle.IsActive()) MyCloudParticle.DesactivateRecursively(); } NumberCloudsAnt = NumberClouds; } // Actualize the particle emmitter if the density of particles emmited has changed by user if(CloudDetailAnt != CloudDetail){ if(CloudDetail == TypeDetail.Low){ EmissionMult = 1; SizeFactorPart = 1; } else if(CloudDetail == TypeDetail.Normal){ EmissionMult = 1.5f; SizeFactorPart = 1.2f; } else if(CloudDetail == TypeDetail.High){ EmissionMult = 2.0f; SizeFactorPart = 1.3f; } for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetCloudEmitter (i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); if(CloudRender == TypeRender.Realistic) MyCloudParticle.SetMainColor(CloudColor); PaintTheParticlesShadows(MyCloudParticle); } CloudDetailAnt = CloudDetail; } // if change the Size or amount of particles emmitted by any Cloud, must update the partice emmitter and emit again. // after that, we ensure the particles are in the assigned ellipsoid of the cloud if(SizeFactorPartAnt != SizeFactorPart || EmissionMultAnt != EmissionMult){ for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetCloudEmitter (i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); } SizeFactorPartAnt = SizeFactorPart; EmissionMultAnt = EmissionMult; } // Are soft clouds? Update the particle emmitter and renderer to take care of the change if(SoftCloudsAnt != SoftClouds){ for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetCloudEmitter (i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); MyCloudParticle.SoftCloud (SoftClouds); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); } SoftCloudsAnt = SoftClouds; } // this two vars, only are visibles if softClouds are true, otherwise any change will not be advised if(SpreadDirAnt != SpreadDir || LengthSpreadAnt != LengthSpread){ for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.SetLengthScale(LengthSpread); if(SpreadDirAnt != SpreadDir){ MyCloudParticle.SetWorldVelocity(SpreadDir); MyCloudParticle.SetActive(true); MyCloudParticle.UpdateCloudsPosition(); } } SpreadDirAnt = SpreadDir; LengthSpreadAnt = LengthSpread; } // Changin the clouds width or tall. Must redefine all the cloud parameters, including his name if(MaxWithCloud != MaxWithCloudAnt || MaxTallCloud != MaxTallCloudAnt || MaxDepthCloud != MaxDepthCloudAnt){ for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; // Define some main particle properties if( TypeClouds == Type.Nimbus1 || TypeClouds == Type.Nimbus2 || TypeClouds == Type.Nimbus3 || TypeClouds == Type.Nimbus4 || TypeClouds == Type.MixNimbus || TypeClouds == Type.MixAll || TypeClouds == Type.PT1) MyCloudParticle.DefineCloudProperties (i, MaxWithCloud, MaxTallCloud, MaxDepthCloud, 0, FixedSize, true , true); else if(TypeClouds == Type.Cirrus1 || TypeClouds == Type.Cirrus2 || TypeClouds == Type.MixCirrus) MyCloudParticle.DefineCloudProperties (i, MaxWithCloud, MaxTallCloud, MaxDepthCloud, 1, FixedSize, true , true); // Change the emitter params of the cloud to adjust the new size. MyCloudParticle.SetCloudEmitter (i, SpreadDir, SoftClouds, SizeFactorPart, EmissionMult, MaximunVelocity, VelocityMultipier); // Start emit again, my friend. MyCloudParticle.SetActive(true); // Update the position of the particles emmitted inside the ellipsoid MyCloudParticle.UpdateCloudsPosition(); // Colorize the cloud if(CloudRender == TypeRender.Realistic) MyCloudParticle.SetMainColor(CloudColor); PaintTheParticlesShadows(MyCloudParticle); } MaxWithCloudAnt = MaxWithCloud; MaxTallCloudAnt = MaxTallCloud; MaxDepthCloudAnt = MaxDepthCloud; } // If change the type of cloud just meaning i must change his material or render mode // also assign again the new texture if the procedural texture has changed. if(TypeCloudsAnt != TypeClouds || CloudRenderAnt != CloudRender /*|| ProceduralTexture.IsTextureUpdated()*/){ for(i = 0; i < MaximunClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; // Change the Material depending on the type defined by user AssignCloudMaterial(MyCloudParticle, CloudRender, TypeClouds); } TypeCloudsAnt = TypeClouds; CloudRenderAnt = CloudRender; } // Actualize the velocity of the cloud and take care of the direccion of the mov for the LateUpdate proccess. if(MaximunVelocityAnt != MaximunVelocity || VelocityMultipierAnt != VelocityMultipier){ // Define the axis the clouds are moving on. (Only one value X or Y or Z, must be not equal Zero). // Used to determine the way the coulds are goig to dissapear when they move far away from the Box. if(MaximunVelocity.x > 0) CloudsGenerateAxis = Axis.X; else if(MaximunVelocity.x < 0) CloudsGenerateAxis = Axis.XNeg; else if(MaximunVelocity.y > 0) CloudsGenerateAxis = Axis.Y; else if(MaximunVelocity.y < 0) CloudsGenerateAxis = Axis.YNeg; else if(MaximunVelocity.z > 0) CloudsGenerateAxis = Axis.Z; else if(MaximunVelocity.z < 0) CloudsGenerateAxis = Axis.ZNeg; for(i = 0; i < MaximunClouds; i++) ((CloudParticle)MyCloudsParticles[i]).SetCloudVelocity(MaximunVelocity, VelocityMultipier); MaximunVelocityAnt = MaximunVelocity; VelocityMultipierAnt = VelocityMultipier; } // All this just change one color or the system to colorize the cloud, just that. if(CloudColorAnt != CloudColor){ for(i = 0; i < NumberClouds; i++) ((CloudParticle)MyCloudsParticles[i]).SetMainColor(CloudColor); CloudColorAnt = CloudColor; } if(MainColorAnt != MainColor){ for(i = 0; i < NumberClouds; i++) PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); MainColorAnt = MainColor; } if(SecondColorAnt != SecondColor || TintStrengthAnt !=TintStrength){ for(i = 0; i < NumberClouds; i++) PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); SecondColorAnt = SecondColor; TintStrengthAnt = TintStrength; } if(offsetAnt != offset){ for(i = 0; i < NumberClouds; i++) PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); offsetAnt = offset; } if(PaintTypeAnt != PaintType){ for(i = 0; i < NumberClouds; i++) PaintTheParticlesShadows(((CloudParticle)MyCloudsParticles[i])); PaintTypeAnt = PaintType; } // Determine if cloud shadow must be active or not, depending on user choice if(NumberOfShadowsAnt != NumberOfShadows){ for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; ManageCloudShadow(MyCloudParticle); } NumberOfShadowsAnt = NumberOfShadows; } if(IsAnimate) for(i = 0; i < NumberClouds; i++){ MyCloudParticle = (CloudParticle)MyCloudsParticles[i]; MyCloudParticle.AnimateCloud (AnimationVelocity); } }