unity中DatePicker和Calendar

unity日期选择插件 DatePicker for UnityUI unity日期选择插件 DatePicker for UnityUI 仅供学习,请勿商用。 立即下载

日历效果如下图所示,需要自己搭建UI界面。

DatePicker


/*=========================================
* Author: springDong
* Description: SpringGUI.DatePicker
* DatePicker has lisened onDayClick/onMonthClick/onYearClick three interfaces .
* You can set date by DateTime property.
==========================================*/

using System;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine;

public class DatePicker : MonoBehaviour
{
    private Text _dateText = null;
    private Calendar _calendar = null;
    private DateTime _dateTime = DateTime.Today;

    // get data from this property
    public DateTime DateTime
    {
        get { return _dateTime; }
        set
        {
            _dateTime = value;
            refreshDateText();
        }
    }

    protected  void Awake()
    {
        _dateText = this.transform.Find("DateText").GetComponent<Text>();
        _calendar = this.transform.Find("Calendar").GetComponent<Calendar>();
        _calendar.onDayClick.AddListener(dateTime => { DateTime = dateTime; });
        transform.Find("PickButton").GetComponent<Toggle>().onValueChanged.AddListener((isOn) =>
         {
             if (isOn)
             {
                 _calendar.gameObject.SetActive(true);
             }
             else 
             {
                 _calendar.gameObject.SetActive(false);
             }
             
         });
        refreshDateText();
    }

    private void refreshDateText()
    {
        if (_calendar.DisplayType == E_DisplayType.Standard)
        {
            switch (_calendar.CalendarType)
            {
                case E_CalendarType.Day:
                    _dateText.text = DateTime.ToString("yyyy-MM-dd");
                    break;
                case E_CalendarType.Month:
                    _dateText.text = DateTime.Year + "/" + DateTime.Month;
                    break;
                case E_CalendarType.Year:
                    _dateText.text = DateTime.Year.ToString();
                    break;
            }
        }
        else
        {
            switch (_calendar.CalendarType)
            {
                case E_CalendarType.Day:
                    _dateText.text = DateTime.ToString("yyyy-MM-dd");
                    break;
                case E_CalendarType.Month:
                    _dateText.text = DateTime.Year + "-" + DateTime.Month;
                    break;
                case E_CalendarType.Year:
                    _dateText.text = DateTime.Year.ToString();
                    break;
            }
        }
        _calendar.gameObject.SetActive(false);
    }

    private void Update()
    {

        ////鼠标左键关闭日历
        //if (Input.GetMouseButtonDown(0)) 
        //{
        //    _calendar.gameObject.SetActive(false);
        //}
    }
}

Calendar


/*=========================================
* Author: springDong
* Description: SpringGUI.Calendar
* This component you only need to listen onDayClick/onMonthClick/onYearClick three interfaces
* Interface return DateTime class data.
==========================================*/

using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using UnityEngine.Events;
using Object = UnityEngine.Object;

public class Calendar : MonoBehaviour
    {
        #region click events
        public class DayClickEvent : UnityEvent<DateTime>{}
        public class MonthClickEvent : UnityEvent<DateTime> { }
        public class YearClickEvent : UnityEvent<DateTime> { }

        private DayClickEvent m_onDayClickEvent = new DayClickEvent();
        public DayClickEvent onDayClick
        {
            get { return m_onDayClickEvent; }
            set { m_onDayClickEvent = value; }
        }
        private MonthClickEvent m_onMonthClickEvent = new MonthClickEvent();
        public MonthClickEvent onMonthClick
        {
            get { return m_onMonthClickEvent; }
            set { m_onMonthClickEvent = value; }
        }
        private YearClickEvent m_onYearClickEvent = new YearClickEvent();
        public YearClickEvent onYearClick
        {
            get { return m_onYearClickEvent; }
            set { m_onYearClickEvent = value; }
        }

        #endregion

        #region private && public members
        private DateTime m_selectDT = DateTime.Today;
        private readonly CalendarData m_calendarData = new CalendarData();
        private Transform m_Transform = null;
        [HideInInspector]
        public E_CalendarType CalendarType = E_CalendarType.Day;
        public E_DisplayType DisplayType = E_DisplayType.Chinese;
        private Text _timeButtonText = null;
        private GameObject _weeksGameObject = null;
        private GameObject _daysGameObejct = null;
        private GameObject _monthGameObject = null;
        private readonly List<DMY> _daysPool = new List<DMY>();
        private readonly List<DMY> _monthYearPool = new List<DMY>();
        #endregion

        protected  void Awake()
        {
            m_Transform = transform;
            _timeButtonText = m_Transform.Find("Title/TimeButton/Text").GetComponent<Text>();
            _weeksGameObject = m_Transform.Find("Container/Weeks").gameObject;
            _daysGameObejct = m_Transform.Find("Container/Days").gameObject;
            _monthGameObject = m_Transform.Find("Container/Months").gameObject;
            var weekPrefab = _weeksGameObject.transform.Find("WeekTemplate").gameObject;
            var dayPrefab = _daysGameObejct.transform.Find("DayTemplate").gameObject;
            var monthPrefab = _monthGameObject.transform.Find("MonthTemplate").gameObject;
            WeekGenerator(weekPrefab, _weeksGameObject.transform);
            DayGenerator(dayPrefab, _daysGameObejct.transform);
            MonthGenerator(monthPrefab, _monthGameObject.transform);
            m_Transform.Find("Title/NextButton").GetComponent<Button>().onClick.AddListener(OnNextButtonClick);
            m_Transform.Find("Title/LastButton").GetComponent<Button>().onClick.AddListener(OnLastButtonClick);
            m_Transform.Find("Title/TimeButton").GetComponent<Button>().onClick.AddListener(OnTimeButtonClick);
            Refresh();
        }

        #region operation functions
        private void OnTimeButtonClick()
        {
            if ( CalendarType == E_CalendarType.Month )
                CalendarType = E_CalendarType.Year;
            if (CalendarType == E_CalendarType.Day)
            {
                CalendarType = E_CalendarType.Month;
                calendarTypeChange(false);
            }
            Refresh();
        }
        private void OnNextButtonClick()
        {
            if ( CalendarType == E_CalendarType.Day )
                m_selectDT = m_selectDT.AddMonths(1);
            else if ( CalendarType == E_CalendarType.Month )
                m_selectDT = m_selectDT.AddYears(1);
            else 
                m_selectDT = m_selectDT.AddYears(12);
            Refresh();
        }
        private void OnLastButtonClick()
        {
            if(CalendarType == E_CalendarType.Day)
                m_selectDT = m_selectDT.AddMonths(-1);
            else if(CalendarType == E_CalendarType.Month)
                m_selectDT = m_selectDT.AddYears(-1);
            else 
                m_selectDT = m_selectDT.AddYears(-12);
            Refresh();
        }
        #endregion

        #region days && weeks && months generator
        private void WeekGenerator( GameObject weekPrefab ,Transform parent )
        {
            for (int i = 0; i < 7; i++)
            {
                GameObject week = prefabGenerator(weekPrefab , parent);
                week.GetComponent<Text>().text = getWeekName(i.ToString());
            }
            Destroy(weekPrefab);
        }
        private void DayGenerator( GameObject dayPrefab , Transform parent )
        {
            for (int i = 0; i < 42; i++)
            {
                GameObject day = prefabGenerator(dayPrefab,parent);
                DMY dmy = day.AddComponent<DMY>();
                day.GetComponent<Button>().onClick.AddListener(() =>
                {
                    m_selectDT = dmy.DateTime;
                    onDayClick.Invoke(dmy.DateTime);
                    Refresh();
                });
                _daysPool.Add(dmy);
            }
            Destroy(dayPrefab);
        }
        private void MonthGenerator( GameObject monthPrefab , Transform parent )
        {
            for ( int i = 0 ; i < 12 ; i++ )
            {
                GameObject month = prefabGenerator(monthPrefab , parent);
                DMY dmy = month.AddComponent<DMY>();
                month.GetComponent<Button>().onClick.AddListener(() =>
                {
                    m_selectDT = dmy.DateTime;
                    if ( CalendarType == E_CalendarType.Month )
                    {
                        CalendarType = E_CalendarType.Day;
                        calendarTypeChange(true);
                        onMonthClick.Invoke(dmy.DateTime);
                    }
                    if (CalendarType == E_CalendarType.Year)
                    {
                        CalendarType = E_CalendarType.Month;
                        onYearClick.Invoke(dmy.DateTime);
                    }
                    Refresh();
                });
                _monthYearPool.Add(dmy);
            }
            Destroy(monthPrefab);
        }
        private GameObject prefabGenerator( GameObject prefab,Transform parent )
        {
            GameObject go = Object.Instantiate(prefab);
            go.transform.SetParent(parent);
            go.transform.localScale = Vector3.one;
            return go;
        }
        private string getWeekName( string weekName )
        {
            switch (DisplayType)
            {
                case E_DisplayType.Standard:
                    switch ( weekName )
                    {
                        case "0":
                            return "Sunday";
                        case "1":
                            return "Monday";
                        case "2":
                            return "Tuesday";
                        case "3":
                            return "Wednesday";
                        case "4":
                            return "Thursday";
                        case "5":
                            return "Friday";
                        case "6":
                            return "Saturday";
                        default:
                            return "";
                    }
                case E_DisplayType.Chinese:
                    switch ( weekName )
                    {
                        case "0":
                            return "日";
                        case "1":
                            return "一";
                        case "2":
                            return "二";
                        case "3":
                            return "三";
                        case "4":
                            return "四";
                        case "5":
                            return "五";
                        case "6":
                            return "六";
                        default:
                            return "";
                    }
                default:
                    return "";
            }
            
        }
        private void calendarTypeChange( bool isDays )
        {
            _weeksGameObject.SetActive(isDays);
            _daysGameObejct.SetActive(isDays);
            _monthGameObject.SetActive(!isDays);
        }
        #endregion

        #region refresh calendar all component
        private void Refresh( )
        {
            RefreshCalendar();
            RefreshTimeButtonContent();
        }
        private void RefreshTimeButtonContent( )
        {
            switch ( CalendarType )
            {
                case E_CalendarType.Day:
                    if ( DisplayType == E_DisplayType.Standard ) _timeButtonText.text = m_selectDT.ToShortDateString();
                    else _timeButtonText.text = m_selectDT.Year + "年" + m_selectDT.Month + "月" + m_selectDT.Day + "日";
                    break;
                case E_CalendarType.Month:
                    if ( DisplayType == E_DisplayType.Standard ) _timeButtonText.text = m_selectDT.Year + "/" + m_selectDT.Month;
                    else _timeButtonText.text = m_selectDT.Year + "年" + m_selectDT.Month + "月";
                    break;
                case E_CalendarType.Year:
                    if ( DisplayType == E_DisplayType.Standard ) _timeButtonText.text = m_selectDT.Year.ToString();
                    else _timeButtonText.text = m_selectDT.Year + "年";
                    break;
            }
        }
        private void RefreshCalendar( )
        {
            if(CalendarType == E_CalendarType.Day) RefreshDays(m_calendarData.Days(m_selectDT));
            else if(CalendarType == E_CalendarType.Month) RefreshMonths(m_calendarData.Months(m_selectDT));
            else RefreshYears(m_calendarData.Years(m_selectDT));
        }
        private void RefreshDays( List<DateTime> dateTimes )
        {
            for (int i = 0; i < _daysPool.Count; i++)
            {
                var fontColor = Color.black;
                if (dateTimes[i].Month != m_selectDT.Month)
                    fontColor = Color.gray;
                _daysPool[i].SetDay(dateTimes[i] , DisplayType , fontColor);
            }
        }
        private void RefreshMonths( List<DateTime> dateTimes )
        {
            for ( int i = 0 ; i < _monthYearPool.Count ; i++ )
                _monthYearPool[i].SetMonth(dateTimes[i] , DisplayType);
        }
        private void RefreshYears( List<DateTime> dateTimes )
        {
            for ( int i = 0 ; i < _monthYearPool.Count ; i++ )
                _monthYearPool[i].SetYear(dateTimes[i] , DisplayType);
        }
        #endregion
    }

    public enum E_CalendarType
    {
        Day,
        Month,
        Year
    }
    public enum E_DisplayType
    {
        Standard,
        Chinese
    }
    public class CalendarData
    {
        public List<DateTime> Days( DateTime month )
        {
            List<DateTime> days = new List<DateTime>();
            DateTime firstDay = new DateTime(month.Year , month.Month , 1);
            DayOfWeek week = firstDay.DayOfWeek;
            int lastMonthDays = (int)week;
            if ( lastMonthDays.Equals(0) )
                lastMonthDays = 7;
            for ( int i = lastMonthDays ; i > 0 ; i-- )
                days.Add(firstDay.AddDays(-i));
            for ( int i = 0 ; i < 42 - lastMonthDays ; i++ )
                days.Add(firstDay.AddDays(i));
            return days;
        }
        public List<DateTime> Months( DateTime year )
        {
            List<DateTime> months = new List<DateTime>();
            DateTime firstMonth = new DateTime(year.Year , 1 , 1);
            months.Add(firstMonth);
            for ( int i = 1 ; i < 12 ; i++ )
                months.Add(firstMonth.AddMonths(i));
            return months;
        }
        public List<DateTime> Years( DateTime year )
        {
            List<DateTime> years = new List<DateTime>();
            for ( int i = 5 ; i > 0 ; i-- )
                years.Add(year.AddYears(-i));
            for ( int i = 0 ; i < 7 ; i++ )
                years.Add(year.AddYears(i));
            return years;
        }
    }
    public class DMY : MonoBehaviour
    {
        public DateTime DateTime { get; set; }
        private Text _text = null;
        protected  void Awake( )
        {
            _text = transform.Find("Text").GetComponent<Text>();
        }
        public void SetDay( DateTime dateTime , E_DisplayType displayType , Color fontColor )
        {
            DateTime = dateTime;
            _text.text = dateTime.Day.ToString();
            _text.color = fontColor;
        }
        public void SetMonth( DateTime dateTime , E_DisplayType displayType )
        {
            DateTime = dateTime;
            _text.text = getMonthString(dateTime.Month.ToString() , displayType);
        }
        public void SetYear( DateTime dateTime , E_DisplayType displayType )
        {
            DateTime = dateTime;
            _text.text = dateTime.Year.ToString();
        }
        private string getMonthString( string month , E_DisplayType displayType )
        {
            switch ( displayType )
            {
                case E_DisplayType.Standard:
                    switch ( month )
                    {
                        case "1":
                            return "Jan.";
                        case "2":
                            return "Feb.";
                        case "3":
                            return "Mar.";
                        case "4":
                            return "Apr.";
                        case "5":
                            return "May.";
                        case "6":
                            return "Jun.";
                        case "7":
                            return "Jul.";
                        case "8":
                            return "Aug.";
                        case "9":
                            return "Sept.";
                        case "10":
                            return "Oct.";
                        case "11":
                            return "Nov.";
                        case "12":
                            return "Dec.";
                        default:
                            return "";
                    }
                case E_DisplayType.Chinese:
                    switch ( month )
                    {
                        case "1":
                            return "一月";
                        case "2":
                            return "二月";
                        case "3":
                            return "三月";
                        case "4":
                            return "四月";
                        case "5":
                            return "五月";
                        case "6":
                            return "六月";
                        case "7":
                            return "七月";
                        case "8":
                            return "八月";
                        case "9":
                            return "九月";
                        case "10":
                            return "十月";
                        case "11":
                            return "十一月";
                        case "12":
                            return "十二月";
                        default:
                            return "";
                    }
                default:
                    return "";
            }
        }
    }

 

unity日期选择插件 unity的日期选择插件,里面包含多个插件,从简单到复杂的都有,这里拿来和大家分享一下,我会经常查看留言的,希望大家多多关注 立即下载

相关推荐

DatePicker for UnityUI Unity日期选择DatePicker工具

亲测可用:https://blog.youkuaiyun.com/luckydogyxx/article/details/109049985

Unity SDK对接全攻略之Android

本课程带大家学习Unity和Android交互相关的知识,如果你是刚接触Android,或刚接到对接SDK的任务,那么这堂课程你一定不要错过,带你从零到对接一款SDK的全流程。课程包括五个大的部分,从环境配置到发布、到发布第一款APK,除了Unity内置的一些相关的跨平台的知识,还会带你飞速熟悉Android开发,讲解完Unity和Android交互还会带你接一款讯飞语音识别的SDK。

DatePicker for UnityUI 1.18

DatePicker for UnityUI 1.18 时间选择器,日历形式选择时间

Unity3D UGUI制作滚动日期选择(无限滚动)

Unity3D UGUI制作滚动日期选择(无限滚动) 首先上效果图和层次结构 效果图-层次结构DatePickerGroup(日期选择组) DatePickerGroup需要将所属的DatePicker添加到DatePickerList中,共同控制选择的时间。 DatePicker(时间选择器) DatePicker中Mask组件和Image组件起着遮罩的作用, Date...

wxw705757104的博客 5826

DatePicker for UnityUI 1.18.7z

日期选择器, DatePicker for UnityUI 说明:https://blog.youkuaiyun.com/qq_33789001/article/details/114834776

Unity UI边缘流光特效插件

1.UI流光特效插件,包含了大量UI特效。 2.满足你各种各样的UI特效需求,让你的UI不再单调! 3.包含各种Shander及流光贴图资源。 4.代码简单易上手学习。 5.仅用于学习交流,切勿商用。

Unity自定义UI组件(六)日历、日期拾取器

前言考虑到工业项目中可能会利用到类似日历的工具,就比如选取某个时间节点,所以我结合UGUI源码开发了日历工具和日期拾取器工具,简单易用,接口齐全,可中文显示,外观可自定义。只需要导入脚本,即可在Hierarchy面板直接创建组件,和使用自带组件一样方便。 主要内容:1.日历工具(仿Winform平台的Calendar组件) 2.日期拾取器 3.如何使用日历组件和日期拾取器组件

SpringD 1万+

Unity获取时间UI日历控件

已购专栏的用户找博主免费获取 工具博客地址:http://t.csdn.cn/u2w95 三种常用日期选择UI控件工具 一. DataPicker的简介 一种是常显,一种是按钮控制显示逻辑,可以设置年,月,日。并输出结果 二. DateTimePicker的简介 可以设置年,月,日,时,分,秒。并输出结果 三. FlatCalendar的简介 可以设置年,月,日。并输出结果

Unity日期选择DatePicker工具

如图: 下载地址https://download.youkuaiyun.com/download/luckydog1120446388/12921204

Lucky Dog's Zone 3566

unity简单的日历表插件

unity简单的日历表插件

SoIC、CoWoS、InFO一次讲透:从2D/2.5D/3D看懂先进封装

先进封装是后摩尔时代提升芯片性能的关键路径,但面对SoIC、CoWoS、InFO这些名词,很多人容易混淆。理解它们,需从最基本的2D、2.5D、3D封装概念入手:2D是传统平房,2.5D通过硅中介层实现高密度互连,3D则让芯片直接堆叠。CoWoS作为2.5D中介层封装,已成为AI芯片与HBM高带宽存储集成的行业标准;SoIC通过铜-铜混合键合实现真正的3D堆叠,为逻辑与缓存提供极致带宽;InFO以扇出型封装兼顾成本与集成度,广泛用于移动SoC。在系统级封装(SiP)和CPO共封装光学等前沿趋势中,这些技术往

weixin_42388898的博客 309

Unity 日历插件组件-日期选择器2D(二)

日期选择的工具。可更改ui和尺寸用于不同场合。个人总结归纳,便于使用。避免重复造轮子~~~优快云组件下载:https://download.youkuaiyun.com/download/u014641682/87563968。

u014641682的博客 3201

HAL库移植实战:解决‘HAL_StatusTypeDef‘未定义报错的3个关键步骤

本文针对STM32开发中从标准库向HAL库移植时常见的'HAL_StatusTypeDef'未定义报错,提供了三个关键解决步骤:首先确保正确包含头文件入口,其次检查并配置模块使能宏,最后注意避免与标准库的同名结构体混用。文章通过实战案例解析了HAL库的模块化设计理念,帮助开发者高效解决混合编程中的编译问题。

book8的博客 207

datepicker unity 下载_unity游戏日期时间选择编辑GUI插件DateTime Picker v1.0

DateTime Picker 1.0年月日时间日期分秒选择编辑插件,可自定义日期的格式。Script to build datetime picker using Unity UI objects and tools.100% customizable and editable.C # code.Select one or more dates depending on your needs.S...

weixin_39832628的博客 782

告别混乱!用Cadence Capture CIS高效管理你的原理图库:以单逻辑器件K9F2G08U0M为例

本文以单逻辑器件K9F2G08U0M为例,详细介绍了如何使用Cadence Capture CIS高效管理原理图库。通过三级分类体系、工程化命名规范和智能检索技术,帮助工程师实现从混乱到有序的转变,提升团队协作效率和设计准确性。

aizhi0169的博客 398

一分钟学会MATLAB-数据清洗(含完整代码)

数据清洗是数据分析过程中的一个重要步骤,目的是提高数据的质量,以便进行更有效的分析。% 删除超出阈值的行。% 用线性插值填充缺失值。% 删除包含缺失值的行。% 找到缺失值的位置。% 可视化数据,识别异常值。缺失值是数据清洗中常见的问题。通过以上步骤,你可以有效地清洗数据,使其准备好进行后续的分析和建模。

2402_87132195的博客 3316

【Unity3D】日期选择器

本文介绍了Unity3D开发中实现日期选择器的探索过程。作者首先尝试使用现成的DatePicker for Unity UI插件,该插件功能丰富(支持日期范围选择、多平台兼容、本地化等),但在实际使用中出现了日期显示异常的问题。随后参考ChoiceDatePicker方案进行二次开发,实现了基本日期选择功能,但仍存在操作体验不佳(拖动困难)、校验不完善等问题。两种方案各有利弊,反映了在Unity中实现复杂UI组件时面临的技术挑战。

zhchyun 759

openclaw本地模型对接

使用是官方推荐的一种集成方式,它可以简化配置过程。但由于您的系统环境和之前复杂的配置历史,我为您梳理了一个核心流程,并增加了关键的“事后检查”步骤,以确保能从根本上解决问题。

suny8的专栏 2459

Unity Calendar 日历功能

Unity Calendar 日历功能

当代野生程序猿 2806

Linux内核配置选项详解及编译过程

在内核编译完成后,可以通过重启系统并选择新编译的内核来使用它。可以在该菜单下选择需要编译进内核的设备驱动,也可以选择将设备驱动编译为模块。可以在该菜单下选择需要编译进内核的设备驱动,也可以选择将设备驱动编译为模块。可以选择需要的调试选项,并根据需要启用或禁用相应的功能。可以选择需要的文件系统类型,并根据需要启用或禁用相应的选项。可以选择需要的网络协议和功能,并根据需要启用或禁用相应的选项。可以选择需要的调试选项,并根据需要启用或禁用相应的功能。可以选择需要的文件系统类型,并根据需要启用或禁用相应的选项。

TechGlide的博客 746

YOLOv8【第十一章:视频追踪与流处理篇·第6节】BoT-SORT 改进:结合相机运动补偿(CMC)提升追踪稳定性!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏。该专栏系统复现并梳理全网各类 YOLOv8 改进与实战案例(当前已覆盖分类 / 检测 / 分割 / 追踪 / 关键点 / OBB 检测等方向),坚持持续更新 + 深度解析,质量分长期稳定在 97 分以上,可视为当前市面上 覆盖较全、更新较快、实战导向极强 的 YOLO 改进系列内容之一。

**My Coding Family** 717

提升Unity项目用户体验的利器:DatePicker for UnityUI

提升Unity项目用户体验的利器:DatePicker for UnityUI 【下载地址】UnityUI日期选择器工具-DatePickerforUnityUI 本仓库提供了一个适用于UnityUI的日期选择器工具,名为“DatePicker for UnityUI”。该工具旨在帮助Unity开发者在其项目中轻松实现日...

gitblog_09707的博客 424

工业激光器核心参数详解与选型实战:从理论到产线落地(五)

本文深入解析了脉冲激光加工的三大核心参数——脉宽、重复频率和脉冲能量的协同作用机制。通过公式推导和产线案例,揭示了参数设置对加工良率的关键影响:1. 脉宽决定热影响区大小,缩短脉宽可显著提升加工精度;2. 重复频率影响加工速度和热积累效应,需平衡效率与质量;3. 脉冲能量决定材料去除量,过大易导致加工缺陷。文中以ABS塑料打标、模具清洗和微孔钻孔为例,展示了参数优化如何将良率从65%提升至99%,并提供了不同应用场景的参数选型表和调试技巧,强调峰值功率比平均功率更具决定性作用。

weixin_44520581的博客 2421

Unity 制作时间选择器

首先来看一下要实现的功能效果 一、搭建场景 新建一个按钮,用来控制选择时间界面的显示的。如下,按钮下有一个图片,一个Text。图片用来显示箭头,文字用来显示选择的时间 新建TimeDate界面(时间选择界面)。.背景啥的全看个人爱好设计。这里只是随便弄了一个。主要的内容全部在Time的下面。下面开始搭建一下,(以年为例,月,日,时,分,秒和年同理) 新建一张Image,起名Year_Picke...

1万+

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Unity 日历插件组件-日期选择器2D(一)

工作中时常能用到日期选择的工具,实现灵活选择、设置日期!提示:组件结构简单,层级明朗,便于理解。可更改ui和尺寸用于不同场合。个人总结归纳,便于使用。避免重复造轮子~~~优快云组件下载:https://download.youkuaiyun.com/download/u014641682/87552703。

u014641682的博客 1838

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: unity中将3D场景中的3DUI界面转换为2DUI界面(方法一)
下一篇: unity中鼠标检测指定层的物体
科幻之眼
博客等级 码龄9年 101粉丝 153原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值