[Xiao Mu learns Unity3d] Unity plug-in weather system UniStorm

1 Introduction

UniStorm - Volumetric Clouds, Sky, Modular Weather and Cloud Shadows

1.1 Description

UniStorm is the ultimate solution for AAA dynamic skies, weather, cloud shadows, atmospheric fog and procedural volumetric clouds. UniStorm gives you the option to adjust every component in the sky.

UniStorm is a very powerful dynamic day and night weather system capable of creating AAA class dynamically generated weather, lighting and skies at extremely fast frame rates. UniStorm features over 300 customizable components, allowing users to create any environment imaginable.

insert image description here

1.2 Compatibility

Unity's Programmable Render Pipeline (SRP) is a feature that allows you to control rendering through C# scripts. SRP is the underlying technology supporting Universal Rendering Pipeline (URP) and High Definition Rendering Pipeline (HDRP).

insert image description here

insert image description here

1.3 Price

insert image description here

1.4 Features

  • AAA Volumetric Clouds
    UniStorm 4.0 brings a completely redesigned cloud system capable of creating AAA procedural, self-projected, PBR, volumetric clouds with excellent frame rates and using only one draw call! UniStorm's cloud uses the latest rendering and performance techniques, such as temporal reshoots and LODs. UniStorm's clouds contain 4 mass settings plus a volumetric and 2D option, all of which can be changed at runtime or in the UniStorm editor. This enables it to support a wide range of devices and computers. An easy-to-use API makes adding in-game quality controls hassle-free. It also contains an example that demonstrates the operation.

insert image description here

  • Built-in support for Photon PUN 2 networking
    UniStorm includes everything you need to get UniStorm to work with PUN 2 and have PUN 2 synchronize UniStorm multiplayer weather, time and date. A sample scene is included.

  • Atmospheric Fog
    Atmospheric Fog takes into account the sun and moon direction as well as the application of color to the scene, UniStorm's clouds and skyboxes.

  • Cloud Shadows
    Efficient real-time screen-space cloud shadows to match current cloud layers and cloud types to add realistic visual effects.

  • 4k stars with precise constellation arrangement
    UniStorm's night sky contains 4k stars with precise constellation arrangement. There are options within the editor to control the tightness of the constellation.

  • Programmatic Aurora
    UniStorm lets users customize intensity, color, condition, and more of Aurora by weather type!

  • Performance
    UniStorm's volumetric clouds feature temporal recasting and LODs, both with 4 quality settings (low, medium, high and ultra), estimated to be far more efficient than previous settings. This allows UniStorm to run smoothly on almost any computer. Thanks to the UniStorm shader, there is no maximum limit to the camera far clipping plane distance, so you can use any distance.

  • Lightweight options built in
    Why pay more for necessary features? UniStorm has a built-in lightweight 2D cloud option, especially suitable for low-end mobile devices or computers. Users can select the mobile option from the editor and it will automatically apply all optimization settings without overriding custom settings like colors.

  • Dynamic Modular Weather
    Modular Weather enables users to create custom weather types. Dust storms, auroras, hailstorms, thunderstorms, and more are all possible. There is no limit to how many weather types UniStorm can have, and the best part is that it allows users to customize effects, settings and sounds for each weather type. UniStorm brings 31 weather types! These include: Aurora, Blowing Leaves, Blowing Snow, Blowing Grass, Fireflies, Clear, Mostly Clear, Partly Cloudy, Mostly Cloudy, Cloudy, Overcast, Foggy, Light Rain, Light Rain, Rain, Heavy Rain, Hail, thunderstorms, blizzards, snow, blizzards, thundersnow, fire rain, dust storms and more!
    insert image description here

  • Cloud Configurations
    Each weather type in UniStorm has a customizable cloud configuration. This lets you customize the appearance of clouds to provide a lot of variation for each weather type. With UniStorm's cloud configurations, users are sure to find the type of cloud that suits them. Sunny, fluffy, fluffy, balanced, and stylized cloud configurations are all included. However, you can always create your own!

  • VR and Mobile Available
    UniStorm's all-in-one functionality also supports mobile and VR (currently only multi-channel). There's even an easy-to-use option to automatically apply all optimization settings to a given platform while maintaining user customizations!

  • Advanced Weather Generation
    UniStorm's weather is generated based on the precipitation rate set in the UniStorm editor. An easy-to-use line graph allows the user to set the precipitation rate for each weather type, and UniStorm will generate the corresponding weather. Summer can have less precipitation than winter, and vice versa. UniStorm has options to generate daily weather with random start times and hourly weather based on in-game timing and precipitation rates. Static weather can also be selected if the user does not want to generate weather.
    insert image description here

  • Global Weather Shader and Rendering
    UniStorm's global shader allows objects to be rendered with rain and snow in the rain and snow weather types. Rain rendering can make the surface more glossy, only for surfaces less than 90 degrees. The interior of most surfaces will remain dry, such as the interior of buildings and roofs. Snow does the same, but with snow rendering. The snow texture, snow pump texture and snow specular level can all be custom tuned. UniStorm fades weather rendering when the weather is not raining or snowing.

  • Weather and Weather Transitions
    UniStorm allows the user to create an unlimited number of weather types. Every time the weather changes, UniStorm will seamlessly transition according to the global transition speed. Each weather type can be customized with its cloud cover, cloud style, cloud height, particle effects, sun intensity, moonlight intensity, cloud shadow intensity, sound effects, wind volume and various other settings for a truly unique and highly customizable sexual weather.

  • Procedural Lightning and Lightning Strikes
    UniStorm's procedural lightning system allows objects to be struck by lightning. The user can specify the probability that lightning will strike the ground and objects. When lightning strikes, users can customize the special effects it produces. This can be done with appropriate labels or even fire effects.

  • Day/Night Cycling and Color Control
    UniStorm allows you to adjust all the colors of the environment and sky at different times of day, such as day, moon color, ambient light color, shadow and cloud shadow strength, fog color, sky color, environment reflection strength and more! Each color has its own individual color options for use with precipitation weather types.
    insert image description here

  • Time, Date and Built-in Calendar
    UniStorm has a built-in time and date system to help you keep track of your players' game time. UniStorm's calendar is precise and even uses the current time and date.

  • Customizable Moon Phase System
    UniStorm's customizable moon phase system allows users to build their own moon phases. There is no upper limit to the number of moon phases available in UniStorm. Users can preview their moon phases and set starting moon phases directly on the UniStorm editor. UniStorm automatically assigns all required textures and updates the moon phases daily. Each moon phase also has its own moonlight intensity. This can make crescent and sickle moon phases less bright than full moon if desired by the user.

  • Weather Type Conditions
    The optional Weather Type Conditions allow UniStorm's Weather Generator to generate weather types based on the attainment of specified conditions. These include conditions such as: specific seasons and temperatures and the ability to invoke a certain weather type only on custom events or programmatically.

  • UniStorm Configuration Files
    Import and export your UniStorm settings from a UniStorm configuration file. This allows users to save their settings and transfer them between other UniStorm systems without manually applying colors and settings.

  • Sounds and Music for Different Times of Day
    UniStorm allows users to customize the sound effects and/or music played at different times of day. The delay time between each sound effect and song can be adjusted. There is no upper limit to the number that can be used.

  • Sound Manager
    UniStorm's sound manager uses the Unity Audio Mixer for all sounds created by UniStorm. This gives you precise control over global, ambient, weather and music volume, and can be used in the user UI or controlled within the UniStorm editor.

  • Built-in Events
    UniStorm's built-in events can be called hourly, daily, monthly, yearly, and even during weather changes in the game, allowing users to easily create game functions.
    insert image description here

  • Examples included
    UniStorm includes 6 example scenes to demonstrate the different functions that UniStorm can do. Also includes a save example system to allow users to manually or automatically save their game time, date, weather, temperature and more. These data can be loaded later, and the user can directly follow up the progress of the last time.

  • Editor
    UniStorm's editor design was influenced by feedback from its many users, so it is intuitive, powerful and offers a low learning curve. UniStorm's editor is self-describing, so each component is explained in the editor's tooltip.

  • API and Documentation
    UniStorm's API can facilitate other game mechanics and functions, such as accessing its temperature, time, date, current weather, forecast weather, seasons and more. Tutorial videos and external documentation are included to help users get the most out of UniStorm.

  • Support for CTS Weather Manager
    UniStorm includes an external system to transition to CTS's weather renderer, allowing your terrain to have snow and humidity rendering when it is snowing or raining. (excluding CTS)

1.5 Example

https://unistorm-weather-system.fandom.com/wiki/Documentation

  • Basic Example - A basic standard demo of UniStorm.
  • Dynamic Snow Example - Provides a demonstration of dynamically constructing snow on non-terrain objects.
  • Plant Growth Example - Provides a demonstration of dynamically growing plants based on a number of different factors.
  • Save and Load Example - A demo that provides an efficient save and load system that allows you to save UniStorm's time, weather, date and player's position, then load it at the location you saved it to.
  • Build Sample - Provides a demo of an example that allows character generation at runtime. All effects and components are then applied to UniStorm at runtime.
  • Vital Signs Survival Example - Provides a demo of the Survival Example, where the player is affected by UniStorm factors/variables such as temperature (warmth), weather (dryness), and time (hunger).
  • Weather Forecaster Example - Demonstrates how to use the weather forecaster system to generate a weekly forecast for UniStorm.
  • Advanced UI Example - Demonstrates an advanced UI that references UniStorm to display the current time, date, temperature, weather, season, month, etc.
  • Autosave Example - Demonstrates how to use the autosave system to save player positions and UniStorm variables. It can then be loaded at any time to pick up where the player left off.
  • Procedural Lightning Example - Demonstrates UniStorm 2.4's new lightning system with procedural lightning and improved lightning generation.
  • Event Example 1 (Generating Daily Objects) - Demonstrates that UniStorm 2.4's new event system generates objects at specific times of the day.
  • Event Example 2 (Random Daily Weather) - Demonstrates that UniStorm 2.4's new event system generates objects at specific times of the day.
  • Event Example 3 (Enabling and Disabling Lights at Night) - Demonstrates that UniStorm 2.4's new event system generates objects at specific times of day.

3. Installation

3.1 Create a new Unity project

Run Unity Hub, switch to the project page, open the interface as follows:
insert image description here
select the core template, select 3D, as follows:
insert image description here
the new project is loading resources.
insert image description here
The new project is successfully created, and the interface after entering is as follows:
insert image description here

3.2 Install the plug-in UniStorm

Just download the plug-in and import it directly.

Just copy the Assets in the UniStorm code folder to the Assets of the current newly created project. Unity then automatically loads the copied files.
Of course, an error may be reported during this process as follows:
insert image description here
double-click the place where the error is reported above, the VS editor will pop up, and open the error code file, as follows:
insert image description here
Change all "MinAttribute" in the above file to "UnityEngine.PostProcessing.MinAttribute", as follows:

using UnityEngine;
using UnityEngine.PostProcessing;
 
namespace UnityEditor.PostProcessing
{
    
    
    [CustomPropertyDrawer(typeof(UnityEngine.PostProcessing.MinAttribute))]
    sealed class MinDrawer : PropertyDrawer
    {
    
    
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
    
    
            UnityEngine.PostProcessing.MinAttribute attribute = (UnityEngine.PostProcessing.MinAttribute)base.attribute;
 
            if (property.propertyType == SerializedPropertyType.Integer)
            {
    
    
                int v = EditorGUI.IntField(position, label, property.intValue);
                property.intValue = (int)Mathf.Max(v, attribute.min);
            }
            else if (property.propertyType == SerializedPropertyType.Float)
            {
    
    
                float v = EditorGUI.FloatField(position, label, property.floatValue);
                property.floatValue = Mathf.Max(v, attribute.min);
            }
            else
            {
    
    
                EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
            }
        }
    }
}

After saving the file, Unity automatically compiles and loads the file. Error solved!

Then select the Unity menu item Window—>UniStorm—>Create Weather System (create a UniStorm System component). Be careful not to rename the created component, otherwise the built-in script will not be found.
insert image description here
A UniStorm System object node is automatically created in the Hierarchy interface.
insert image description here

(1)在Asset Store中搜索并下载Unistorm插件,或者从其他渠道获取Unistorm的.unitypackage文件。
(2)在Unity编辑器中,选择Assets -> Import Package -> Custom Package…,打开文件选择对话框。
(3)选择您下载的Unistorm插件的.unitypackage文件,点击Open按钮。
(4)在导入资源包的窗口中,勾选您需要导入的资源,然后点击Import按钮。
(5)或者您需要在Unity编辑器中,将UniStorm_Source文件夹拖拽到项目视图中的Assets文件夹下。
(6)等待Unity完成导入后,在项目视图中找到UniStorm -> Prefabs -> UniStorm System,并将其拖拽到场景视图或者层次视图中。
(7)选中场景视图或者层次视图中的UniStorm System对象,在检查器视图中可以看到它的组件和设置项。
(8)在检查器视图中,找到Player & Camera设置项,并选择您的玩家对象和摄像机对象。这两个对象是必要的,因为Unistorm会根据它们的位置来生成天气效果。
(9)您可以在检查器视图中调整其他设置项来定制您想要的天气系统。例如,您可以在Weather Options设置项下选择不同的天气类型、频率、音效等。您也可以在Sky Options设置项下调整天空、太阳、月亮、星星等组件的外观和行为。
(10)您可以点击播放按钮来预览和测试您的天气系统。如果您对效果满意,就可以保存并应用到您的项目中了。如果不满意,就可以继续调整设置项直到达到理想效果。

3.3 Introducing the UniStorm Toolbar

  • Player & Camera

This setting allows you to select Unistorm's player and player objects, and the options will be adjusted according to your selection. The weather system must select the Player and Camera objects. It will determine the range of the generated weather based on the position of the Player and Camera objects.

Player and Camera are necessary objects. If the plugin cannot find them, an error will be reported at runtime, and the weather effect will not be visible

Get Player at Runtime: Whether you can get your Player during runtime, you can pass the name or label.
Use Runtime Delay: Whether it will wait for initialization until the Player is created and found.
Use UniStorm Menu: Whether to use the UniStorm menu, which can be triggered by the ESC key during operation, and the function is to select different weather types.
insert image description here

  • Time Management

Time management allows you to control various time-related settings such as start time, time flow, etc.

insert image description here

  • Weather Management

Weather management allows you to adjust various weather-related settings, such as weather type, cloud color, and lightning settings, among others.
Weather Generation: Whether to generate weather, if Disabled, UniStorm will always maintain a weather type, unless the code is used to control its change.
insert image description here

  • Celestial Setting

This setting controls the colors of the sun, moon, stars, and atmosphere.
insert image description here

3.4 Getting Started

Create an empty object: Player.

insert image description here
And modify its Position to (10, 10, 10).
insert image description here

The scene camera MainCamera is set to (0, 0, 0) and assigned to the PlayerTransform and PlayerCamera fields respectively.
insert image description here
Click the play button on the top triangle of Unity's Play:
insert image description here

Run and press Esc to select cloudy weather in the menu to switch. You can see that the weather changes.
insert image description here
After selecting a weather from the drop-down box, click the button "Change Weather" below with the mouse, and then you need to wait for a while before the weather transitions to the new weather effect.

/*      插件天气对照表
0   Clear				 		//清除 万里无云        
1   Mostly Clear		 		//晴时多云              
2   Mostly Cloudy	    		//大部多云              
3   Partly Cloudy				//局部多云;少云         
4   Cloudy						//阴天的		
5   Lightning Bugs			    //萤火虫
6   Blowing Pollen			    //吹花粉
7   Blowing Leaves			    //吹树叶
8   Blowing Pine Needles 	    //吹松针
9   Blowing Snow				//高吹雪,飞雪
10  Foggy						//有雾的
11  Overcast					//阴天的
12  Hail						//下冰雹
13  Heavy Rain					//大暴雨
14  Rain						//雨
15  Light Rain					//小雨
16  Drizzle					    //下毛毛雨
17  Heavy Snow					//大雪
18  Snow						//雪
19  Light Snow					//小雪
20  Thunderstorm				//雷雨
21  Thunder Snow				//雷阵雨
22  Dust Storm					//尘暴
23  Fire Rain					//火雨
24  Fire Storm					//大火
 */

4. Script development

UniStorm provides a large number of useful APIs that make it easy to customize and change UniStorm. United Storm's
API is accessed from 2 different scripts. Be sure to use the correct instance interface when accessing.

4.1 Interface Introduction

4.1.1 Weather

//Changes UniStorm's weather, regardless of conditions, with the transition speed to the weather type parameter.
UniStormManager.Instance.ChangeWeatherWithTransition(WeatherType weatherType);

//Changes UniStorm's weather instantly, regardless of conditions, to the weather type parameter.
UniStormManager.Instance.ChangeWeatherInstantly(WeatherType weatherType);

//Generates a random weather type, regardless of conditions, from UniStorm's All Weather Type list
UniStormManager.Instance.RandomWeather();

//Get the name of the current weather type string CurrentWeatherTypeName =
UniStormSystem.Instance.CurrentWeatherType.WeatherTypeName;

//Gets the forecasted weather type's name
string WeatherForecastName = UniStormManager.Instance.GetWeatherForecastName();

//Gets the hour that the forecasted weather will change
string WeatherForecastName = UniStormManager.Instance.GetWeatherForecastHour();

//Disables or enables all UniStorm particle effects depending on the ActiveState bool, , but does not affect their emission amount.
UniStormManager.Instance.ChangeWeatherEffectsState(bool ActiveState);

//Disables or enables all UniStorm weather sounds depending on the ActiveState bool, but does not affect their current volume.
UniStormManager.Instance.ChangeWeatherSoundsState(bool ActiveState);

//Get the current UniStorm temperature
int CurrentTemperature = UniStormSystem.Instance.Temperature;

4.1.2 Time

//Get the current UniStorm Minute
int CurrentMinute = UniStormSystem.Instance.Minute;

//Get the current UniStorm Hour
int CurrentHour = UniStormSystem.Instance.Hour;

//Sets UniStorm's Date
UniStormManager.Instance.SetDate(int Year, int Month, int Day);

//Sets UniStorm's Time
UniStormManager.Instance.SetTime (int Hour, int Minute);

//Get the current time of day state
UniStormSystem.CurrentTimeOfDayEnum CurrentTimeOfDayState = UniStormSystem.Instance.CurrentTimeOfDay;

//Sets the length, in minutes, of UniStorm's days
UniStormManager.Instance.SetDayLength(int MinuteLength);

//Sets the length, in minutes, of UniStorm's nights
UniStormManager.Instance.SetNightLength(int MinuteLength);

//Gets the current UniStorm day of the week
System.DayOfWeek CurrentDayOfWeek = UniStormManager.Instance.GetDate().DayOfWeek;

//Gets the current UniStorm date
System.DayOfWeek CurrentDayOfWeek = UniStormManager.Instance.GetDate().DayOfWeek;

4.1.3 degree

//Set UniStorm's Music volume using a value from 0 (Fully muted) to 1 (Full volume).
UniStormManager.Instance.SetMusicVolume(float Volume);

//Set UniStorm's Ambience volume using a value from 0 (Fully muted) to 1 (Full volume).
UniStormManager.Instance.SetAmbienceVolume(float Volume);

//Set UniStorm's Weather volume using a value from 0 (Fully muted) to 1 (Full volume).
UniStormManager.Instance.SetWeatherVolume(float Volume);

4.1.4 Seasons

//Get the current season
UniStormSystem.CurrentSeasonEnum currentSeason = UniStormSystem.Instance.CurrentSeason;

4.1.5 System

//Change the player transform and player camera to UniStorm, if they need to be changed or updated.
UniStormManager.Instance.ChangePlayerComponents(Transform PlayerTransform, Camera CameraSource);

4.1.6 Others

//Changes UniStorm's moon phase color. The updated color will be applied at noon when UniStorm's moon is updated.
UniStormManager.Instance.ChangeMoonPhaseColor(Color MoonPhaseColor)

4.2 Interface Test

4.2.1 Test 1

(1) Create a UniStorm System object.
insert image description here

(2) Create an empty object: Player
insert image description here
(3) Click the UniStorm System object with the mouse, and configure the UniStorm System object in the property area on the right.
insert image description here
(4) Create a Button object.

insert image description here
(5) Modify the text of the Button object.
insert image description here

(6) Create a Script object.
insert image description here

  • Weather_Button.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Weather_Button : MonoBehaviour
{
    
    
    void Start()
    {
    
    
		//TODO
    }
    
    void Update()
    {
    
    
		//TODO
    }
    
    public void changeWeather()
    {
    
    
        UniStormSystem.Instance.ChangeWeather(UniStormSystem.Instance.AllWeatherTypes[18]);
    }
}

(7) Drag the above Script object to the Button object in the Hierarchy tree.
insert image description here
(8) Click the + button of On Click(). Bind the function interface in the Weather_Button script.
Drag the Button object into the first text box in row 2. Then select the function in the script from the drop-down box at the back.
insert image description here
(9) Click the Play button, as follows.
insert image description here
After clicking the button, it slowly began to snow. If winter comes, can spring be far behind?
(10) Add another button to control the time change.
insert image description here
Its corresponding script is as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;

public class Weather_Time : MonoBehaviour
{
    
    
    // Start is called before the first frame update
    void Start()
    {
    
    
        //TODO
    }

    // Update is called once per frame
    void Update()
    {
    
    
        //TODO
    }

    private string GetCurrentTime()
    {
    
    
        DateTime dateTime = DateTime.Now;
        string strNowTime = string.Format("{0:D}{1:D}{2:D}{3:D}{4:D}{5:D}", dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);

        print(strNowTime);
        return strNowTime;
    }

    public void changeTime()
    {
    
    
        DateTime dateTime = DateTime.Now;
        UniStormManager.Instance.SetTime(dateTime.Hour, dateTime.Minute);
    }
}

(11) Add another text box to display the time change.
insert image description here
Its corresponding script is as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class Text_Time : MonoBehaviour
{
    
    
    public TextMeshProUGUI TxtCurrentTime;

    // Start is called before the first frame update
    void Start()
    {
    
    
        TxtCurrentTime = transform.GetComponent<TextMeshProUGUI>();
        // TxtCurrentTime = GetComponent<TextMeshPro>();
    }

    // Update is called once per frame
    void Update()
    {
    
    
        if (Input.GetKey(KeyCode.Space))
        {
    
    
            //TODO
        }

        //获取系统当前时间
        System.DateTime NowTime = System.DateTime.Now.ToLocalTime();
        TxtCurrentTime.text = NowTime.ToString("HH:mm:ss");
    }
}

(12) Click the Play button, as follows.
insert image description here
Click the second button, as follows:
insert image description here

epilogue

如果您觉得该方法或代码有一点点用处,可以给作者点个赞,或打赏杯咖啡;╮( ̄▽ ̄)╭
如果您感觉方法或代码不咋地//(ㄒoㄒ)//,就在评论处留言,作者继续改进;o_O???
如果您需要相关功能的代码定制化开发,可以留言私信作者;(✿◡‿◡)
感谢各位大佬童鞋们的支持!(´ ▽´ )ノ (´ ▽´)! ! !

Guess you like

Origin blog.csdn.net/hhy321/article/details/129654735