当前位置:网站首页>Unity 接入天气系统
Unity 接入天气系统
2022-07-04 03:55:00 【九本才】

我使用了高德开放平台的天气预报接口接入到Unity中。
高德开放平台 | 高德地图API高德开放平台官网https://lbs.amap.com/注册高德开放平台后,鼠标移动到右上角头像后就会发现应用管理,点击应用管理,再点击创建新应用。

点击添加,Web服务就可以使用天气的API。

创建完成后就可以看到对应的Key

然后我们查看开发文档就很容易获取到天气的数据。
天气查询API服务地址:
URL | https://restapi.amap.com/v3/weather/weatherInfo?parameters |
请求方式 | GET |
parameters代表的参数包括必填参数和可选参数。所有参数均使用和号字符(&)进行分隔。下面的列表枚举了这些参数及其使用规则。
- 请求参数
参数名 | 含义 | 规则说明 | 是否必须 | 缺省值 | |
|---|---|---|---|---|---|
key | 请求服务权限标识 | 用户在高德地图官网申请web服务API类型KEY | 必填 | 无 | |
city | 城市编码 | 输入城市的adcode,adcode信息可参考城市编码表 | 必填 | 无 | |
extensions | 气象类型 | 可选值:base/all base:返回实况天气 all:返回预报天气 | 可选 | 无 | |
output | 返回格式 | 可选值:JSON,XML | 可选 | JSON | |
下面是我获取到的数据。


注意实时天气和天气预报是两个接口。
代码示例,此代码就可以获取到天气的json数据,通过json解析就可以将获取到的数据显示在UI上了。
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);
}
}
边栏推荐
- RAC delete damaged disk group
- 【云原生】那些看起来很牛X,原理却很简单的一行代码
- Y55. Chapter III kubernetes from entry to proficiency -- HPA controller and metrics server (28)
- The "functional art" jointly created by Bolang and Virgil abloh in 2021 to commemorate the 100th anniversary of Bolang brand will debut during the exhibition of abloh's works in the museum
- Rhcsa 04 - process management
- MAUI 入门教程系列(5.XAML及页面介绍)
- 十字路口通行优先权,十字路口通行规则图解
- 戳气球和布尔运算问题(巨难)
- 红队视角下的防御体系突破之第一篇介绍、阶段、方法
- 6-5漏洞利用-SSH弱口令破解利用
猜你喜欢

Change the background color of Kivy tutorial (tutorial includes source code)

6-5漏洞利用-SSH弱口令破解利用

Emlog user registration plug-in is worth 80 yuan

MySQL 索引和事务

GUI application: socket network chat room

十字路口通行优先权,十字路口通行规则图解

The five pictures tell you: why is there such a big gap between people in the workplace?

leetcode:1314. 矩阵区域和【二维前缀和模板】

Beipiao programmer, 20K monthly salary, 15W a year, normal?

5张图告诉你:同样是职场人,差距怎么这么大?
随机推荐
Leader: who uses redis expired monitoring to close orders and get out of here!
20000 words will take you to master multithreading
Rhcsa 03 - Basic permissions for documents
网络设备应急响应指南
附件二:攻防演练保密协议.docx
Correct the classpath of your application so that it contains a single, compatible version of com.go
RPC技术
Unity中RampTex介绍和应用: 溶解特效优化
[go] database framework Gorm
Sample template of software design document - learning / practice
Modstartblog modern personal blog system v5.2.0 source code download
The paddlehub face recognition scheme is deployed, and the trained model is deployed and applied in pytchrom
Precautions for accompanying driving these 23 points should be paid attention to!
Kivy教程之 自定义字体(教程含源码)
附件一:202x年xxx攻防演习授权委托书
LeetCode136+128+152+148
Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file
The "functional art" jointly created by Bolang and Virgil abloh in 2021 to commemorate the 100th anniversary of Bolang brand will debut during the exhibition of abloh's works in the museum
Wechat official account infinite callback authorization system source code
Virtual commodity account trading platform source code_ Support personal QR code collection