ユニティコルーチンポイント

コルーチンタイミングを使用する関数ことに留意すべきである
使用される1つのコルーチン成分、及び他の変数は前例に設定され、ブランクコルーチンであるべきであるが、
コルーチンブランキングコルーチン2.前に停止すべきである
コルーチンながらそれを確保するために3.一度だけ実行し、スタートコルーチンのセキュリティコードの前に添加してもよい:変更コルーチンがあるかどうかを決定し、コルーチンプレゼンスコルーチンは停止ブランキング
方法を:

local function setMyTime()
    --注意(3)
    if this.countdown then
        coroutine.stop(this.countdown)
        this.countdown = nil
    end
    this.countdown = coroutine.start(function()
        while true do
            this.tm=this.tm-1--用到的变量
            coroutine.wait(1)
        end
    end)
end
注意(2)
if this.countdown then
    coroutine.stop(this.countdown)
    --注意(1)
    this.countdown = nil
end
--假设此时需要对this.tm置空
this.tm=nil

おすすめ

転載: www.cnblogs.com/shirln/p/11799719.html