UniStorm昼夜变化中时间的显示和控制
这里用的UniStorm版本是2.1
因为在unity中可以很方便的调节时间和天气,所以在一些不大的项目当中经常用到
开始一般使用可以用window菜单UniStorm里面创建对应的
一般会创建这个(我这里用的是c#版本),
当然创建了也可以手动进行修正,比如你要换个摄像机
可以把里面的player禁用掉,还有记得一定要把摄像机的远切平面调大,貌似要30000以上,不然远处的云和星空将被切掉,然后不可见
然后把上面的滤镜都搬到自己的摄像机上,这样差不多就完成了手动迁移
另外如果需要下雨之类的效果,还需要自己扩大区域,默认是在player周围的
还有要注意的就是运行才能看到效果,为了防止效果影响在window-lighting里面最好把skybox去掉,然后把上面截图里的Sun_Moon拖到Sun里面就好了
UniStorm的总控调节参数可以看UniStormSystemEditor这个物体,上面有很多参数调节
包括了昼夜分别的长度和起始时间,云的密度等等很多东西
但是没有提供代码控制,所以还是有不方便的地方
所以自己找来显示时间和控制时间的方式
下面是查到的显示时间的方式(需要自己建立一个canvas并有4个text组件拖上去)
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class myUniStormControlTime : MonoBehaviour {UniStormWeatherSystem_C uniStormSystem;GameObject uniStormObject;public bool use12hourclock = false;public Text ClockText;public Text DateText;public Text WeatherText;public Text TempText;// Use this for initializationvoid Start(){uniStormObject = GameObject.Find("UniStormSystemEditor");uniStormSystem = uniStormObject.GetComponent<UniStormWeatherSystem_C>();}void Update(){if (!use12hourclock){ClockText.text = "Current Time:" + "\n" + uniStormSystem.hourCounter.ToString() + ":" + uniStormSystem.minuteCounter.ToString("00");}if (use12hourclock){if (uniStormSystem.hourCounter <= 12){ClockText.text = "Current Time:" + "\n" + uniStormSystem.hourCounter.ToString() + ":" + uniStormSystem.minuteCounter.ToString("00") + " AM";}if (uniStormSystem.hourCounter >= 13){ClockText.text = "Current Time:" + "\n" + ((int)uniStormSystem.hourCounter - 12) + ":" + uniStormSystem.minuteCounter.ToString("00") + " PM";}}DateText.text = "Date:" + "\n" + uniStormSystem.monthCounter.ToString() + "/" + uniStormSystem.dayCounter.ToString() + "/" + uniStormSystem.yearCounter.ToString();WeatherText.text = "Current Weather:" + "\n" + uniStormSystem.weatherString.ToString();TempText.text = "Current Temperature:" + "\n" + uniStormSystem.temperature.ToString() + "°";}
}
显示效果如下
下面还有就是控制时间
using UnityEngine;
using System.Collections;public class StartingHour : MonoBehaviour
{public GameObject uniStormSystem;public int startingHour = 8;public float getDayLength;public bool startingHourReached = false;void Awake(){//uniStormSystem = GameObject.Find("UniStormPrefab_C/UniStormSystemEditor"); //Get our UniStorm Weather System gameObjectgetDayLength = uniStormSystem.GetComponent<UniStormWeatherSystem_C>().dayLength;}void Start(){uniStormSystem.GetComponent<UniStormWeatherSystem_C>().dayLength = 0.2f; //Sets our dayLength fast to calculate the proper time on start//Sets our time variablesuniStormSystem.GetComponent<UniStormWeatherSystem_C>().dayCounter = 1;uniStormSystem.GetComponent<UniStormWeatherSystem_C>().monthCounter = 1;uniStormSystem.GetComponent<UniStormWeatherSystem_C>().yearCounter = 2015;//uniStormSystem.GetComponent<UniStormWeatherSystem_C>().weatherForecaster = 1; //Changes the weather to foggyuniStormSystem.GetComponent<UniStormWeatherSystem_C>().fader = 1; //Fades in clouds instantly}void Update(){if (Input.GetKeyDown(KeyCode.W)){//这里是控制时间的uniStormSystem.GetComponent<UniStormWeatherSystem_C>().startTime +=0.1f;}if (startingHourReached == false){//niStormSystem.GetComponent<UniStormWeatherSystem_C>().lightFlareObject.light.intensity = 0; //Fades out our sun glare instantlyuniStormSystem.GetComponent<UniStormWeatherSystem_C>().lightningShadowIntensity = 0; //Fades out our sun glare instantly}//After everything is set disable by setting startingHourReachedTo trueif (uniStormSystem.GetComponent<UniStormWeatherSystem_C>().hourCounter == startingHour && startingHourReached == false){startingHourReached = true;uniStormSystem.GetComponent<UniStormWeatherSystem_C>().dayLength = getDayLength;uniStormSystem.GetComponent<UniStormWeatherSystem_C>().startTime = 0.2333f;}}
}
按w可以跳转时间,这里一天长度是1,可以根据24小时自己算
然后就能调节时间了
当然里面还能调节天气之类的
参考地址
http://unistorm-weather-system.wikia.com/wiki/Code_References
https://forum.unity3d.com/threads/unistorm-dynamic-day-night-weather-system-released-now-includes-unistorm-mobile-free.121021/page-48
http://unistorm-weather-system.wikia.com/wiki/Documentation
http://unistorm-weather-system.wikia.com/wiki/Tutorials
UniStorm昼夜变化中时间的显示和控制相关推荐
- select标签中option的显示隐藏控制(兼容IE)
问题描述: 在有些功能切换的时候,select标签中的某些option是要被隐藏的.但通过设置option的样式为 display:none根本无法隐藏option标签.(ie浏览器中option不支 ...
- php中时间轴开发,即显示为“刚刚”、“5分钟前”、“昨天10:23”等
php中时间轴开发,即显示为"刚刚"."5分钟前"."昨天10:23"等 其实这个没什么技术含量,当然就直接贴代码,不废话了(合肥旅游网), ...
- mysql date 24小时制_SpringBoor连接mysql数据库取数据库中时间格式是12小时制的时间,如何显示成24小时制...
设置spring配置文件: 1.spring.datasource.url=jdbc:mysql://10.35.105.25:3306/database?characterEncoding=utf- ...
- [转载]WEB中实时时间的显示
WEB中实时时间的显示 当你进入一个网站时,是否看到里面的一个非常体贴的时间提示,好象网易社区的小秘书,会按时间提示你一些东西.其实实现起来也没什么困难,下面一步一步来吧! 1.必须取得系统当前时间, ...
- wincc显示系统时间_在WINCC画面组态中,如何显示系统时间?-工业支持中心-西门子中国...
在wincc 的智能对象中 使用控件 选择DaclockCtrl 即可 调用的控件名称为WINCC Digital/Analog clock ctrol 回答者: KCN - 顶级工程师&nb ...
- qt5设置linux系统时间,Qt中使用QLabel显示时间的两种方法
Qt中使用QLabel显示时间的两种方法思路一致,只是实现方法不一样而已. main.cpp #include "displaytime.h" #include int main( ...
- java实现动态展示当前时间,在文本框中动态地显示当前时间,有木有人做过,指导下初学者...
在文本框中动态地显示当前时间,有木有人做过,指导下菜鸟? 想在两个文本框中,一个动态显示日期,一个动态显示时间. 如下图这样: 不过这是静态的. 虽然网上有动态的代码,但是javascript的. d ...
- ant design vue 表格中时间戳转换成时间格式显示
ant design vue 表格中时间戳转换成时间格式显示 原始数据表格如上图,因为接口传递过来的时间是10位int类型的时间戳格式,所以前端需要我们把时间格式化. step1 安装moment n ...
- 解决echart在tab中切换时显示不正确
在VUE使用Element UI时,在el-tab-pane添加上lazy='true'属性即可 <el-tab-pane label="远程测试控制" name=" ...
最新文章
- eclipse集成lombok
- GT Transceiver的总体架构梳理
- 微软职位内部推荐-Senior Software Engineer_Azure
- Android网络编程
- 爬虫学习笔记(四)—— urllib 与 urllib3
- 【WebRTC---入门篇】(十五)WebRTC信令服务器实现
- pandas dataframe多重索引常用操作
- hcfax2e伺服驱动器说明书_SD伺服驱动器说明书
- ubuntu下用VirtualBox安装Windows虚拟机
- 应届生web前端面试题_前端开发应届生面试指南(含各大公司具体指南及面试真题)...
- 人,要活得明白。活到极致,就是素与简。
- Github清除历史记录的方法
- spring概念理解之IOC(控制反转)
- enovia使用富文本小结
- vue 微信录音倒计时_vue的微信语音功能,录音+对接口返回amr音频播放-Go语言中文社区...
- Intel汇编-无符号整数除法
- 开源在线客服系统源码(支持PC/H5/公众号/小程序)基于golang的网页在线客服系统...
- It Was a Good Barn
- python爬虫爬当当网_爬虫实战一:爬取当当网所有 Python 书籍
- 湖仓一体:基于Iceberg的湖仓一体架构在B站的实践