博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UNITY中有Timer
阅读量:7014 次
发布时间:2019-06-28

本文共 505 字,大约阅读时间需要 1 分钟。

using UnityEngine;using System.Collections;using System.Timers;public class NewBehaviourScript : MonoBehaviour {	// Use this for initialization	void Start () {        Timer t = new Timer(100);        t.Elapsed += T_Elapsed_Handle;        t.Start();		}    private void T_Elapsed_Handle(object sender, ElapsedEventArgs e)    {        Debug.Log("T_Elapsed_Handle" + this.gameObject.name);    }

  输出:

get_gameObject can only be called from the main thread.

 

看来Coroutin的出现就是为了解决这个问题,方便大家使用,

当然往主线程里Enqeue消息也是可以的

 

转载地址:http://ashtl.baihongyu.com/

你可能感兴趣的文章
更换CentOS7的下载源为阿里云
查看>>
退出Android程序时清除所有activity的实现方法
查看>>
eclipse注释模板设置(未整理)
查看>>
Hibernate框架 主配置文件(Hibernate.cfg.xml)基本
查看>>
学习SpringMVC——从HelloWorld开始
查看>>
Say Hello to ConstraintLayout
查看>>
awk打印指定列以后的所有内容
查看>>
代码16
查看>>
用 kGDB 调试 Linux 内核
查看>>
ActiveMQ发布-订阅消息模式
查看>>
2017.3找工作面试记录-第一周(2)
查看>>
vuejs2.0子组件改变父组件的数据
查看>>
Java开发环境配置(4)--Maven安装 环境变量配置,本地仓库配置---插件安装
查看>>
【NIO】Java NIO之通道
查看>>
HDU 4287 Intelligent IME(map运用)
查看>>
[LeetCode] Subtree of Another Tree 另一个树的子树
查看>>
说说这些年做的云计算和大数据项目
查看>>
P1019 单词接龙
查看>>
linux下的开源移动图像监测程序--motion编译与配置【转】
查看>>
git的版本回退探索
查看>>