public Coroutine StartCoroutine(string methodName, object value = null);

Description

Starts a coroutine named methodName.

In most cases you want to use the StartCoroutine variation above. However StartCoroutine using a string method name allows you to use StopCoroutine with a specific method name. The downside is that the string version has a higher runtime overhead to start the coroutine and you can pass only one parameter.

// In this example we show how to invoke a coroutine using a string name and stop it

function Start () {
StartCoroutine("DoSomething", 2.0);
yield WaitForSeconds(1);
StopCoroutine("DoSomething");
} function DoSomething (someParameter : float) {
while (true) {
print("DoSomething Loop");
// Yield execution of this coroutine and return to the main loop until next frame
yield;
}
}
using UnityEngine;
using System.Collections; public class ExampleClass : MonoBehaviour {
IEnumerator Start() {
StartCoroutine("DoSomething", 2.0F);
yield return new WaitForSeconds(1);
StopCoroutine("DoSomething");
}
IEnumerator DoSomething(float someParameter) {
while (true) {
print("DoSomething Loop");
yield return null;
}
}
}

Stop单个Coroutine的更多相关文章

  1. C 的 coroutine 库 via 云风的 BLOG

    今天实现了一个 C 用的 coroutine 库. 我相信这个东西已经被无数 C 程序员实现过了, 但是通过 google 找了许多, 或是接口不让我满意, 或是过于重量. 在 Windows 下, ...

  2. asyncio模块中的Future和Task

      task是可以理解为单个coroutine,经过ensure_future方法处理而形成,而众多task所组成的集合经过asyncio.gather处理而形成一个future. 再不精确的粗略的说 ...

  3. Golang后台开发初体验

    转自:http://blog.csdn.net/cszhouwei/article/details/37740277 补充反馈 slice 既然聊到slice,就不得不提它的近亲array,这里不太想 ...

  4. Lua 协程coroutine

    协程和一般多线程的区别是,一般多线程由系统决定该哪个线程执行,是抢占式的,而协程是由每个线程自己决定自己什么时候不执行,并把执行权主动交给下一个线程. 协程是用户空间线程,操作系统其存在一无所知,所以 ...

  5. Lua的协程(coroutine)

    -------------------------------------------------------------------------------- -- 不携带参数 ---------- ...

  6. 使用tornado的gen.coroutine进行异步编程

    在tornado3发布之后,强化了coroutine的概念,在异步编程中,替代了原来的gen.engine, 变成现在的gen.coroutine.这个装饰器本来就是为了简化在tornado中的异步编 ...

  7. Unity脚本编程之——协程(Coroutine)

    本文翻译自Unity官方文档:https://docs.unity3d.com/Manual/Coroutines.html 专有名词: Coroutine 协程 Alpha 不透明度 当你调用一个函 ...

  8. skynet coroutine 运行笔记

    阅读云大的博客以及网上关于 skynet 的文章,总是会谈服务与消息.不怎么看得懂代码,光读这些文字真的很空洞,不明白说啥.网络的力量是伟大的,相信总能找到一些解决自己疑惑的文章.然后找到了这篇讲解 ...

  9. python generator与coroutine

    python  generator与coroutine 协程 简单介绍 协程,又称微线程,纤程,英文名Coroutine.协程是一种用户态的轻量级线程,又称微线程.协程拥有自己的寄存器上下文和栈,调度 ...

随机推荐

  1. Java实现冒泡排序,选择排序,插入排序

    冒泡排序: 思想: 冒泡排序重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地进行直到没有再需要交换,也就是说排序完成 特点:比较稳定,排序数较小是 ...

  2. js 的各种排序算法 -- 待续

    链接 function quickSort(arr,l,r){ if(l < r){ var i = l, j = r, x = arr[i]; while(i<j){ while(i&l ...

  3. springmvc的表单标签

    1. Spring提供的轻量级标签库 2.可在JSP页面中渲染HTML元素的标签 3 用法 1)必须在JSP页面的开头处声明taglib指令 <%@ taglib prefix="fm ...

  4. dir listing 目录文件列表索引

    一般而言,网站应用都有一个入口,比如说:index.php,index.html,app.js等.通过这个路口,以及相应的路由功能,去到网站各个功能版块. 而网站的目录结构,目录里面的文件列表,一般都 ...

  5. Linux系列:Linux中如何安装.rpm、.tar、.tar.gz和tar.bz2文件

    转载自:https://blog.csdn.net/lanxuezaipiao/article/details/21896579 我以下面三个包为例:(三个包都在/etc/opt下) A. examp ...

  6. Codeforces 106A:Card Game

    题目链接http://codeforces.com/contest/106/problem/A 题意:一套牌有S.H.D.C四种花色,按等级分成6.7.8.9.T.J.Q.K.A.每次选出一个花色作为 ...

  7. MySQL 练习题4

    1.表结构如下: #课程表 CREATE TABLE `course` ( `c_id` ) NOT NULL, `c_name` ) DEFAULT NULL, `t_id` ) DEFAULT N ...

  8. leetcode:Insert Sort List

    问题描写叙述 对一个单链表进行插入排序,head指向第一个结点. 代码 /** * Definition for singly-linked list. * struct ListNode { * i ...

  9. ETL流程概述及常用实现方法

    ETL流程概述及常用实现方法 http://blog.csdn.net/btkuangxp/article/details/48224187 目录(?)[-] 1抽取作业 1手工开发抽取作业时候的常用 ...

  10. Accessing data in Hadoop using dplyr and SQL

    If your primary objective is to query your data in Hadoop to browse, manipulate, and extract it into ...