Real-Time Weather Plugin for Unity | ASSIST Software Romania
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.  

We have recently updated the tool with a series of features that will offer an overall improved experience for the users. The new version comes with:
Expanse – Volumetric Skies, Clouds, and Atmospheres Integration (HDRP)
Feedback form option for user reviews
Updated the RealTimeWeatherManager Inspector
 

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, or Weather APIs like Tomorrow.io, OpenWeatherMap, etc.  

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 ASSIST Software - Main UI

→ 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 ASSIST Software - Don't destroy on load
→ Step 3

In the Location” area fill up the “City” and “Country” input fields for the location you want to receive weather information from. For locations from the USA, check the “United States” option and fill the “State” and “City” fields. 

Real Time Weather Plugin ASSIST Software - Simulation Settings
→ 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 ASSIST Software - Update Weather Frequency
→ Step 5

Depending on what weather plugin you have in the project, you can activate EnviroTenkoku, Massive Clouds Atmos or Expanse (only for HDRP) Simulation
Simply click on one of the weather simulators and everything you need for weather simulation will be added into your scene. 

3. Weather Simulation Assets Integration

3.1 Enviro - Sky and Weather

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 set up with wonderful results.  

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

3.2 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, the day-night cycle, and clouds. It's easy to set up with wonderful results.  

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

 

3.3 MassiveClouds Atmos Integration

Massive Clouds Atmos is an asset that provides the ability to render the entire sky with volumetric effects. It allows you to design the entire sky while adjusting for various weather conditions and time zones in real-time. 

With Massive Clouds Atmos you can simulate a complete day-night cycle, clouds, atmospheric scattering, and fog rendering. 

The current Real-Time Weather version supports integration with Massive Clouds Atmos 1.1.0, which can be imported from the Unity Asset Store 

 

3.4 Expanse – Volumetric Skies, Clouds, and Atmospheres Integration

Expanse – Volumetric Skies, Clouds, and Atmospheres is a state-of-the-art volumetrics tool for HDRP that gives you the power to author beautiful skies, clouds, and fog banks. Together, with Real-Time Weather Manager, you can create compelling and interactive atmospheres. 

With Expanse you can simulate a complete day-night cycle, cloud coverage, atmospheric scattering, fog density, plus other excellent effects. 

The current Real-Time Weather version supports integration with Expanse – Volumetric Skies, Clouds, and Atmospheres 1.6.8, which can be imported from the Unity Asset Store 

 

More information about weather simulation tools activation & deactivation procedures could be found at pages 6-10 on the Documentation

 

4. 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 all the weather providers will fail to obtain weather data.  

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

 

5. Feedback Form

This dialog can be opened from the toolbar “Real-Time Manager” -> “Help” -> “Feedback Form”. 

The module is used to send your feedback to the Real-Time Weather developers. 

Real Time Weather Plugin ASSIST Software - Feedback Form

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, Tenkoku and Massive Clouds Atmos or Expanse.


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 ASSIST Software - Info UI

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.

 

11. Open Weather Map API

OpenWeatherMap is one of the services that offers the capabilities to obtain real-time weather data using HTTP requests to their data-server, based on a user account. In our application we created all the necessary functionality for requesting weather data for two important requests from the server: [Current Weather Data API] and [One Call API]. 

Through the One Call API request, the user could obtain forecast weather data for the next following 48 hours with a step at every hour, or the next 7 days with a daily forecast. 

Real Time Weather Plugin ASSIST Software - Open Weather Map API

The request is composed of: API key, localization data, and optional parameters, using the following request: 

=> api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key} 
 

11.1 OpenWeatherMap request methods

There are 4 modes of request: 

  • City name, state code (applicable only ofr US), and country code 
  • CIty ID [cities.json - file available on the OpenWeatherMap page] 
  • Latitude & Longitude 
  • Zip code and country code 
     

11.2 OpenWeatherMap Parameters 

There are 2 types of parameters: 

  • Language: en, fr, de, jp, ro, etc. 
  • “Request mode” that represents the 4 types of requests presented. 


12. Tomorrow.io API

Tomorrow.io is the world’s leading All-in-One Weather Intelligence PlatformTM [Link], which offers the opportunity to obtain real-time weather data or forecast data (hourly – up to 108 hours, or daily - up to 14 days). 

The Tomorrow API is organized in a RESTful, stable endpoint structure, administered over HTTPS response codes and authentication. The API has predictable URLs, request query and body parameters, and JSON-encoded responses. 

Access to the Tomorrow API requires a valid access key with the right permissions. 

Real Time Weather Plugin ASSIST Software - Tomorrow.io API

12.1 Tomorrow.io request methods 

To request weather data from Tomorrow, you must make the following settings in the Tomorrow Module inspector: 

  • Specify a valid API key in the Tomorrow API key field. Requests not properly authenticated will return a 403-error code; 
  • Specify latitude and longitude (ISO 6709). 


12.2 Tomorrow.io parameters 

The Tomorrow API will automatically request the core weather data such as temperature, wind speed and direction, and so on. In the "Weather Data Settings" menu, check what forecast information and what additional information you want to request from the API. You can choose from a set of weather parameters related to forecast, air quality, and pollen. 

More information about data structures used, the integration with Real-Time Manager, or functionality for user modules could be found at pages 23-26, for Open Weather Map, and pages 29-34, for Tomorrow.io, in the Documentation

 

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 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