unity-编辑器协程


title: unity-编辑器协程
categories: Unity3d
tags: [unity, 编辑器, 协程]
date: 2022-01-13 15:03:30
comments: false
mathjax: true
toc: true

unity-编辑器协程


前篇

  • Editor Coroutines - https://docs.unity3d.com/2022.1/Documentation/Manual/com.unity.editorcoroutines.html
  • 相关文档: https://docs.unity3d.com/Packages/com.unity.editorcoroutines@0.0/api/Unity.EditorCoroutines.Editor.EditorCoroutine.html

官方通过 package 支持的版本


使用

  1. 安装 Editor Coroutines

    windows -> package manager 调出包管理界面, 输入 editor coroutines 安装节课

  2. 代码

    // 1. 命名空间
    using Unity.EditorCoroutines.Editor;
    
    // 2. 协程方法
    IEnumerator Test_Cor(string name, int age) {
        Debug.LogFormat("--- Test_Cor begin, name: {0}, age: {1}", name, age);
        for (int i = 0; i < 3; i++) {
            Debug.LogFormat("--- Test_Cor doing, cnt: {0}", i);
            yield return new EditorWaitForSeconds(1); // 这个是 editor 的 WaitForSeconds
        }
        Debug.LogFormat("--- Test_Cor begin, name: {0}, age: {1}", name, age);
    }
    
    // 3. 执行协程
    EditorCoroutineUtility.StartCoroutineOwnerless(Test_Cor("hello", 123));
    
    • 效果


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谷歌上架及老账号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值