get in touch
>

LIKE

SHARE

Facebook Share Tweet LinkedIn Share

FOLLOW

LinkedIn Follow Xing Follow

1. Introduction into real-time weather plugin for Unity

The Real-Time Weather Plugin for Unity is an efficient tool to obtain real-time weather data in Unity and process the data to simulate a full environment system.  

Example scenes are provided to show the capabilities of the Unity extension tool with real-time data obtained from three different sources: Weather Atlas official webpage, Weather Underground official webpage, Weather For You official webpage

Get the Real-Time Weather Plugin for a special price from https://assetstore.unity.com/packages/tools/utilities/real-time-weather-169843

Subscribe on YouTube

 

 

2. Overview & Installation 

Import Real-time weather package and follow these steps to get started:

 → Step 1 

On unity top bar you will find a new tab “Real-time Weather”, so click on it and then select “Real-time Weather Manager”. A new game object will be created in your scene with the “RealTimeWeatherManager” component. 

Real-time weather plugin for Unity(1) - Alexandru Patraucean - ASSIST Software Romania
→ Step 2

If you want “Real-time Weather Manager” to not be destroyed when other scene is loaded, then check “Don’t Destroy On Load” in “General Settings” panel.  

Real-time weather plugin for Unity(2) - Alexandru Patraucean - ASSIST Software Romania.
→ Step 3

In the Localization” area fill up the “City” and “Country” input fields for the location you want to receive weather information from. For locations from the USA, the “City” input should always be composed of two words, the name of the state and the name of the city, for example, "Colorado, Arriba". 

Real-time weather plugin for Unity(3) - Alexandru Patraucean - ASSIST Software Romania.
→ Step 4

To get real-time weather updates, check “Enable auto weather update” and also choose “Update frequency” which is measured in minutes. 

Real-time weather plugin for Unity(4) - Alexandru Patraucean - ASSIST Software Romania.
→ Step 5

Depending on what weather plugin you have in the project, you can activate Enviro or Tenkoku Simulation
Simply click on “Activate Enviro Simulation” or “Activate Tenkoku Simulation” and everything you need for weather simulation will be added into your scene. 
 

3. Enviro Integration

Enviro - Sky and Weather is a complete dynamic AAA sky and weather solution!  

With Enviro, you can simulate weather, day-night cycle, clouds, vegetation growth and seasons. Easy to setup with wonderful results.  

The current Real-Time Weather version supports integration with Enviro 2.2.0, which can be imported from the Unity Asset Store

→  Activation

Real-Time Weather will automatically detect the presence of the Enviro asset and will enable the simulation controls. 

Click the “Activate Enviro Simulation” button to simulate the weather using Enviro. After that, you will see that the EnviroModule object has been added to the scene. Disable other light sources. 

→  Deactivation

Click the "Deactivate Enviro Simulation" button to disable weather simulation using Enviro. The EnviroModule, Enviro Effects, and Enviro Directional Light objects will be deleted from the scene. 

Now you can remove the Enviro asset, if you wish, or keep it for future simulations. 
 

4. Tenkoku - Dynamic Sky Integration

Tenkoku- Dynamic Sky brings completely dynamic high-fidelity sky and weather rendering to Unity developers

With Tenkoku you can simulate weather, day-night cycle, clouds. It's easy to set up with wonderful results.  

The current Real-Time Weather version supports integration with Tenkoku 1.2.1, which can be imported from the Unity Asset Store

→ Activation

Real-Time Weather will automatically detect the presence of the Tenkoku asset and will enable the simulation controls. 

Click the “Activate Tenkoku Simulation” button to simulate the weather using Tenkoku. After that, you will see that the Tenkoku Module object has been added to the scene. Disable other light source. 

→ Deactivation

Click the "Deactivate Tenkoku Simulation" button to disable weather simulation using Tenkoku. Tenkoku Module, object will be deleted from the scene. 

Now you can remove the Tenkoku asset, if you wish, or keep it for the later simulations. 
 

5. Help & Bug Report 

This module will send an email to the Real-Time Weather developers, when an error appears in the services used for getting weather data. It can also be used to ask other questions.  

The Bug Reporter will be activated automatically when the last service (WeatherForYou module) will fail to obtain weather data.  

It can also be activated by pressing the “Real-time Weather Manager” tab and then selecting “Bug Reporter”. 

Real-time weather plugin for Unity(5) - Alexandru Patraucean - ASSIST Software Romania.

6. Scripting API 


6.1 Real-Time Weather Manager

The RealTimeWeatherManager class is implemented using the Singleton design pattern and it manages the main functionalities of the Real-Time Weather plugin. It allows weather data requests from the Atlas module, Underground module, and WeatherForYou module.  

Also, it manages the automatic weather data update and weather simulation using third-party support components: Enviro and Tenkoku.


6.2 Request weather data  

public void RequestWeather(string city, string country)
Example: 
RealTimeWeatherManager.instance.RequestWeather("Paris", "France");

The Weather data request can be made using the following function:  


6.3 Receive weather data 

public delegate void WeatherUpdate(WeatherData weatherData);
public event WeatherUpdate OnWeatherUpdate;

Example: 
RealTimeWeatherManager.instance.OnWeatherUpdate += OnWeatherUpdate;

Receiving current weather data can be done by subscribing to the OnWeatherUpdate event. 


6.4 Notify weather data changed 

Send a notification with updated weather data to the components that listen to the OnWeatherUpdate event. 

private void NotifyWeatherChanged(WeatherData weatherData);

7. Weather Data

The WeatherData class is used to store and manage weather data. 

_localization is a Localization class instance that holds the localization data: city, country, latitude, and longitude. 

_dateTime is an instance of DateTime structure that represents an instant in time, typically expressed as a date and time of day. 

_utcOffset is an instance of TimeSpan structure that represents the difference in hours and minutes from Coordinated Universal Time (UTC) for a particular place and date. 

_wind is a Wind class instance that holds the wind data: direction and speed. Speed is measured in km/h. 

_weatherState a WeatherState enum value that represents the weather state. 

public enum WeatherState
{
Clear, 
PartlyClear,
Cloudy,
PartlyCloudy,
Mist,
Thunderstorms,
RainSnowPrecipitation,
RainPrecipitation,
SnowPrecipitation,
Windy,
PartlySunny,
Sunny,
Fair	
}

_temperature is a float value that represents the temperature in °C. 

_pressure(atmospheric pressure), also known as barometric pressure is a float value that represents the pressure within the atmosphere of Earth measured in millibars. 

_humidity a float value that represents the humidity. 

_precipitation is a float value that represents the precipitation in mm. 

_dewpoint is the temperature to which air must be cooled to become saturated with water vapor at °C. 

_visibility is a float value that represents the visibility in km. 

_indexUV is a float value that represents the UV index. The ultraviolet index is an international standard measurement of the strength of sunburn-producing ultraviolet (UV) radiation at a particular place and time. 

The weather data received from the services can be viewed in the WeatherUI interface. 

Real-time weather plugin for Unity(6) - Alexandru Patraucean - ASSIST Software Romania.

The WeaterUI Prefab can be found in Real-Time Weather Manager/Prefabs/UI Prefabs. The information will be displayed if simulation settings have been set. 


8. Atlas Module

This module is responsible for downloading web pages from https://www.weather-atlas.com and parsing them to obtain weather information. 

The webpage data is requested using input composed from the non-abbreviated, complete name of the city and country, for example: "Spain/Madrid”. 

The obtained data are parsed through HtmlAgilityPack HTML parser, a C# linked solution that transforms a plain text in a parsable HTML node structure using tags division. 


8.1 Receive Atlas weather data 

public delegate void OnWebPageParsed(WeatherData weatherData);
public OnWebPageParsed onWebPageParsed;

Example:
_atlasModule.onWebPageParsed += OnReceivingAtlasWeatherData;

Text BoxReceiving Atlas weather data can be done by subscribing to the OnWebPageParsed delegate. 
 


8.2  Receive Atlas exception 

public delegate void OnExceptionRaised(ExceptionType exception, string message);
public OnExceptionRaised onExceptionRaised;

Example:
_atlasModule.onExceptionRaised += OnAtlasServiceExceptionRaised;

Receiving Atlas exception can be done by subscribing to the OnExceptionRaised delegate. 

The WeatherAtlasModule is instantiated in the scene as a child of RealTimeWeatherManager. You can use this module separately, the WeatherAtlasModulePrefab prefab can be found in Real-Time Weather/Prefabs/Weather Modules Prefabs.
 

9. Weather for your module 

This module is responsible for downloading web pages from https://www.weatherforyou.com/ and parsing them to obtain weather information. 

The webpage data is requested using input data composed from the name of the city/county and the abbreviated name of the country, for example: “&place=liverpool&state=&country=gb”. 

The obtained data are parsed through HtmlAgilityPack HTML parser, C# linked solution which transforms a plain text in a parsable HTML node structure using tags division. 


9.1 Receive WeatherForYou weather data 

public delegate void OnWebPageParsed(WeatherData weatherData);
public OnWebPageParsed onWebPageParsed;

Example:
_weatherForYou.onWebPageParsed += OnReceivingWeatherForYouData;

Receiving WeatherForYou weather data can be done by subscribing to the OnWebPageParsed delegate


9.2  Receive WeatherForYou exception 

public delegate void OnExceptionRaised(ExceptionType exception, string message);
public OnExceptionRaised onExceptionRaised;

Example:
_weatherForYou.onExceptionRaised += OnWeatherForYouExceptionRaised;

Receiving WeatherForYou exception can be done by subscribing to the OnExceptionRaised delegate

The WeatherForYouModule is instantiated in the scene as a child of RealTimeWeatherManager. You can use this module separately, the prefab can be found in Real-Time Weather/Prefabs/Weather Modules Prefabs.
 

10. Weather Underground Module

This module is responsible for downloading web pages from https://www.wunderground.com/ and parsing them to obtain weather information.  

The webpage data is requested using input data composed from the abbreviated name of the country and the name of city/county, for example: “fr/Paris”. 

The obtained data are parsed through HtmlAgilityPack HTML parser, C# linked solution that transforms a plain text in a parsable HTML node structure using tags division.  


10.1 Receive Underground weather data 

public delegate void OnWebPageParsed(WeatherData weatherData);
public OnWebPageParsed onWebPageParsed;

Example:
_undergroundModule.onWebPageParsed += OnReceivingUndergroundData;

Receiving Underground weather data can be done by subscribing to the OnWebPageParsed delegate. 
 


10.2 Receive Underground exception 

public delegate void OnExceptionRaised(ExceptionType exception, string message);
public OnExceptionRaised onExceptionRaised;

Example:
_undergroundModule.onExceptionRaised += OnUndergroundExceptionRaised;

Receiving Underground exception can be done by subscribing to the OnExceptionRaised delegate. 

The WeatherUndergroundModule is instantiated in the scene as a child of RealTimeWeatherManager. You can use this module separately, the WeatherUndergroundModulePrefab prefab can be found in Real-Time Weather/Prefabs/Weather Modules Prefabs.

Congrats to our Game Development team for the creativity, dedication, and hard work that went into creating the Real-Time Weather Plugin.

→ Get the Real-Time Weather Plugin for a special price from the Unity Asset Store

ASSIST Software’s dedicated game development team also created a demo scene with a set of animations for testing purposes meant to provide a better understanding of the product.

Do you want to get in touch with us? 

If you are interested in our software development services, you would like to join our team, or you simply want to find out more about us, we’d love to hear from you! Drop us a line and a member of the ASSIST team will get back to you as soon as possible. We are sure we can ASSIST you.

GET IN TOUCH