In order to start using ‘True Weather’ the first thing you should do is create a new object in your scene and add the component ‘TrueWeather’. There should be only one instance of that component.
Once added, you will see something like this in the editor:
In ‘Units’ (1) you can change the metric system in which the units will be.
If ‘Try GPS first’ (2) is activated, the geolocation service will first attempt to use the GPS hardware of the device. This is usually only available on mobile devices and the application will need permissions to use it. If this option is used and to save battery, the configuration is used with less precision (~500 meters) and is only active during detection.
If this option is not activated, or is not available, the web service provided by ipap.co. This service does not require registration for less than 1000 consultations per day. We recommend you register and look his payment service when your game is public. When you register, they will give you a key that you must put in ‘API Key’ (3).
To obtain the meteorological data, the web service provided by openweathermap.com will be used. This service does require you to register, even for your free service. You must register for the ‘Current weather data’ service in the API section:
With the free service you can make up to 60 queries every hour. When you register, they will give you a key that you must put in ‘API Key’ (4).
Are you interested in using another similar service? Do not hesitate to contact us.
All code is inside the namespace ‘Nephasto.TrueWeatherAsset’ and main component is ‘TrueWeather’. So if you want to use it you must first import its namespace:
If you already created an object with the ‘TrueWeather’ component, to access it:
To detect the current time you will first have to call the function ‘Detect()’. As this information may take some time to be available, you can pass an Action as a parameter to know when it is ready. For example, if you want that when the information is available, your ‘ShowWeatherInfo()’ function is called:
Once the ‘Detect()’ function returns you successfully, you can check the information using the properties ‘Location’ (geolocation) and ‘Weather’ (meteorological information):
All this information will be available until the next time you call ‘Detect()’. If instead of the meteorological data you want a description of the weather, you can consult ‘trueWeather.Weather.ID’ which will return an identifier that depends on the service used. While using the ‘OpenWeatherMap’ service, the identifier corresponds to the values you can see in the file ‘OpenWeatherMapIDs.cs':
Optionally, and if you have used the ipap.co service (not the GPS device), you can access the extra information provided by this service:
All the code are well commented, I recommend reading it if you want more information.
Any questions or suggestions you have, I will be happy to answer you in