Hello, everyone. Welcome to my blog. My blog address is blog.csdn.net/qinyuanpei.
Well, continue with the terrain we achieved in the previous article. In this article, we will add weather effects for this terrain. We use the UniSky plug-in. You can find this plug-in Assets Store. First, we introduce the resource package. do not include a Chinese path. Otherwise, an error will be reported. In this case, an UniSky folder is added to the project ,:
Next, find the UniSkyAPI under UniSky/Resources/. This is a preset file. We drag it into our scenario and associate it with the main camera ,:
Next, create an empty GameObject object to bind the script. Let's take a look at the following script, which can be found in the UniSky \ Example Project \ Assets path:
Using UnityEngine; using System. collections; public class UniSkyScript: MonoBehaviour {// defines the UniSkyAPI instance private UniSkyAPI uniSky; void Awake () {// gets the instance uniSky = GameObject. find ("UniSkyAPI "). getComponent ("UniSkyAPI") as UniSkyAPI; // initialize UniSkyuniSky. instantiateUniSky (); // sets the initialization value uniSky. setTime (12.0f); // set the time of the day (0-24 hours cycle) uniSky. setAmbientLighting (new Color (0.1f, 0.1f, 0.1f, 0.1f); // set the Color of the surrounding environment to uniSky. setStormCenter (new Vector3 (0, 0, 0); // you can specify the storm center uniSky. setSunShadows (LightShadows. soft); // set the Sun Shadow // common method uniSky. lerpCloudCover (0.5f, 5000.0f); // sets the level of the cloud layer (from-5 to 5) uniSky. lerpPrecipitationLevel (0.6f, 5000.0f); // set the level of sediment in the cloud layer (from 0 to 2) uniSky. lerpStormCloudCover (-1.0f, 00000000f); // sets the storm coverage level (-3.5 to-1.0) uniSky. lerpRainLevel (500, 0.2f, 00000000f); // sets the level of rain uniSky. lerpStormLevel (300, 0.4f, 20000.0f); // set the storm level uniSky. lerpSunIntensity (0.2f, 00000000f); // set the sun height to uniSky. lerpFogLevel (0.02f, 20000.0f); // sets the cloud level uniSky. lerpAmbientLighting (new Color (0.0f, 0.0f, 0.0f, 0.0f), 5000); // sets the ambient light Color uniSky. clearDropletBuffer (); // clears the yunisky cache. lerpDropletLevel (10,200 000000f); // sets the drop level} void Update (){}}The methods in the script are defined in the UniSkyAPI file. You can check the method on your own. Now we bind the script to the empty game body just created and run the game. The effect is as follows (ps: special Effect animation files ):
Finally, the UniSkyAPI method comment is given:
// One day (0 to 24 hours cycle) SetTime (float time); LerpTime (float time, float milliseconds); GetTime (); // return the sun color GetSunColor (); // enable or disable the Sun and Moon Shadows. Type: "LightShadows. none "," LightShadows. hard "and" LightShadows. soft "public void SetSunShadows (LightShadows sunShadows) public void SetMoonShadows (LightShadows moonShadows) // set the coordinates of the storm cloud layer center SetStormCenter (Vector3 stormCenter); // scattering radius, it affects the color of the sky (45000 by default, usually a real sky) SetScatteringRadius (float scatteringRadius); LerpScatteringRadius (float scatteringRadius, float milliseconds ); // The coverage of the main atmosphere is (-5 to 5) void SetCloudCov Er (float cloudCover); LerpCloudCover (float cloudCover, float milliseconds); // dark clouds are not the atmosphere of the storm. (2-0, the lower, the deeper the cloud layer color) SetPrecipitationLevel (float precipitationLevel); LerpPrecipitationLevel (float precipitationLevel, float milliseconds ); // The storm coverage level is (recommended from-3.5 to-1.0) SetStormCloudCover (float cloudCover); LerpStormCloudCover (float cloudCover, float milliseconds); // The amount of rain. There is no heavy rain, but it is light rain. (From 0 to 1000) SetRainLevel (float rainLevel, float sfxLevel); LerpRainLevel (float rainLevel, float sfxLevel, float milliseconds); // extraordinary rainstorm. Rain is everywhere. (From 0 to 200) SetStormLevel (float stormLevel, float sfxLevel); LerpStormLevel (float stormLevel, float sfxLevel, float milliseconds); // The brightness or concentration of the sun. SetSunIntensity (float intensity); LerpSunIntensity (float intensity, float milliseconds); // set built-in FOG (0 to 0.5) setFogLevel (float fogLevel); LerpFogLevel (float fogLevel, float milliseconds); // SetDropletLevel (float dropletLevel); float dropletLevel (float dropletLevel, float, float milliseconds); // sets the direction, acceleration, and evolution speed of the cloud. X = x and acceleration, Y = y and acceleration, Z = evolutionary speed (0 to 1) SetCloudSpeedDirection (Vector3 speedDirection); LerpCloudSpeedDirection (Vector3 speedDirection, float milliseconds ); // halo difference. Set the lighting intensity of the cloud edge (0 to 10 ). Tip: if it is set to around 0, it will have a good effect of rolling cloud. SetGlowVariance (float glowVariance); interval (float glowVariance, float milliseconds); // set the distance from the cloud to the atmosphere (0 to 20) SetViewDistance (float viewDistance); LerpViewDistance (float viewDistance, float milliseconds); // adjust the default color. The default value of RGB is recommended (1.5, 1.5, 1.5 ). If you want a pink or green cloud: DSetColorVariance (Vector3 colorVariance); LerpColorVariance (Vector3 colorVariance, milliseconds); // if you want automatic time loop, This is the speed of time passing. (0 to 0.1) SetSpeedOfTime (float speedOfTime); // Changes light scattering to the cloud, only affecting the color of the cloud. It is best to keep his default value, 40. (-20 to 100) SetRayleighLevel (float rayleighLevel); // If this option is enabled, the player in a day is synchronized with the system clock. SetUseSystemTime (bool enabled); // you can change the color of ambient light. I suggest interpolation or turbidity within one day. SetAmbientLighting (Color ambientLevel); LerpAmbientLighting (Color ambientLevel, float milliseconds); // SetMoonSize (float moonSize); // clear ClearDropletBuffer (); // set the lightning frequency. The higher the frequency (0 to 100 ). SetLightningFrequency (floatfrequency );
Thank you! Good night!