通过UNITY中的Textmeshpro(TMPro)UI显示当前系统时间

参考了b站教学视频:https://www.bilibili.com/video/BV1ig4y137wY 但是这个是unity自带的text的,而不是TMPro的时间,那么TMPro中应该如何调用呢? 首先创建一个C#脚本,命名为TIMEget,代码如下所示:

using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
using TMPro;

public class TIMEget : MonoBehaviour
{
    public TextMeshProUGUI CurrentTime;

    void Update()
    {
        DateTime NowTime = DateTime.Now.ToLocalTime();
        CurrentTime.text = NowTime.ToString("HH:mm:ss");
    }
}

其实整体是一样的,就是需要把public里面的text更改为TextMeshProUGUI,这个里面有个text函数能够修改调用TMP里面的文本内容,其他的基本一致。

其中,HH:mm:ss是时间日期格式,可以根据自己需要调用,这里我设置的是小时:分钟:时间,也可以加上年份。

创建好这个C#脚本之后,在需要进行修改的TMPro的Hierarchhy元素的inspector下Add Component找到上面的脚本,然后把这个TMP的物体从Hierarchy拖拽到刚才添加脚本的CurrentTime(none)空白处。 运行之后就可以看到当前系统时间了。

其他相关文章:

其他UNITY开发相关文章:https://www.gongyesheji.org/?cat=860

 

unity实现点击按钮多次延迟切换背景图片/界面 – 工设里世界 (gongyesheji.org)

 

[unity] implementation after clicking a button, delay and switch the background image/interface

There might be a better way, but so far I've found that you can do this, and you can try other ways.

 

Goal: In UNITY, after clicking a button, three screens (or Raw images) appear in sequence: the first screen appears 1 second later, the second screen appears 3 seconds later and the first screen disappears, and the third screen appears 3 seconds later and the second screen disappears. The first step is to create a C# script in Assets, let's name it delaydisplay3, double-click visual studio to open the edit.

(更多…)

unity实现点击按钮多次延迟切换背景图片/界面

本人学习了一下的小白写法,可能有更好的方式,但是目前我发现可以这么做,大家也可以试试其他方法。

目标:在UNITY中,点击按钮后,有三个界面(或Raw image)依次显示:第一个界面延迟1秒出现,第二个界面延迟3秒出现且第一个界面消失,第三个界面再延迟3秒出现且第二个界面消失。

首先是在Assets里面新建一个C#脚本,我们就命名为delaydisplay3吧,双击打开visual studio进行编辑。

(更多…)

浅谈我眼中真正的RPG游戏:AI与游戏的结合才能带来有趣的东西

在各国的文学作品和动画作品中,RPG游戏是永恒的话题之一,在日漫中可以列出一大串以RPG游戏为题材的作品。比如:

《刀剑神域》《加速世界》《线上游戏老婆不可能是女生》《网络胜利组》《灰与幻想的格林姆迦尔》《记录的地平线》《overload》等等,当然RPG题材也只是最近日漫烂大街的异世界穿越题材的一小部分,异世界穿越题材的《盾之勇者成名录》《无职转生到了异世界也要拿出真本事》《从零开始的异世界生活》系列等等也收获了很多的好评与大量的粉丝群体。最近《盾勇》的第三季也在播出,一部动漫动画化到第三季其实也证明了其受欢迎的程度。那么,为什么RPG和异世界穿越题材的动漫这么受欢迎呢?现代世界的RPG玩家到底在追求什么呢?

把话说的简单一点,为什么要玩游戏?是追求一种精神放松?满足感?还是荣誉感?还是都有?其实每个人玩游戏的目的都不一样。

(更多…)

How does UNITY remove plugins or packages

Plug-ins in unity are called packages or packages. In the development of hololens, it is often necessary to delete conflicting plug-ins due to various plug-in conflicts. For example, MRTK3 and MRTK2 plugins will conflict. So you need to use the following method to remove conflicting plug-ins.

Click on the menu bar window -- Package Manager -- select the package you want to delete and click remove. If it doesn't work, just restart the editor and recompile it.

(更多…)