当前位置:网站首页>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);
}
}
边栏推荐
- Instructions for LPC interrupt binding under ft2000+
- Niuke Xiaobai monthly race 49
- 附件六:防守工作簡報.docx
- 附件三:防守方评分标准.docx
- Redis: order collection Zset type data operation command
- 西部数据绿盘、蓝盘、黑盘、红盘和紫盘有什么区别
- Operate the server remotely more gracefully: the practice of paramiko Library
- Can closed data be deleted by DBCA? can
- 红队视角下的防御体系突破之第二篇案例分析
- EIG在智利推出可再生能源平台Grupo Cerro
猜你喜欢

Correct the classpath of your application so that it contains a single, compatible version of com. go

附件五:攻击过程简报.docx

分享一些我的远程办公经验

多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者

牛客小白月赛49

优秀的测试/开发程序员是怎么修炼的?该往哪走......

Deep parsing structured exception handling (SEH) - by Matt Pietrek

Experience sharing of epidemic telecommuting | community essay solicitation

Instructions for LPC interrupt binding under ft2000+

附件六:防守工作简报.docx
随机推荐
(pointer) write function void fun (int x, int *pp, int *n)
Asahi Kasei participated in the 5th China International Import Expo (5th ciie) for the first time
[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise
[Yugong series] go teaching course 002 go language environment installation in July 2022
Main applications of TDK lambda power supply
Change the background color of Kivy tutorial (tutorial includes source code)
【愚公系列】2022年7月 Go教学课程 002-Go语言环境安装
附件2-2保密承诺书.docx
Y55. Chapter III kubernetes from entry to proficiency -- HPA controller and metrics server (28)
[security attack and Defense] how much do you know about serialization and deserialization?
Zhengzhou zhengqingyuan Culture Communication Co., Ltd.: seven marketing skills for small enterprises
Deep parsing structured exception handling (SEH) - by Matt Pietrek
"Don't care too much about salary when looking for a job", this is the biggest lie I've ever heard
附件六:防守工作簡報.docx
多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者
B. All Distinct
B. All Distinct
MySQL 索引和事务
MySQL JDBC programming
在代码中使用度量单位,从而生活更美好