当前位置:网站首页>Unity is connected to the weather system
Unity is connected to the weather system
2022-07-04 05:01:00 【Jiubencai】

I used the weather forecast interface of Gaode open platform to access Unity in .
Gaud open platform | Gould map API Gaode open platform official website https://lbs.amap.com/ After registering Gaode open platform , After moving the mouse to the avatar in the upper right corner, you will find application management , Click on Application Management , Then click create new application .

Click Add ,Web The service can use the weather API.

After the creation, you can see the corresponding Key

Then we can easily get the weather data by looking at the development documents .
Weather query API Service address :
URL | https://restapi.amap.com/v3/weather/weatherInfo?parameters |
Request mode | GET |
parameters The parameters represented include mandatory parameters and optional parameters . All parameters use the and character (&) separation . The following list enumerates these parameters and their usage rules .
- Request parameters
Parameter name | meaning | Rule description | Whether must | The default value | |
|---|---|---|---|---|---|
key | Request service permission id | The user is on the official website of Gaode map apply web service API type KEY | Required | nothing | |
city | City Code | Enter the name of the city adcode,adcode Information is available for reference City code table | Required | nothing | |
extensions | Weather type | Optional value :base/all base: Return to the real weather all: Return to the weather forecast | Optional | nothing | |
output | Returns the format | Optional value :JSON,XML | Optional | JSON | |
Here is the data I got .


Note that real-time weather and weather forecast are two interfaces .
Code example , This code can get the weather json data , adopt json The obtained data can be displayed in UI Yes .
IEnumerator GetBase()
{
UnityWebRequest webRequest = UnityWebRequest.Get(urlBase);
yield return webRequest.SendWebRequest();
if (webRequest.isHttpError || webRequest.isNetworkError)
Debug.Log(webRequest.error);
else
{
// Debug.Log(webRequest.downloadHandler.text);
}
}
边栏推荐
猜你喜欢
随机推荐
关于solidworks standard无法获得许可 8544问题的总结
中科磐云—2022广西逆向解析思路
中科磐云—2022广东木马信息获取解析
练习-冒泡排序
Using jsts in esmodule environment
附件六:防守工作简报.docx
Roles of rollup components
Unity 接入天气系统
在代码中使用度量单位,从而生活更美好
MAUI 入门教程系列(5.XAML及页面介绍)
Binary search tree
Sécurité du réseau dans les écoles professionnelles secondaires - preuve de mémoire
Exercise bubble sort
Qt QTableView数据列宽度自适应
中科磐云—数据分析与取证数据包flag
[matlab] matlab simulates digital bandpass transmission system ask, PSK, FSK system
Useful plug-ins for vscode
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
Fault analysis | mongodb 5.0 reports an error, and the legal instruction solves it
附件六:防守工作簡報.docx









